1 // Useful utilities for worker tests
5 document
.getElementById("result").innerHTML
+= message
+ "<br>";
8 function waitUntilWorkerThreadsExit(callback
)
10 waitUntilThreadCountMatches(callback
, 0);
13 function waitUntilThreadCountMatches(callback
, count
)
15 // When running in a browser, just wait for one second then call the callback.
16 if (!window
.testRunner
) {
17 setTimeout(function() { gc(); callback(); }, 1000);
21 if (internals
.workerThreadCount
== count
) {
22 // Worker threads have exited.
25 // Poll until worker threads have been GC'd/exited.
26 // Force a GC with a bunch of allocations to try to scramble the stack and force worker objects to be collected.
28 setTimeout(function() { waitUntilThreadCountMatches(callback
, count
); }, 10);
32 function ensureThreadCountMatches(callback
, count
)
34 // Just wait until the thread count matches, then wait another 100ms to see if it changes, then fire the callback.
35 waitUntilThreadCountMatches(function() {
36 setTimeout(function() { waitUntilThreadCountMatches(callback
, count
); }, 100);
43 debug('<br><span class="pass">TEST COMPLETE</span>');
47 // Call notifyDone via the queue so any pending console messages/exceptions are written out first.
48 setTimeout(function() {
49 if (window
.testRunner
)
50 testRunner
.notifyDone();