1 description("This test checks whether orphaned workers exit under various conditions");
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.");
12 // Contains tests for dedicated-worker-specific lifecycle functionality.
15 // Start a worker, drop/GC our reference to it, make sure it exits.
16 var worker = createWorker();
17 worker.postMessage("ping");
18 worker.onmessage = function(event) {
19 if (window.testRunner) {
20 if (internals.workerThreadCount == 1)
21 testPassed("Orphaned worker thread created.");
23 testFailed("After thread creation: internals.workerThreadCount = " + internals.workerThreadCount);
26 // Orphan our worker (no more references to it) and wait for it to exit.
29 // Allocating a Date object seems to scramble the stack and force the worker object to get GC'd.
31 waitUntilWorkerThreadsExit(orphanedWorkerExited);
35 function orphanedWorkerExited()
37 testPassed("Orphaned worker thread exited.");
38 // Start a worker, drop/GC our reference to it, make sure it exits.
39 var worker = createWorker();
40 worker.postMessage("ping");
41 worker.onmessage = function(event) {
42 if (window.testRunner) {
43 if (internals.workerThreadCount == 1)
44 testPassed("Orphaned timeout worker thread created.");
46 testFailed("After thread creation: internals.workerThreadCount = " + internals.workerThreadCount);
48 // Send a message that starts up an async operation, to make sure the thread exits when it completes.
49 // FIXME: Disabled for now - re-enable when bug 28702 is fixed.
50 //worker.postMessage("eval setTimeout('', 10)");
52 // Orphan our worker (no more references to it) and wait for it to exit.
55 // For some reason, the worker object does not get GC'd unless we allocate a new object here.
56 // The conjecture is that there's a value on the stack that appears to point to the worker which this clobbers.
58 waitUntilWorkerThreadsExit(orphanedTimeoutWorkerExited);
62 function orphanedTimeoutWorkerExited()
64 testPassed("Orphaned timeout worker thread exited.");