Couldn't load extension with background type 'module' in V3 manifest
Categories
(WebExtensions :: Untriaged, defect)
Tracking
(firefox124 affected, firefox125 affected, firefox126 affected)
People
(Reporter: ris58h, Unassigned)
Details
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:124.0) Gecko/20100101 Firefox/124.0
Steps to reproduce:
I have an extension with background.type.='module' in manifest V3.
Link to the manifest: https://github.com/ris58h/youtube-chapters-in-player/blob/master/extension/manifest.json
Actual results:
There was an error during the temporary add-on installation.
Error details
Extension is invalid
Reading manifest: Error processing background: Value must either: contain the required "page" property, contain the required "scripts" property, or not contain an unexpected "type" property
Expected results:
Extension should be loaded without error as it's done in Chrome.
Comment 1•2 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'WebExtensions::Untriaged' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Comment 2•2 years ago
|
||
Hello,
I reproduced the issue on the latest Nightly (126.0a1/20240331204101), Beta (125.0b6/20240329091918) and Release (124.0.1/20240321230221) under Windows 10 x64 and Ubuntu 22.04 LTS.
Attempting to load the linked manifest in about:debugging will fail with the error mentioned in Comment 0.
Comment 3•2 years ago
|
||
The issue with your extension is not type: "module", but the use of service_worker which Firefox does not support yet.
After looking at your extension, there does not seem to be any service-worker specific API, and you should be able to get the extension working in Firefox and Chrome by adding "scripts": ["background/background.js"] in the background key of your manifest.json file. This is documented at https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/background#browser_support
Maybe there is no service-worker specific API but it was the way to make modules work in Chrome.
Comment 5•2 years ago
|
||
type: "module" is supported in Firefox.
Does my suggestion (scripts + service_worker + type':"module") solve your issue?
I've changed it to
"background": {
"service_worker": "background/background.js",
"scripts": ["background/background.js"],
"type": "module"
},
as you suggested and it just doesn't work. No errors, no logs, nothing.
Comment 7•2 years ago
|
||
I created the following test case, which should open a new tab when the extension loads. I can confirm that it works in Firefox 121+ and Chrome 121+.
If there is anything "not working" with your extension, it is unrelated to the "module" or "background" issue that you have reported.
Note: currently, Manifest V3 extensions are not automatically granted host permissions upon install. We're going to change that soon, in bug 1889402.
manifest.json
{
"name": "module background test",
"version": "1",
"manifest_version": 3,
"background": {
"service_worker": "background.js",
"scripts": ["background.js"],
"type": "module"
}
}
background.js
import "./hello.js"
hello.js
chrome.tabs.create({ url: "https://example.com/?hello" });
Description
•