OLD | NEW |
1 <body> | 1 <body> |
2 <p>Test shared worker garbage collection. Should print "PASS" followed by "DONE"
.</p> | 2 <p>Test shared worker garbage collection. Should print "PASS" followed by "DONE"
.</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 a
bout 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 worker = new SharedWorker('resources/shared-worker-common.js', 'name'); | 16 var worker = new SharedWorker('resources/shared-worker-common.js', 'name'); |
26 worker.port.onmessage = handleMessage; | 17 worker.port.onmessage = handleMessage; |
27 worker.port.postMessage("ping"); | 18 worker.port.postMessage("ping"); |
28 worker = 0; | 19 worker = 0; |
29 gc(); | 20 gc(); |
30 | 21 |
31 function handleMessage(event) { | 22 function handleMessage(event) { |
32 log(event.data); | 23 log(event.data); |
33 log("DONE"); | 24 log("DONE"); |
34 if (window.testRunner) | 25 if (window.testRunner) |
35 testRunner.notifyDone(); | 26 testRunner.notifyDone(); |
36 }; | 27 }; |
37 </script> | 28 </script> |
38 </body> | 29 </body> |
OLD | NEW |