summaryrefslogtreecommitdiffstats
path: root/dom/encoding/test/worker_helper.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/encoding/test/worker_helper.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/encoding/test/worker_helper.js')
-rw-r--r--dom/encoding/test/worker_helper.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/dom/encoding/test/worker_helper.js b/dom/encoding/test/worker_helper.js
new file mode 100644
index 000000000..bfa408e6a
--- /dev/null
+++ b/dom/encoding/test/worker_helper.js
@@ -0,0 +1,48 @@
+/*
+ * worker_helper.js
+ * bug 764234 tests
+*/
+function runTestInWorker(files) {
+ function workerRun() {
+ var tests = [];
+ var asserts;
+ test = function(func, msg) {
+ asserts = [];
+ tests.push({asserts: asserts, msg: 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) {
+ func = a.shift();
+ self[func].apply(self, a);
+ });
+ }, "worker " + t.msg);
+ });
+ done();
+ };
+}