Files
palemoon27/toolkit/devtools/shared/tests/browser/browser_devtools-worker-01.js
T
roytam1 7529dc68e8 import changes from `dev' branch of rmottola/Arctic-Fox:
- import VMX Blur from TenFourFox and adapt moz.build with HAVE_ALTIVEC (f23006226)
- Bug 1176083. Remove the now-dead code for the XPCOM version of setTimeout/setInterval. r=smaug (af84a61a6)
- Bug 1148593 - Pass JSContext to CallbackObject constructor. r=bz (548cda0cc)
- Bug 1164564 - Clean up the worker loader;r=jlong (c22a9241c)
- Bug 1164564 - Refactor Promise-backend.js so it can be required as a CommonJS module;r=jlong (6ced4a7f2)
- Bug 1084525 - Part 4: Add listPromises method to PromisesActor r=fitzgen (132c6b062)
- Bug 1084525 - Part 5: Add onNewPromise event handler to PromisesActor r=fitzgen (07098d58c)
- Bug 1084525 - Part 6: Add onPromiseSettled event handler to PromisesActor r=fitzgen (11d0c7430)
- Bug 1164483 - move worker helpers from frontend of devtools to backend r=jsantell (d5a0d16af)
- Bug 1164632 - use new worker helpers in debugger for pretty-printing r=jsantell (de356582a)
- do not run a test program to see if -maltivec is supported, since GCC always accepts it, even if an incompatible processor is selected. Offer explicit enable-altivec option and also set CXXFLAGS (c78bc8e43)
- extend removing of optimizations to all newer GCC versions, since it is a code issue, not compiler one (29639f4d5)
2021-04-19 11:02:56 +08:00

45 lines
1.3 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that the devtools/shared/worker communicates properly
// as both CommonJS module and as a JSM.
const WORKER_URL = "resource:///modules/devtools/GraphsWorker.js";
const count = 100000;
const WORKER_DATA = (function () {
let timestamps = [];
for (let i = 0; i < count; i++) {
timestamps.push(i);
}
return timestamps;
})();
const INTERVAL = 100;
const DURATION = 1000;
add_task(function*() {
// Test both CJS and JSM versions
yield testWorker("JSM", () => Cu.import("resource:///modules/devtools/shared/worker.js", {}));
yield testWorker("CommonJS", () => devtools.require("devtools/shared/worker"));
});
function *testWorker (context, workerFactory) {
let { DevToolsWorker, workerify } = workerFactory();
let worker = new DevToolsWorker(WORKER_URL);
let results = yield worker.performTask("plotTimestampsGraph", {
timestamps: WORKER_DATA,
interval: INTERVAL,
duration: DURATION
});
ok(results.plottedData.length,
`worker should have returned an object with array properties in ${context}`);
let fn = workerify(function (x) { return x * x });
is((yield fn(5)), 25, `workerify works in ${context}`);
fn.destroy();
worker.destroy();
}