mdn / content

The content behind MDN Web Docs
https://developer.mozilla.org
Other
9.15k stars 22.47k forks source link

browserAction undefined if browser_action missing in manifest.json #32627

Closed djbrown closed 3 months ago

djbrown commented 7 months ago

MDN URL

Toolbar button

What specific section or headline is this issue about?

Specifying the browser action

What information was incorrect, unhelpful, or incomplete?

Missing information about the browser_action key itself, only that all properties are optional. If I miss this key in manifest.json then browser.browserAction is undefined in background.js: browser_action

What did you expect to see?

It should be stated, that the browserAction API is only available of the browser_api key/object is declared in the manifest.json.

Do you have any supporting links, references, or citations?

Do you have anything more you want to share?

might also be a problem with other APIs

MDN metadata

Page report details * Folder: `en-us/mozilla/add-ons/webextensions/user_interface/toolbar_button` * MDN URL: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/user_interface/Toolbar_button * GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/mozilla/add-ons/webextensions/user_interface/toolbar_button/index.md * Last commit: https://github.com/mdn/content/commit/8e7726da0782dcf7d1ca273177df60e3ff0893df * Document last modified: 2023-11-17T15:34:57.000Z
Rob--W commented 6 months ago

AFAIK Firefox didn't throw that error a year ago

The browser_action key has always been a requirement for the browserAction API.

It would be a good idea to double-check that the manifest key requirement is well-documented in the articles of all extension APIs. I went through the list of manifest keys at https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json#list_of_manifest.json_keys and from my recollection, these are the keys with an API:

rebloor commented 6 months ago

I have checked that list and aside from the toolbar and address bar button the requirement, or otherwise, for the manifest key to be specified before the API can be used are clearly documented. It appears that the requirements for these buttons were correctly and fully specified in the UI descriptions. I have now submitted a PR to clarify this in the APIand manifest key descriptions.

djbrown commented 6 months ago

Ah yes I see User Interface > Toolbar Button clearly states it. +1 for #32703 though