diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /toolkit/components/promiseworker/tests/xpcshell/data | |
parent | Initial commit. (diff) | |
download | firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/promiseworker/tests/xpcshell/data')
-rw-r--r-- | toolkit/components/promiseworker/tests/xpcshell/data/chrome.manifest | 1 | ||||
-rw-r--r-- | toolkit/components/promiseworker/tests/xpcshell/data/worker.js | 40 |
2 files changed, 41 insertions, 0 deletions
diff --git a/toolkit/components/promiseworker/tests/xpcshell/data/chrome.manifest b/toolkit/components/promiseworker/tests/xpcshell/data/chrome.manifest new file mode 100644 index 0000000000..9e5dd29b22 --- /dev/null +++ b/toolkit/components/promiseworker/tests/xpcshell/data/chrome.manifest @@ -0,0 +1 @@ +content promiseworker ./ diff --git a/toolkit/components/promiseworker/tests/xpcshell/data/worker.js b/toolkit/components/promiseworker/tests/xpcshell/data/worker.js new file mode 100644 index 0000000000..ffb3473713 --- /dev/null +++ b/toolkit/components/promiseworker/tests/xpcshell/data/worker.js @@ -0,0 +1,40 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +/* eslint-env mozilla/chrome-worker */ + +"use strict"; + +// Trivial worker definition + +/* import-globals-from /toolkit/components/workerloader/require.js */ +importScripts("resource://gre/modules/workers/require.js"); +var PromiseWorker = require("resource://gre/modules/workers/PromiseWorker.js"); + +var worker = new PromiseWorker.AbstractWorker(); +worker.dispatch = function (method, args = []) { + return Agent[method](...args); +}; +worker.postMessage = function (...args) { + self.postMessage(...args); +}; +worker.close = function () { + self.close(); +}; +worker.log = function (...args) { + dump("Worker: " + args.join(" ") + "\n"); +}; +self.addEventListener("message", msg => worker.handleMessage(msg)); +self.addEventListener("unhandledrejection", function (error) { + throw error.reason; +}); + +var Agent = { + bounce(...args) { + return args; + }, + + throwError(msg, ...args) { + throw new Error(msg); + }, +}; |