summaryrefslogtreecommitdiffstats
path: root/dom/encoding/test/worker_helper.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /dom/encoding/test/worker_helper.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--dom/encoding/test/worker_helper.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/dom/encoding/test/worker_helper.js b/dom/encoding/test/worker_helper.js
new file mode 100644
index 0000000000..ca34387784
--- /dev/null
+++ b/dom/encoding/test/worker_helper.js
@@ -0,0 +1,56 @@
+/*
+ * worker_helper.js
+ * bug 764234 tests
+ */
+
+// The undefined items here are used in the tests within the worker that this
+// runs.
+/* eslint-disable no-undef */
+
+function runTestInWorker(files) {
+ function workerRun() {
+ var tests = [];
+ var asserts;
+ test = function (func, msg) {
+ asserts = [];
+ tests.push({ asserts, msg });
+ };
+ assert_equals = function (result, expected, msg) {
+ asserts.push(["assert_equals", result, expected, msg]);
+ };
+ assert_true = function (condition, msg) {
+ asserts.push(["assert_true", condition, msg]);
+ };
+ assert_unreached = function (condition, msg) {
+ asserts.push(["assert_unreached", condition, msg]);
+ };
+ onmessage = function (event) {
+ importScripts.apply(self, event.data);
+ runTest();
+ postMessage(tests);
+ };
+ }
+
+ var url = URL.createObjectURL(
+ new Blob([runTest.toString(), "\n\n", "(", workerRun.toString(), ")();"])
+ );
+ var worker = new Worker(url);
+ var base = location.toString().replace(/\/[^\/]*$/, "/");
+ worker.postMessage(
+ files.map(function (f) {
+ return base + f;
+ })
+ );
+ worker.onmessage = function (event) {
+ URL.revokeObjectURL(url);
+ event.data.forEach(function (t) {
+ test(function () {
+ t.asserts.forEach(function (a) {
+ let func = a.shift();
+ self[func].apply(self, a);
+ });
+ }, "worker " + t.msg);
+ });
+ done();
+ };
+}