Closed Bug 1608282 Opened 4 years ago Closed 2 years ago

Export symbols imported by XPCOMUtils.defineLazyGlobalGetters and Cu.importGlobalProperties by default in the shared global

Categories

(Firefox :: General, task, P5)

task

Tracking

()

RESOLVED FIXED
103 Branch
Tracking Status
firefox103 --- fixed

People

(Reporter: bgrins, Assigned: arai)

References

(Blocks 1 open bug)

Details

Attachments

(4 files)

It sounds like Cu.importGlobalProperties might continue to work even with Bug 1432901, but we might also need to change how it works. The lazy getters won't (no global this) but depending on how/if Cu.importGlobalProperties works it might not be necessary.

Won't globalThis work, either?

globalThis works in both JSMs and ES Modules. It will refer to the BackstagePass shared by the chrome modules. Doing something like (new Function("return this"))() should give the same value, but we would like to disable dynamic code in modules already.

Whether we allow globalThis is mainly a policy decision about interactions. Disallowing in privileged modules in favour of explicit import/export would be my preference, but I'm not the expert on frontend.

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: General → XPConnect
Product: Firefox → Core
Component: XPConnect → General
Product: Core → Firefox

Cu.importGlobalProperties defines properties on the shared global (= globalThis)
So it keeps working in the same way in ESM, without modification
(But of course it means those properties leak to other modules...)

Looks like Cu.importGlobalProperties isn't necessary at least in some case (see bug 1771378).
Maybe better checking each symbol imported with this, and either:

  • remove the call if the symbol is avalable without the call
  • support the symbol in the shared global if it's common
See Also: → 1771378

Most of XPCOMUtils.defineLazyGlobalGetters will be removed by bug 1772360.
Remaining are fetch, crypto, and indexedDB

Regressions: 1771378
See Also: → 1772360

(In reply to Tooru Fujisawa [:arai] from comment #6)

Most of XPCOMUtils.defineLazyGlobalGetters will be removed by bug 1772360.
Remaining are fetch, crypto, and indexedDB

That's a remarkably small number. Perhaps we can consider explicitly exporting these few getters by default on the shared JSM/ESM global so that we don't need to use Cu.importGlobalProperties in these shared scopes anymore.

Summary: Figure out what to do with XPCOMUtils.defineLazyGlobalGetters and Cu.importGlobalProperties in ESMs → Export symbols imported by XPCOMUtils.defineLazyGlobalGetters and Cu.importGlobalProperties by default in the shared global
Assignee: nobody → arai.unmht
Status: NEW → ASSIGNED
See Also: → 1774152
Pushed by arai_a@mac.com:
https://hg.mozilla.org/integration/autoland/rev/e26e480c7dd6
Part 1: Support fetch, crypto, and indexedDB in the system global by default. r=mccr8
https://hg.mozilla.org/integration/autoland/rev/ced8d82cc2d2
Part 2: Update jsm environment definition to include fetch, crypto, indexedDB. r=mccr8
https://hg.mozilla.org/integration/autoland/rev/37c970364269
Part 3: Remove Cu.importGlobalProperties from JSM. r=extension-reviewers,kmag
https://hg.mozilla.org/integration/autoland/rev/32aebc8be201
Part 4: Remove Cu.defineLazyGlobalGetters from JSM. r=webdriver-reviewers,extension-reviewers,jdescottes,kmag
Flags: needinfo?(arai.unmht)
Pushed by arai_a@mac.com:
https://hg.mozilla.org/integration/autoland/rev/b9c7f7ade029
Part 1: Support fetch, crypto, and indexedDB in the system global by default. r=mccr8
https://hg.mozilla.org/integration/autoland/rev/78fa9a7f9087
Part 2: Update jsm environment definition to include fetch, crypto, indexedDB. r=mccr8
https://hg.mozilla.org/integration/autoland/rev/b24017ef3ee7
Part 3: Remove Cu.importGlobalProperties from JSM. r=extension-reviewers,kmag
https://hg.mozilla.org/integration/autoland/rev/7f6fabbd9dc5
Part 4: Remove Cu.defineLazyGlobalGetters from JSM. r=webdriver-reviewers,extension-reviewers,jdescottes,kmag
Regressions: 1775013
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: