Closed Bug 1911833 Opened 6 months ago Closed 2 months ago

Implement initial MV3 userScripts API bindings

Categories

(WebExtensions :: General, enhancement, P1)

enhancement

Tracking

(firefox134 fixed)

RESOLVED FIXED
134 Branch
Tracking Status
firefox134 --- fixed

People

(Reporter: robwu, Assigned: robwu)

References

(Blocks 1 open bug)

Details

(Whiteboard: [addons-jira])

Attachments

(4 files)

See https://bugzilla.mozilla.org/show_bug.cgi?id=1875475#c3 for details.

In-scope:

  • userScripts.register, userScripts.unregister, userScripts.getScripts()
  • MAIN world only.
  • with persistency. Depends on skv (bug 1909409), but if that is not ready yet we can land with rkv at first and before enabling userScripts by default, switch to skv.
  • Add "userScripts" permission for MV3.

  • Add "userScripts" namespace for MV3, and add schema and logic to make
    sure that this namespace is limited to MV3 only.

  • Add tests to verify that the "userScripts" namespace of MV2 and MV3
    are completely isolated.

  • The functionality in this patch is limited to verifying that the API
    bindings and permission requirement works; the rest of the
    implementation will follow in the next patches.

See Also: → 1919530
Depends on: 1920245
Attachment #9425344 - Attachment description: WIP: Bug 1911833 - Add APIs to register user scripts → Bug 1911833 - Add APIs to register user scripts
Attachment #9425342 - Attachment description: Bug 1911833 - Add MV3 userScripts namespace, separate from MV2 → WIP: Bug 1911833 - Add MV3 userScripts namespace, separate from MV2
Attachment #9425342 - Attachment description: WIP: Bug 1911833 - Add MV3 userScripts namespace, separate from MV2 → Bug 1911833 - Add MV3 userScripts namespace, separate from MV2

Although the bindings generator skips MV2-only APIs at some point
(https://searchfox.org/mozilla-central/rev/1bc0601cc5b3d4c3919d220acbe248221ebce035/toolkit/components/extensions/webidl-api/GenerateWebIDLBindings.py#337-338),
that only happens after loading all schemas. Because user_scripts.json
contains multiple userScripts.register definitions (one for MV2 and one
for MV3), GenerateWebIDLBindings.py raised the following error before
this patch:

TypeError: Unxpected multiple schema data for API property "userScripts.register" in schema group toolkit

This patch fixes the issue by ignoring the schemas that define the
userScripts API, and now the following test passes again:

./mach test toolkit/components/extensions/webidl-api/test/test_all_schemas_smoketest.py
Pushed by rob@robwu.nl: https://hg.mozilla.org/integration/autoland/rev/2056c51701e1 Skip userScripts in GenerateWebIDLBindings.py r=rpl https://hg.mozilla.org/integration/autoland/rev/ea3cd3ed29f4 Add MV3 userScripts namespace, separate from MV2 r=zombie https://hg.mozilla.org/integration/autoland/rev/ee0e151f3179 Put userScripts permission behind pref r=zombie https://hg.mozilla.org/integration/autoland/rev/5cc04d582843 Add APIs to register user scripts r=zombie
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: