diff --git a/dom/webidl/Worker.webidl b/dom/webidl/Worker.webidl index 9a3dacecd533..155a21cb3a4d 100644 --- a/dom/webidl/Worker.webidl +++ b/dom/webidl/Worker.webidl @@ -44,5 +44,5 @@ enum WorkerType { "classic", "module" }; Exposed=(Window,DedicatedWorker,SharedWorker)] interface ChromeWorker : Worker { [Throws] - constructor(USVString scriptURL); + constructor(USVString scriptURL, optional WorkerOptions options = {}); }; diff --git a/dom/workers/ChromeWorker.cpp b/dom/workers/ChromeWorker.cpp index 50035bd0293d..7fda84f7f59a 100644 --- a/dom/workers/ChromeWorker.cpp +++ b/dom/workers/ChromeWorker.cpp @@ -18,7 +18,7 @@ namespace mozilla::dom { /* static */ already_AddRefed ChromeWorker::Constructor( const GlobalObject& aGlobal, const nsAString& aScriptURL, - ErrorResult& aRv) { + const WorkerOptions& aOptions, ErrorResult& aRv) { // Dump the JS stack if somebody's creating a ChromeWorker after shutdown has // begun. See bug 1813353. if (xpc::IsInAutomation() && @@ -32,7 +32,7 @@ already_AddRefed ChromeWorker::Constructor( RefPtr workerPrivate = WorkerPrivate::Constructor( cx, aScriptURL, true /* aIsChromeWorker */, WorkerKindDedicated, - RequestCredentials::Omit, WorkerType::Classic, u""_ns, VoidCString(), + RequestCredentials::Omit, aOptions.mType, aOptions.mName, VoidCString(), nullptr /*aLoadInfo */, aRv); if (NS_WARN_IF(aRv.Failed())) { return nullptr; diff --git a/dom/workers/ChromeWorker.h b/dom/workers/ChromeWorker.h index bb741263886e..04265f4a31d0 100644 --- a/dom/workers/ChromeWorker.h +++ b/dom/workers/ChromeWorker.h @@ -13,9 +13,9 @@ namespace mozilla::dom { class ChromeWorker final : public Worker { public: - static already_AddRefed Constructor(const GlobalObject& aGlobal, - const nsAString& aScriptURL, - ErrorResult& aRv); + static already_AddRefed Constructor( + const GlobalObject& aGlobal, const nsAString& aScriptURL, + const WorkerOptions& aOptions, ErrorResult& aRv); static bool WorkerAvailable(JSContext* aCx, JSObject* /* unused */); diff --git a/dom/workers/test/chrome.ini b/dom/workers/test/chrome.ini index d10a0dbee8c8..1b8658063f06 100644 --- a/dom/workers/test/chrome.ini +++ b/dom/workers/test/chrome.ini @@ -39,7 +39,9 @@ support-files = WorkerTest_worker.js bug1062920_worker.js chromeWorker_subworker.js + chromeWorker_worker_submod.sys.mjs chromeWorker_worker.js + chromeWorker_worker.sys.mjs dom_worker_helper.js empty.html fileBlobSubWorker_worker.js diff --git a/dom/workers/test/chromeWorker_worker.sys.mjs b/dom/workers/test/chromeWorker_worker.sys.mjs new file mode 100644 index 000000000000..ee96d7829b2b --- /dev/null +++ b/dom/workers/test/chromeWorker_worker.sys.mjs @@ -0,0 +1,16 @@ +/** + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +// our onmessage handler lives in the module. +import _ from "./chromeWorker_worker_submod.sys.mjs"; + +if (!("ctypes" in self)) { + throw "No ctypes!"; +} + +// Go ahead and verify that the ctypes lazy getter actually works. +if (ctypes.toString() != "[object ctypes]") { + throw "Bad ctypes object: " + ctypes.toString(); +} diff --git a/dom/workers/test/chromeWorker_worker_submod.sys.mjs b/dom/workers/test/chromeWorker_worker_submod.sys.mjs new file mode 100644 index 000000000000..c2fc29175c04 --- /dev/null +++ b/dom/workers/test/chromeWorker_worker_submod.sys.mjs @@ -0,0 +1,9 @@ +onmessage = function (event) { + let worker = new ChromeWorker("chromeWorker_subworker.js"); + worker.onmessage = function (msg) { + postMessage(msg.data); + }; + worker.postMessage(event.data); +}; + +export default "go away linter"; diff --git a/dom/workers/test/test_chromeWorker.xhtml b/dom/workers/test/test_chromeWorker.xhtml index 677fda578319..65d14f8851ab 100644 --- a/dom/workers/test/test_chromeWorker.xhtml +++ b/dom/workers/test/test_chromeWorker.xhtml @@ -4,8 +4,7 @@ http://creativecommons.org/publicdomain/zero/1.0/ --> + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">