OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
| 3 <head> |
| 4 <script src="../../resources/js-test.js"></script> |
| 5 <script src='resources/worker-util.js'></script> |
| 6 </script> |
3 <body> | 7 <body> |
4 <p>Verify that creation of a worker does not leak its creating document.</p> | |
5 <div id='console'></div> | |
6 <script src='resources/worker-util.js'></script> | |
7 <script> | 8 <script> |
| 9 description('Verify that creation of a worker does not leak its creating documen
t.'); |
| 10 |
| 11 window.jsTestIsAsync = true; |
| 12 |
8 function log(message) | 13 function log(message) |
9 { | 14 { |
10 document.getElementById("console").innerHTML += message + "<br>"; | 15 document.getElementById("console").innerHTML += message + "<br>"; |
11 } | 16 } |
12 | 17 |
13 if (window.testRunner) { | 18 if (window.testRunner) { |
14 testRunner.dumpAsText(); | 19 testRunner.dumpAsText(); |
15 testRunner.waitUntilDone(); | 20 testRunner.waitUntilDone(); |
16 } | 21 } |
17 | 22 |
(...skipping 16 matching lines...) Expand all Loading... |
34 { | 39 { |
35 gc(); | 40 gc(); |
36 if (window.internals && window.internals.numberOfLiveDocuments) { | 41 if (window.internals && window.internals.numberOfLiveDocuments) { |
37 numLiveAtStart = window.internals.numberOfLiveDocuments(); | 42 numLiveAtStart = window.internals.numberOfLiveDocuments(); |
38 // Depending on which tests ran before this one in DumpRenderTree, | 43 // Depending on which tests ran before this one in DumpRenderTree, |
39 // their Document instances may not have been fully cleaned up yet. | 44 // their Document instances may not have been fully cleaned up yet. |
40 // When this test is run in isolation, there should be only one | 45 // When this test is run in isolation, there should be only one |
41 // live document at this point. | 46 // live document at this point. |
42 runOneIteration(); | 47 runOneIteration(); |
43 } else { | 48 } else { |
44 log("window.internals.numberOfLiveDocuments not available -- no point in
running test"); | 49 debug("window.internals.numberOfLiveDocuments not available -- no point
in running test"); |
45 finishTest(); | 50 finishTest(); |
46 } | 51 } |
47 } | 52 } |
48 | 53 |
49 function runOneIteration() { | 54 function runOneIteration() { |
50 if (currentIteration < numIterations) { | 55 if (currentIteration < numIterations) { |
51 ++currentIteration; | 56 ++currentIteration; |
52 | 57 |
53 var createdIframe = false; | 58 var createdIframe = false; |
54 if (!iframe) { | 59 if (!iframe) { |
55 iframe = document.createElement("iframe"); | 60 iframe = document.createElement("iframe"); |
56 createdIframe = true; | 61 createdIframe = true; |
57 } | 62 } |
58 iframe.setAttribute("src", "resources/worker-document-leak-iframe.html")
; | 63 iframe.setAttribute("src", "resources/worker-document-leak-iframe.html")
; |
59 if (createdIframe) | 64 if (createdIframe) |
60 document.body.appendChild(iframe); | 65 document.body.appendChild(iframe); |
61 } else { | 66 return; |
62 finishTest(); | |
63 } | 67 } |
| 68 asyncGC(finishTest); |
64 } | 69 } |
65 | 70 |
66 function finishTest() | 71 function finishTest() |
67 { | 72 { |
68 gc(); | 73 gc(); |
69 | 74 |
70 if (window.internals && window.internals.numberOfLiveDocuments) { | 75 if (window.internals && window.internals.numberOfLiveDocuments) { |
71 numLiveAtEnd = window.internals.numberOfLiveDocuments(); | 76 numLiveAtEnd = window.internals.numberOfLiveDocuments(); |
72 // Under no circumstances should the number of live documents | 77 // Under no circumstances should the number of live documents |
73 // at the end be more than 1 greater than the number at the | 78 // at the end be more than 1 greater than the number at the |
74 // beginning (because of the iframe). | 79 // beginning (because of the iframe). |
75 if (numLiveAtEnd > numLiveAtStart + 1) { | 80 if (numLiveAtEnd > numLiveAtStart + 1) { |
76 log("FAIL: leaked documents during test run (started with " + numLiv
eAtStart + ", ended with " + numLiveAtEnd + ")"); | 81 testFailed("leaked documents during test run (started with " + numLi
veAtStart + ", ended with " + numLiveAtEnd + ")"); |
77 } else { | 82 } else { |
78 log("PASS: did not leak documents during test run"); | 83 testPassed("did not leak documents during test run"); |
79 } | 84 } |
80 } | 85 } |
81 | 86 finishJSTest(); |
82 if (window.testRunner) | |
83 testRunner.notifyDone(); | |
84 } | 87 } |
85 | 88 |
86 window.onload = startTest; | 89 window.onload = startTest; |
87 </script> | 90 </script> |
88 </body> | 91 </body> |
89 </html> | 92 </html> |
OLD | NEW |