4 <script src=
"../../resources/js-test.js"></script>
5 <script src='resources/worker-util.js'
></script>
9 description('Verify that creation of a worker does not leak its creating document.');
11 window
.jsTestIsAsync
= true;
15 document
.getElementById("console").innerHTML
+= message
+ "<br>";
18 if (window
.testRunner
) {
19 testRunner
.dumpAsText();
20 testRunner
.waitUntilDone();
23 // Set this number as high as possible without introducing timeouts in debug builds.
24 // Reducing it does not require rebaselines.
25 var numIterations
= 6;
27 var currentIteration
= 0;
29 var numLiveAtStart
= 0;
32 window
.onmessage = function(event
) {
33 if (event
.data
== "done") {
41 if (window
.internals
&& window
.internals
.numberOfLiveDocuments
) {
42 numLiveAtStart
= window
.internals
.numberOfLiveDocuments();
43 // Depending on which tests ran before this one in DumpRenderTree,
44 // their Document instances may not have been fully cleaned up yet.
45 // When this test is run in isolation, there should be only one
46 // live document at this point.
49 debug("window.internals.numberOfLiveDocuments not available -- no point in running test");
54 function runOneIteration() {
55 if (currentIteration
< numIterations
) {
58 var createdIframe
= false;
60 iframe
= document
.createElement("iframe");
63 iframe
.setAttribute("src", "resources/worker-document-leak-iframe.html");
65 document
.body
.appendChild(iframe
);
75 if (window
.internals
&& window
.internals
.numberOfLiveDocuments
) {
76 numLiveAtEnd
= window
.internals
.numberOfLiveDocuments();
77 // Under no circumstances should the number of live documents
78 // at the end be more than 1 greater than the number at the
79 // beginning (because of the iframe).
80 if (numLiveAtEnd
> numLiveAtStart
+ 1) {
81 testFailed("leaked documents during test run (started with " + numLiveAtStart
+ ", ended with " + numLiveAtEnd
+ ")");
83 testPassed("did not leak documents during test run");
89 window
.onload
= startTest
;