Closed Bug 1796582 Opened 3 years ago Closed 3 years ago

Reuse global from DevTools Loader to load other DevTools modules

Categories

(DevTools :: General, task, P3)

task

Tracking

(firefox108 fixed)

RESOLVED FIXED
108 Branch
Tracking Status
firefox108 --- fixed

People

(Reporter: jdescottes, Assigned: jdescottes)

References

(Blocks 1 open bug)

Details

Attachments

(3 files, 1 obsolete file)

If we load the DevToolsLoader with loadInDevToolsLoader: true and manage to reuse the same global to load other devtools modules, we should be able to automatically load other ESMs in the DevTools global instead of the shared global.

See this comment: https://phabricator.services.mozilla.com/D159219#5226753

But note that it may not be that complicated to set the right global in our Loader... especially once I land my patch to convert Loader.jsm/base-loader.js into ESMs.
https://searchfox.org/mozilla-central/rev/76ccfc801e6b736c844cde3fddeab7a748fc8515/devtools/shared/loader/base-loader.js#545-550
Here we might "just" replace sharedGlobalSandbox with globalThis or something refering to the global of base-loader.sys.mjs,
and then, ensure that Loader.sys.mjs is loaded with loadInDevtoolsLoader:true.
Many issues may arise, but I think we can do this without any additional C++ API.

The downside of this approach is that we will start loading all ESMs in the DevTools compartment, and this might not always be desirable. So we will have to flag individual imports with loadInDevToolsLoader: false. One case is about the JSWindow/ProcessActors. We never want to load twice an ESM which will register actors, because the actual store for those actors in C++ and doesn't seem to follow compartments.

See Also: → 1796540

Just a wip, this prevents the MBT from actually retrieving content from other processes.
But the isolation works

Attachment #9299535 - Attachment is obsolete: true
Blocks: 1797908
Pushed by jdescottes@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/70af32ef6986 [devtools] Use distinctSystemPrincipalLoader instead of invisibleToDebugger when possible r=ochameau https://hg.mozilla.org/integration/autoland/rev/fa0ff274795f [devtools] Extract helpers for distinctSystemPrincipalLoader to a dedicated module r=ochameau https://hg.mozilla.org/integration/autoland/rev/a365a7834657 [devtools] Load DistinctSystemPrincipalLoader in the dedicated DevToolsLoader global r=ochameau

Backed out for causing failures in test_invisible_loader.js.

  • Backout link
  • Push with failures
  • Failure Log
  • Failure line: TEST-UNEXPECTED-FAIL | devtools/shared/tests/xpcshell/test_loader.js | run_test - [run_test : 19] The loader is set invisible to debugger - false == true
Flags: needinfo?(jdescottes)

Sorry, I forgot to include the xpcshell test update! Will re-land with the fix

Flags: needinfo?(jdescottes)
Pushed by jdescottes@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/af01513a649e [devtools] Use distinctSystemPrincipalLoader instead of invisibleToDebugger when possible r=ochameau https://hg.mozilla.org/integration/autoland/rev/188f86540306 [devtools] Extract helpers for distinctSystemPrincipalLoader to a dedicated module r=ochameau https://hg.mozilla.org/integration/autoland/rev/ea7a72477948 [devtools] Load DistinctSystemPrincipalLoader in the dedicated DevToolsLoader global r=ochameau
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 108 Branch
Regressions: 1798107
Regressions: 1798020
Regressions: 1810340
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: