Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / workers / worker-gc.html
blob9fc6bdd940ece2147fc2080e3f76b8cf318f9a88
1 <body>
2 <p>Test worker garbage collection. Should print "SUCCESS".</p>
3 <div id=result></div>
4 <script>
5 function log(message)
7 document.getElementById("result").innerHTML += message + "<br>";
10 function gc()
12 if (window.GCController)
13 return GCController.collect();
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");
20 if (window.testRunner) {
21 testRunner.dumpAsText();
22 testRunner.waitUntilDone();
25 var interval = setInterval(gc, 0);
27 var worker = new Worker('resources/worker-common.js');
28 worker.postMessage("ping");
29 worker.onmessage = function(evt) {
30 this.postMessage("ping");
31 this.onmessage = function() {
32 log("SUCCESS");
33 clearInterval(interval);
34 if (window.testRunner)
35 testRunner.notifyDone();
39 worker = 0;
40 gc();
41 </script>
42 </body>
43 </html>