1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" >
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
7 <script type=
"text/javascript">
9 testRunner
.dumpAsText();
11 function print(message
)
13 var paragraph
= document
.createElement("li");
14 paragraph
.appendChild(document
.createTextNode(message
));
15 document
.getElementById("console").appendChild(paragraph
);
19 result3
= testForElement("onload", "testElement2"); // expect to see "testElement2"
21 // don't show the results until the tests are finished -- it changes the DOM and could affect the tests
26 function testForElement(testName
, elementId
) {
27 var found
= containsElementWithId(document
.body
, elementId
);
28 if (window
.GCController
)
29 GCController
.collect();
31 // create lots of objects to force a garbage collection
40 return testName
+ ": " + (found
? "found" : "not found");
42 function containsElementWithId(el
, id
) {
48 var children
= el
.childNodes
;
49 for (var i
=0; !found
&& i
< children
.length
; i
++)
50 found
= containsElementWithId(children
[i
], id
);
57 <body onload=
"runTest()">
59 <p>This test checks to see if the DOM ContainerNode's NodeList cache is correctly invalidated when new content is parsed.
</p>
60 <p>If the test passes, you should see
"before: not found
",
"after: found
" and
"onload: found
".
</p>
61 <p>If the cache is not invalidated when the testElement is parsed, both before and after will be
"not found
", which is a failure.
</p>
63 <p><ol id=console
></ol></p>
65 <script type=
"text/javascript">
66 result1
= testForElement("before", "testElement"); // expect not to see "testElement"
69 <p id=
"testElement"></p>
71 <script type=
"text/javascript">
72 result2
= testForElement("after", "testElement"); // expect to see "testElement"
75 <p id=
"testElement2"></p>