Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
<window title="Worker shutdown check"
<!-- test results are displayed in the html:body -->
</body>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
SimpleTest.waitForExplicitFinish()
const URL = "worker_shutdownCheck.js";
function checkWorker() {
const wdm = Cc["@mozilla.org/dom/workers/workerdebuggermanager;1"].
getService(Ci.nsIWorkerDebuggerManager);
let e = wdm.getWorkerDebuggerEnumerator();
while (e.hasMoreElements()) {
let dbg = e.getNext().QueryInterface(Ci.nsIWorkerDebugger);
if (dbg.url == URL) {
return true;
}
}
return false;
}
// This test synchronously enumerates the WorkerDebuggerManager right after
// creating the worker and matches the relative script URL. The parent-process
// RemoteWorkerDebugger registers asynchronously over IPC and reports the
// absolute script URL, so force the local WorkerDebugger (bug 1944240). Remove
// this pin (or the test) once the local WorkerDebugger mechanism is removed;
// this legacy synchronous worker-introspection path still needs to be
// modernized to the RemoteWorkerDebugger model.
SpecialPowers.pushPrefEnv({
set: [["dom.worker.remoteDebugger.enabled", false]],
}).then(() => new Promise(resolve => {
var w = new Worker(URL);
ok(checkWorker(), "We have the worker");
w.onmessage = () => { resolve(); }
})).then(() => {
info("Waiting...");
// We don't know if the worker thread is able to shutdown when calling
// CC/GC. Better to check again in case.
function checkGC() {
Cu.forceCC();
Cu.forceGC();
if (!checkWorker()) {
ok(true, "We don't have the worker");
SimpleTest.finish();
return;
}
setTimeout(checkGC, 200);
}
checkGC();
});
]]>
</script>
</window>