tizen beta release
[framework/web/webkit-efl.git] / LayoutTests / fast / xmlhttprequest / xmlhttprequest-gc.html
1 <html>
2 <script>
3 function stateChange() {
4     document.write(this.foo + '<br>');
5     if (this.readyState == 4) {
6         if (window.layoutTestController)
7             layoutTestController.notifyDone();
8     }
9 }
10
11 function collectGarbage() {
12     if (window.GCController) {
13         window.GCController.collect();
14     } else {
15       for (var i = 0; i < 50000; i++)
16           new Object();
17     }
18 }
19
20 function runTest() {
21     document.write("Tests that garbage collection doesn't drop the XMLHttpRequest JS wrapper until the send command is done.  You should see 'bar' four times below.<br>");
22
23     if (window.layoutTestController) {
24         layoutTestController.dumpAsText();
25         layoutTestController.waitUntilDone();
26     }
27
28     var xhr = new XMLHttpRequest();
29     xhr.foo = 'bar';
30     xhr.onreadystatechange = stateChange;
31     xhr.open("GET", "xmlhttprequest-gc.html", true);
32     xhr.send(null);
33
34     xhr = null;
35     collectGarbage();
36 }
37
38 </script>
39 <body onload='runTest()'>
40 </body>
41 </html>