Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'android'
- Manifest: dom/workers/test/chrome.toml
<?xml version="1.0"?>
<!--
Any copyright is dedicated to the Public Domain.
-->
<window title="DOM Worker Threads Test"
<script type="application/javascript" src="dom_worker_helper.js"/>
<script type="application/javascript">
<![CDATA[
add_task(async function classic_worker_test() {
let worker = window.classicWorker = new ChromeWorker("chromeWorker_worker.js");
await new Promise((resolve, reject) => {
worker.onmessage = function(event) {
is(event.data, "Done!", "Got the done message!");
resolve();
};
worker.onerror = function(event) {
ok(false, "Classic Worker had an error: " + event.message);
worker.terminate();
reject();
};
worker.postMessage("go");
});
});
add_task(async function module_worker_test() {
waitForWorkerFinish();
let worker = window.moduleWorker = new ChromeWorker("chromeWorker_worker.sys.mjs", { type: "module" });
await new Promise((resolve, reject) => {
worker.onmessage = function(event) {
is(event.data, "Done!", "Got the done message!");
resolve();
};
worker.onerror = function(event) {
ok(false, "Module Worker had an error: " + event.message);
worker.terminate();
reject();
};
worker.postMessage("go");
});
});
]]>
</script>
<p id="display"></p>
<div id="content" style="display:none;"></div>
<pre id="test"></pre>
</body>
<label id="test-result"/>
</window>