moz-extension:// URLs cannot be imported with ChromeUtils.import() when loaded from an XPI
Categories
(WebExtensions :: Untriaged, defect)
Tracking
(Not tracked)
People
(Reporter: darktrojan, Unassigned)
References
Details
Attachments
(1 file)
1.84 KB,
application/x-xpinstall
|
Details |
I can call fetch("moz-extension://xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/manifest.json")
and it will succeed if the extension is unpacked, but fail if the extension is packed. (This isn't actually what I'm trying to do but it's a good enough test case.)
This seems to be the case whether extensions.webextensions.remote
is set to true or false.
Comment 1•4 years ago
|
||
- How does manifest.json look like? In particular, what is inside the web_accessible_resources and permissions keys?
- Where are you calling fetch?
Reporter | ||
Comment 2•4 years ago
|
||
At the moment, I'm just doing all this from the devtools toolbox. (In Thunderbird, but the same is true in Firefox.)
I've just done some further investigation and it seems that the presence of an experiment_apis
key causes the problem. Remove the key and everything seems to work fine, except then I can't have an experiment, which is what I'm trying to work on in the first place…
Comment 3•4 years ago
|
||
Please attach a full test case and exact steps to reproduce the issue.
Comment 4•4 years ago
|
||
This WebExtension Experiment shows the described behaviour. Reproducable in FireFox Nightly 76.0a1 (2020-03-11). To run Experiments, you have to set
xpinstall.signatures.required = false
extensions.experiments.enabled = true
If this WebExtension gets installed unpacked via add-on debugging, everything works as expected and you will see
Loading myModule.jsm
WebExtensions: Hello world! <1>
in the main console. If it gets installed as a packed xpi directly, you will see
Error: An unexpected error occurred background.js:3:23
in the console of the add-on itself. If the import of myModule.jsm is removed (and all references to myModule), it runs thru without error.
Comment 5•4 years ago
|
||
I don't know enough about the guts of the module loader and the moz-extension handler to know why this doesn't work, but if you switch the getURL()
call to something like context.extension.rootURI.resolve("./modules/myModule.jsm")
that should give you a file:
or jar:
url (depending on whether the extensions is packed or not) that works with the module loader.
Updated•4 years ago
|
Comment 6•4 years ago
|
||
Loading custom modules from extension experiments isn't a thing we want to support. Andrew gave you some workarounds, or if that doesn't work, you might need to setup an URI substitution and map it to a resource://
URI before loading a JSM.
Comment 7•4 years ago
|
||
Thanks for your help!
Using context.extension.rootURI.resolve()
fixes this for us. Just to have a second tool available: How do I setup a URI substitution to map it to a resource:/
URI ?
Comment 8•4 years ago
|
||
Description
•