From 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:47:29 +0200 Subject: Adding upstream version 115.8.0esr. Signed-off-by: Daniel Baumann --- .../tests/xpcshell/data/chrome.manifest | 1 + .../promiseworker/tests/xpcshell/data/worker.js | 40 ++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 toolkit/components/promiseworker/tests/xpcshell/data/chrome.manifest create mode 100644 toolkit/components/promiseworker/tests/xpcshell/data/worker.js (limited to 'toolkit/components/promiseworker/tests/xpcshell/data') 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); + }, +}; -- cgit v1.2.3