Skip to content

Support Web Extension Manifest V3 #203

Description

@kaya51

Is your feature request related to a problem? Please describe.

If I'm not mistaken magick-wasm can't be used in a MV3 (Manifest Version 3) extension, at least on Chrome.

If you try to use it, it's gonna give an error like this.

Uncaught (in promise) EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' 'wasm-unsafe-eval' 'inline-speculation-rules' http://localhost:* http://127.0.0.1:*".

I believe it gives that error because of this and this. Function is an unsafe expression according to here.

What I understand is it needs 'unsafe-eval' in content_security_policy.extension_pages, but it can't have that in MV3.

https://developer.chrome.com/docs/extensions/reference/manifest/content-security-policy

The extension_pages policy cannot be relaxed beyond this minimum value. In other words, you cannot add other script sources to directives, such as adding 'unsafe-eval' to script-src. If you add a disallowed source to your extension's policy, Chrome will throw an error like this at install time:
'content_security_policy.extension_pages': Insecure CSP value "'unsafe-eval'" in directive 'script-src'.;

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/content_security_policy#examples

Manifest V3 does not allow 'unsafe-eval' in script-src.

I've prepared some examples for both MV2 and MV3. They are designed to work as expected in the current up to date Chrome. I didn't check the API's for minimum version of Chrome. MV2 ones might require ExtensionManifestV2Availability or equilevent. They go step by step.

  1. An empty extension
  2. Tries to use magick-wasm
  3. Adds wasm-unsafe-eval
  4. Adds unsafe-eval

In MV2, it works fine at step 4. I think this proves I do nothing wrong in MV3. That's just the way it is.

Describe the solution you'd like

Implementation of the relevant functions in an alternative way.

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions