OLD | NEW |
1 <body> | 1 <body> |
2 <p>Test that worker object is not garbage collected if there is a message from | 2 <p>Test that worker object is not garbage collected if there is a message from |
3 worker context. Should print "SUCCESS". | 3 worker context. Should print "SUCCESS". |
4 <a href="https://bugs.webkit.org/show_bug.cgi?id=62446">Bug 62446</a></p> | 4 <a href="https://bugs.webkit.org/show_bug.cgi?id=62446">Bug 62446</a></p> |
5 <div id=result></div> | 5 <div id=result></div> |
| 6 <script src="../../resources/gc.js"></script> |
6 <script> | 7 <script> |
7 function log(message) | 8 function log(message) |
8 { | 9 { |
9 document.getElementById("result").innerHTML += message + "<br>"; | 10 document.getElementById("result").innerHTML += message + "<br>"; |
10 } | 11 } |
11 | 12 |
12 function gc() | |
13 { | |
14 if (window.GCController) | |
15 return GCController.collect(); | |
16 | |
17 var head; | |
18 for (var i = 0; i < 10000; i++) { | |
19 var newHead = new Array(1000); | |
20 newHead[0] = head; | |
21 head = newHead; | |
22 } | |
23 } | |
24 | |
25 if (window.testRunner) { | 13 if (window.testRunner) { |
26 testRunner.dumpAsText(); | 14 testRunner.dumpAsText(); |
27 testRunner.waitUntilDone(); | 15 testRunner.waitUntilDone(); |
28 } | 16 } |
29 | 17 |
30 var interval = setInterval(gc, 0); | 18 var interval = setInterval(gc, 0); |
31 | 19 |
32 var worker = new Worker('resources/worker-init.js'); | 20 var worker = new Worker('resources/worker-init.js'); |
33 worker.onmessage = function(evt) { | 21 worker.onmessage = function(evt) { |
34 log(evt.data); | 22 log(evt.data); |
35 clearInterval(interval); | 23 clearInterval(interval); |
36 if (window.testRunner) | 24 if (window.testRunner) |
37 testRunner.notifyDone(); | 25 testRunner.notifyDone(); |
38 } | 26 } |
39 worker = 0; | 27 worker = 0; |
40 gc(); | 28 gc(); |
41 </script> | 29 </script> |
42 </body> | 30 </body> |
43 </html> | 31 </html> |
OLD | NEW |