Additional "/" in web_accessible_resources in Firefox MV3

Greetings,

I have an extension developed for Firefox MV3. In the manifest file, web_accessible_resources are specified as file.html or script.js, but when I import it in Firefox there’s an additional slash character /file.html, /script.js. I can check using browser.runtime.getManifest().

Is there a way to get around this? Thanks.

What do you mean when you say “when i import it in Firefox”? What problem(s) is the slash causing?

I mean when I install it. I’m using a package that accesses some files listed in web_accessible_resources, however with the slash character present, it can’t seem to find those files. This doesn’t happen in mv2, only in mv3.

I just tested declaring resources with and without a leading / in web_accessible_resources and getting resource URLs with and without a leading / using runtime.getURL() and all worked expected.

At the moment my best guess is that you have a build step that’s doing something unexpected. Can you share a link to a repository or some example code?

Sure, here’s an example: GitHub - yacine-bens/mellowtel-wxt

After building using npm run build:firefox:mv3, the resources are declared without / in the manifest file.

runtime.getUrl() does indeed return the correct url in both cases, but the package is trying to access the files directly from the manifest using runtime.getManifest(), in this case there will be a leading / in each string in resources array.

IMO this looks like a bug in one of your dependencies.

Currently the mellowtel library is checking the web_accessible_resources array for exact string matches (1, 2). Instead, they should be checking against a normalized version of the web_accessible_resources data.

Matching directly against the value returned by runtime.getManifest() is unreliable because it’s an interpretation of the manifest file, not a 1:1 match of the JSON file bundled with the extension. If they want to get the exact value of the resources declared in web_accessible_resources, they should directly use fetch("manifest.json") to retrieve the file. And even then that JSON file should be normalized to account for different ways of authoring those strings.

Yeah, that makes sense. I’ll notify the authors of the library.

Thank you for your assistance.