Edge: browserAction.setIcon not working when using a default icon with multiple sizes

前端 未结 1 1407
长发绾君心
长发绾君心 2021-01-22 05:37

I can\'t get browser.browserAction.setIcon to work in Microsoft Edge when manifest.json is specifying a default icon in multiple sizes:

manifest

1条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-22 06:20

    In the end I came to the conclusion that Edge doesn't like string values for the browser action icon path, neither in manifest.json nor in browserAction.setIcon, it fails silently without producing any error.

    A way to make it work is to always set explicit sizes in both manifest.json and in every browserAction.setIcon call, even if the different sizes all point to the same image.

    manifest.json

    {
      "manifest_version": 2,
      "name": "test",
      "version": "0.0.1",
      "author": "John Doe",
      "background": {
        "scripts": ["background.js"],
        "persistent": false
      },
      "browser_action": {
        "default_icon": {
          "19": "icon.png",
          "38": "icon2.png"
        }
      }
    }
    

    background.js

    browser.browserAction.setIcon({
        path: {
          "19": "testimage.png",
          "38": "testimage.png"
    });
    

    0 讨论(0)
提交回复
热议问题