Closed Bug 1765156 Opened 2 years ago Closed 2 years ago

Provide the equivalent of ChromeUtils.import via SpecialPowers

Categories

(Testing :: Mochitest, task)

task

Tracking

(firefox102 fixed)

RESOLVED FIXED
102 Branch
Tracking Status
firefox102 --- fixed

People

(Reporter: arai, Assigned: arai)

References

Details

Attachments

(12 files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

Currently SpecialPowers provides JSM import feature by SpecialPowers.Cu.import, but it has difference between ChromeUtils.import.

ChromeUtils.import returns exports object, but SpecialPowers.Cu.import returns global object.
The former supports lexical variables, but the latter doesn't have them, so
the latter requires variables defined on the JSM's global this property.

To my understanding, this is part of the reason why we have this.Foo = Foo in JSM code.

We can temporarily provide SpecialPowers.ChromeUtils_import or something that performs ChromeUtils.import, and replace SpecialPowers.Cu.import with it,
and then remove this.Foo = Foo in JSM code.

Blocks: 1765167

This should probably be in Testing::Mochitest or something along those lines, rather than Firefox::General.

Component: General → Mochitest
Product: Firefox → Testing

Given bug 1758481, it would make sense to drop the 2nd parameter from SpecialPowers.ChromeUtils_import implementation,
to avoid adding more consumer of the 2nd parameter.

:mccr8, can I have your opinion about the API design here?
The current WIP patches above adds SpecialPowers.ChromeUtils_import function with single parameter.

The other possibility are:

  • Expose the entire ChromeUtils as SpecialPowers.ChromeUtils, and let the consumer call SpecialPowers.ChromeUtils.import
  • Expose ChromeUtils.import as SpecialPowers.import or something with shorter name
Flags: needinfo?(continuation)

Kris is probably a better person to ask about this.

Flags: needinfo?(continuation) → needinfo?(kmaglione+bmo)
Blocks: 1548308

I would lean towards just exposing SpecialPowers.ChromeUtils, but I would also be OK with SpecialPowers.import

Flags: needinfo?(kmaglione+bmo)
Attachment #9272956 - Attachment description: WIP: Bug 1765156 - Part 1: Add SpecialPowers.ChromeUtils_import. → Bug 1765156 - Part 1: Add SpecialPowers.ChromeUtils. r?kmag
Attachment #9272957 - Attachment description: WIP: Bug 1765156 - Part 2: Use SpecialPowers.ChromeUtils_import in browser/. → Bug 1765156 - Part 2: Use SpecialPowers.ChromeUtils.import in browser/. r=kmag
Attachment #9272958 - Attachment description: WIP: Bug 1765156 - Part 3: Use SpecialPowers.ChromeUtils_import in dom/. → Bug 1765156 - Part 3: Use SpecialPowers.ChromeUtils.import in dom/. r=kmag
Attachment #9272959 - Attachment description: WIP: Bug 1765156 - Part 4: Use SpecialPowers.ChromeUtils_import in editor/. → Bug 1765156 - Part 4: Use SpecialPowers.ChromeUtils.import in editor/. r=kmag
Attachment #9272960 - Attachment description: WIP: Bug 1765156 - Part 5: Use SpecialPowers.ChromeUtils_import in extensions/. → Bug 1765156 - Part 5: Use SpecialPowers.ChromeUtils.import in extensions/. r=kmag
Attachment #9272961 - Attachment description: WIP: Bug 1765156 - Part 6: Use SpecialPowers.ChromeUtils_import in js/xpconnect/. → Bug 1765156 - Part 6: Use SpecialPowers.ChromeUtils.import in js/xpconnect/. r=kmag
Attachment #9272962 - Attachment description: WIP: Bug 1765156 - Part 7: Use SpecialPowers.ChromeUtils_import in layout/. → Bug 1765156 - Part 7: Use SpecialPowers.ChromeUtils.import in layout/. r=kmag
Attachment #9272963 - Attachment description: WIP: Bug 1765156 - Part 8: Use SpecialPowers.ChromeUtils_import in mobile/. → Bug 1765156 - Part 8: Use SpecialPowers.ChromeUtils.import in mobile/. r=kmag
Attachment #9272964 - Attachment description: WIP: Bug 1765156 - Part 9: Use SpecialPowers.ChromeUtils_import in testing/. → Bug 1765156 - Part 9: Use SpecialPowers.ChromeUtils.import in testing/. r=kmag
Attachment #9272965 - Attachment description: WIP: Bug 1765156 - Part 10: Use SpecialPowers.ChromeUtils_import in toolkit/components/extensions/. → Bug 1765156 - Part 10: Use SpecialPowers.ChromeUtils.import in toolkit/components/extensions/. r=kmag
Attachment #9272966 - Attachment description: WIP: Bug 1765156 - Part 11: Use SpecialPowers.ChromeUtils_import in toolkit/components/passwordmgr/. → Bug 1765156 - Part 11: Use SpecialPowers.ChromeUtils.import in toolkit/components/passwordmgr/. r=kmag
Attachment #9272967 - Attachment description: WIP: Bug 1765156 - Part 12: Use SpecialPowers.ChromeUtils_import in toolkit/. → Bug 1765156 - Part 12: Use SpecialPowers.ChromeUtils.import in toolkit/. r=kmag

Note for testing
Some pre-existing test-verify failures are expected with this patch stack.

Attachment #9272956 - Attachment description: Bug 1765156 - Part 1: Add SpecialPowers.ChromeUtils. r?kmag → Bug 1765156 - Part 1: Add SpecialPowers.ChromeUtils. r?kmag!
Attachment #9272957 - Attachment description: Bug 1765156 - Part 2: Use SpecialPowers.ChromeUtils.import in browser/. r=kmag → Bug 1765156 - Part 2: Use SpecialPowers.ChromeUtils.import in browser/. r=kmag!
Attachment #9272958 - Attachment description: Bug 1765156 - Part 3: Use SpecialPowers.ChromeUtils.import in dom/. r=kmag → Bug 1765156 - Part 3: Use SpecialPowers.ChromeUtils.import in dom/. r=kmag!
Attachment #9272959 - Attachment description: Bug 1765156 - Part 4: Use SpecialPowers.ChromeUtils.import in editor/. r=kmag → Bug 1765156 - Part 4: Use SpecialPowers.ChromeUtils.import in editor/. r=kmag!
Attachment #9272960 - Attachment description: Bug 1765156 - Part 5: Use SpecialPowers.ChromeUtils.import in extensions/. r=kmag → Bug 1765156 - Part 5: Use SpecialPowers.ChromeUtils.import in extensions/. r=kmag!
Attachment #9272961 - Attachment description: Bug 1765156 - Part 6: Use SpecialPowers.ChromeUtils.import in js/xpconnect/. r=kmag → Bug 1765156 - Part 6: Use SpecialPowers.ChromeUtils.import in js/xpconnect/. r=kmag!
Attachment #9272962 - Attachment description: Bug 1765156 - Part 7: Use SpecialPowers.ChromeUtils.import in layout/. r=kmag → Bug 1765156 - Part 7: Use SpecialPowers.ChromeUtils.import in layout/. r=kmag!
Attachment #9272963 - Attachment description: Bug 1765156 - Part 8: Use SpecialPowers.ChromeUtils.import in mobile/. r=kmag → Bug 1765156 - Part 8: Use SpecialPowers.ChromeUtils.import in mobile/. r=kmag!
Attachment #9272964 - Attachment description: Bug 1765156 - Part 9: Use SpecialPowers.ChromeUtils.import in testing/. r=kmag → Bug 1765156 - Part 9: Use SpecialPowers.ChromeUtils.import in testing/. r=kmag!
Attachment #9272965 - Attachment description: Bug 1765156 - Part 10: Use SpecialPowers.ChromeUtils.import in toolkit/components/extensions/. r=kmag → Bug 1765156 - Part 10: Use SpecialPowers.ChromeUtils.import in toolkit/components/extensions/. r=kmag!
Attachment #9272966 - Attachment description: Bug 1765156 - Part 11: Use SpecialPowers.ChromeUtils.import in toolkit/components/passwordmgr/. r=kmag → Bug 1765156 - Part 11: Use SpecialPowers.ChromeUtils.import in toolkit/components/passwordmgr/. r=kmag!
Attachment #9272967 - Attachment description: Bug 1765156 - Part 12: Use SpecialPowers.ChromeUtils.import in toolkit/. r=kmag → Bug 1765156 - Part 12: Use SpecialPowers.ChromeUtils.import in toolkit/. r=kmag!
Pushed by arai_a@mac.com:
https://hg.mozilla.org/integration/autoland/rev/c754789316ab
Part 1: Add SpecialPowers.ChromeUtils. r=kmag
https://hg.mozilla.org/integration/autoland/rev/1c2a9d039e65
Part 2: Use SpecialPowers.ChromeUtils.import in browser/. r=kmag
https://hg.mozilla.org/integration/autoland/rev/ca2494740fc0
Part 3: Use SpecialPowers.ChromeUtils.import in dom/. r=kmag
https://hg.mozilla.org/integration/autoland/rev/534748aa61db
Part 4: Use SpecialPowers.ChromeUtils.import in editor/. r=kmag
https://hg.mozilla.org/integration/autoland/rev/dd7eb05d40c9
Part 5: Use SpecialPowers.ChromeUtils.import in extensions/. r=kmag
https://hg.mozilla.org/integration/autoland/rev/ff0e0d60d30c
Part 6: Use SpecialPowers.ChromeUtils.import in js/xpconnect/. r=kmag
https://hg.mozilla.org/integration/autoland/rev/bb3c4b716945
Part 7: Use SpecialPowers.ChromeUtils.import in layout/. r=kmag
https://hg.mozilla.org/integration/autoland/rev/a06b5b3f366d
Part 8: Use SpecialPowers.ChromeUtils.import in mobile/. r=geckoview-reviewers,agi
https://hg.mozilla.org/integration/autoland/rev/6c4e9b18e436
Part 9: Use SpecialPowers.ChromeUtils.import in testing/. r=kmag
https://hg.mozilla.org/integration/autoland/rev/4f77ac47c966
Part 10: Use SpecialPowers.ChromeUtils.import in toolkit/components/extensions/. r=kmag
https://hg.mozilla.org/integration/autoland/rev/c1cc78ae7763
Part 11: Use SpecialPowers.ChromeUtils.import in toolkit/components/passwordmgr/. r=kmag
https://hg.mozilla.org/integration/autoland/rev/29adb3089e10
Part 12: Use SpecialPowers.ChromeUtils.import in toolkit/. r=kmag
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: