1 description("This test checks whether shared workers exit when the parent document closes");
3 if (window.testRunner) {
4 testRunner.dumpAsText();
5 testRunner.waitUntilDone();
6 waitUntilWorkerThreadsExit(runTests);
8 debug("NOTE: This test relies on functionality in DumpRenderTree to detect when workers have exited - test results will be incorrect when run in a browser.");
14 createWorkerFrame("frame1", "worker1");
15 createWorkerFrame("frame2", "worker1,worker2");
16 createWorkerFrame("frame3", "worker3");
17 createWorkerFrame("frame4", "worker1");
19 waitUntilThreadCountMatches(closeFrame1, 3);
22 function createWorkerFrame(id, workerNames)
24 var iframe = document.createElement("iframe");
25 iframe.setAttribute("id", id);
26 iframe.setAttribute("src", "resources/create-shared-worker-frame.html?" + workerNames);
27 document.body.appendChild(iframe);
30 function closeFrame(id)
32 var frame = document.getElementById(id);
33 frame.parentNode.removeChild(frame);
36 function closeFrame1()
39 ensureThreadCountMatches(closeFrame2, 3);
42 function closeFrame2()
44 testPassed("Frame1 closed, shared workers kept running");
46 ensureThreadCountMatches(closeFrame3, 2);
49 function closeFrame3()
51 testPassed("Frame2 closed, shared worker2 exited");
53 ensureThreadCountMatches(closeFrame4, 1);
56 function closeFrame4()
58 testPassed("Frame3 closed, shared worker3 exited");
60 waitUntilWorkerThreadsExit(complete);
65 testPassed("Frame4 closed, all workers closed");