OLD | NEW |
1 <body> | 1 <body> |
2 <p>Test worker garbage collection. Should print "SUCCESS".</p> | 2 <p>Test worker garbage collection. Should print "SUCCESS".</p> |
3 <div id=result></div> | 3 <div id=result></div> |
| 4 <script src="../../resources/gc.js"></script> |
4 <script> | 5 <script> |
5 function log(message) | 6 function log(message) |
6 { | 7 { |
7 document.getElementById("result").innerHTML += message + "<br>"; | 8 document.getElementById("result").innerHTML += message + "<br>"; |
8 } | 9 } |
9 | 10 |
10 function gc() | |
11 { | |
12 if (window.GCController) | |
13 return GCController.collect(); | |
14 | |
15 for (var i = 0; i < 10000; i++) { // > force garbage collection (FF requires
about 9K allocations before a collect) | |
16 var s = new String("abc"); | |
17 } | |
18 } | |
19 | |
20 if (window.testRunner) { | 11 if (window.testRunner) { |
21 testRunner.dumpAsText(); | 12 testRunner.dumpAsText(); |
22 testRunner.waitUntilDone(); | 13 testRunner.waitUntilDone(); |
23 } | 14 } |
24 | 15 |
25 var interval = setInterval(gc, 0); | 16 var interval = setInterval(gc, 0); |
26 | 17 |
27 var worker = new Worker('resources/worker-common.js'); | 18 var worker = new Worker('resources/worker-common.js'); |
28 worker.postMessage("ping"); | 19 worker.postMessage("ping"); |
29 worker.onmessage = function(evt) { | 20 worker.onmessage = function(evt) { |
30 this.postMessage("ping"); | 21 this.postMessage("ping"); |
31 this.onmessage = function() { | 22 this.onmessage = function() { |
32 log("SUCCESS"); | 23 log("SUCCESS"); |
33 clearInterval(interval); | 24 clearInterval(interval); |
34 if (window.testRunner) | 25 if (window.testRunner) |
35 testRunner.notifyDone(); | 26 testRunner.notifyDone(); |
36 } | 27 } |
37 | 28 |
38 } | 29 } |
39 worker = 0; | 30 worker = 0; |
40 gc(); | 31 gc(); |
41 </script> | 32 </script> |
42 </body> | 33 </body> |
43 </html> | 34 </html> |
OLD | NEW |