Closed Bug 1881564 Opened 2 years ago Closed 2 years ago

Support ChromeUtils.importESModule(..., {global: "current"}) in service worker

Categories

(Core :: XPConnect, task, P3)

task

Tracking

()

RESOLVED FIXED
126 Branch
Tracking Status
firefox126 --- fixed

People

(Reporter: arai, Assigned: arai)

References

Details

Attachments

(1 file)

Currently ServiceWorker doesn't have module loader, which results in ChromeUtils.importESModule(..., {global: "current"}) not available there for DevTools debugger code (bug 1789981)

https://searchfox.org/mozilla-central/rev/a8cc31504a2379bcf8ba395d2da7bb632b5521d6/dom/workers/ScriptLoader.cpp#519-522

// Set up the module loader, if it has not been initialzied yet.
if (!aWorkerPrivate->IsServiceWorker()) {
  self->InitModuleLoader();
}

The reason for not initializing is bug 1694377 and https://github.com/whatwg/html/pull/6395 where dynamic import should be prevented for ServiceWorker.
Then, there's also bug 1360870 which is to support modules in service worker.

So, initializing module loader itself is fine, as long as dynamic import is kept unavailable.
We could add some hook or flag to prevent dynamic import, and then just initialize module loader (maybe lazily), so that ChromeUtils.importESModule(..., {global: "current"}) can access it.

Dynamic import is still disabled for service worker by WorkerModuleLoader::CreateDynamicImport.

Pushed by arai_a@mac.com: https://hg.mozilla.org/integration/autoland/rev/7f07a1c73ff7 Initialize module loader also for ServiceWorker to allow ChromeUtils.importESModule in DevTools ServiceWorker debugger global. r=yulia

Backed out for causing wpt failures in serviceworker.any.serviceworker.html

  • Backout link
  • Push with failures
  • Failure Log
  • Failure line: PROCESS-CRASH | application crashed [@ RefPtr<mozilla::dom::StrongWorkerRef>::get] | /html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/serviceworker.any.serviceworker.html
Flags: needinfo?(arai.unmht)
Flags: needinfo?(arai.unmht)
Pushed by arai_a@mac.com: https://hg.mozilla.org/integration/autoland/rev/012dcfeb8452 Initialize module loader also for ServiceWorker to allow ChromeUtils.importESModule in DevTools ServiceWorker debugger global. r=yulia
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 126 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: