1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/ */
6 // Trivial worker definition
8 /* import-globals-from /toolkit/components/workerloader/require.js */
9 importScripts("resource://gre/modules/workers/require.js");
10 var PromiseWorker = require("resource://gre/modules/workers/PromiseWorker.js");
12 var worker = new PromiseWorker.AbstractWorker();
14 worker.dispatch = async function (method, args = []) {
15 return await Agent[method](...args);
17 worker.postMessage = function (...args) {
18 self.postMessage(...args);
20 worker.close = function () {
23 worker.log = function (...args) {
24 dump("Worker: " + args.join(" ") + "\n");
26 self.addEventListener("message", msg => worker.handleMessage(msg));
27 self.addEventListener("unhandledrejection", function (error) {
36 async bounceWithExtraCalls(...args) {
37 let result = await worker.callMainThread("echo", [
38 "Posting something unrelated",