Closed Bug 1789980 Opened 2 years ago Closed 2 years ago

Expose Component.* symbols as globals to all DevTools modules

Categories

(DevTools :: General, task)

task

Tracking

(firefox107 fixed)

RESOLVED FIXED
107 Branch
Tracking Status
firefox107 --- fixed

People

(Reporter: ochameau, Assigned: ochameau)

References

(Blocks 1 open bug)

Details

Attachments

(4 files, 1 obsolete file)

In order to help the migration of the DevTools codebase to ES Modules (bug 1525652), we should be exposing Components, Cc, Ci, Cu and Cr to all modules.
This symbol is being made available to all privileged ES Modules.

For some, any of these symbols should be fetch from the require("chrome") module.

That, instead of involving the "debuggerSandbox", which is only meant
for exposing the "Debugger" symbol.

This will actually make commonjs module behave like JSM/ESM.
Where you have access to Components, Cc, Ci, Cu and Cr as globals.

This patch is based on the usage of Sandbox's wantComponents,
which will expose all these globals for us.
Then, I'm handling the special cases of Services and ChromeWorker,
which have nothing to do with Components.* APIs.

This will help transition to ES Modules as we won't be able to expose a magic "chrome" ESM.
Also, most of these symbols are exposed as global already.
All but:

  • components which is Components,
  • CC which is Components.Constructor,
  • Cm which is Components.manager.

$ sed -ie "/require(.chrome.)/d" $(git grep -l 'require("chrome")' devtools/)

  • manual edits for all three exceptions
Assignee: nobody → poirot.alex
Status: NEW → ASSIGNED

This symbol is specific to documents and isn't available in JSM/ESM.
So it will be best to keep it manually crafter from the modules.
It appears that only async-storage depends on the overloaded indexedDB
object created by devtools/shared/indexed-db.

This symbol is specific to documents and isn't available in JSM/ESM.
So it will be best to keep it manually crafter from the modules.
It appears that only async-storage depends on the overloaded indexedDB
object created by devtools/shared/indexed-db.

Attachment #9295215 - Attachment is obsolete: true
Pushed by apoirot@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/81d9c294af32 [devtools] Import "wantGlobalProperties" symbols from the module Sandbox. r=jdescottes https://hg.mozilla.org/integration/autoland/rev/05daf99babf4 [devtools] Stop exposing require("chrome"), instead expose Components.* as globals. r=jdescottes https://hg.mozilla.org/integration/autoland/rev/ad401d087fa0 [devtools] Migrate all callsites using require("chrome") to use Components.* global symbols. r=jdescottes,perftest-reviewers,AlexandruIonescu https://hg.mozilla.org/integration/autoland/rev/24bfc3b32e39 [devtools] Stop exposing `indexedDB` to all DevTools modules. r=jdescottes
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: