diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /dom/encoding/test/worker_helper.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/encoding/test/worker_helper.js')
-rw-r--r-- | dom/encoding/test/worker_helper.js | 51 |
1 files changed, 51 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..79bd8dc9e3 --- /dev/null +++ b/dom/encoding/test/worker_helper.js @@ -0,0 +1,51 @@ +/* + * worker_helper.js + * bug 764234 tests + */ +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) { + func = a.shift(); + self[func].apply(self, a); + }); + }, "worker " + t.msg); + }); + done(); + }; +} |