summaryrefslogtreecommitdiffstats
path: root/LayoutTests/fast/dom/NodeList/invalidate-node-lists-when-parsing.html
diff options
context:
space:
mode:
Diffstat (limited to 'LayoutTests/fast/dom/NodeList/invalidate-node-lists-when-parsing.html')
-rw-r--r--LayoutTests/fast/dom/NodeList/invalidate-node-lists-when-parsing.html77
1 files changed, 77 insertions, 0 deletions
diff --git a/LayoutTests/fast/dom/NodeList/invalidate-node-lists-when-parsing.html b/LayoutTests/fast/dom/NodeList/invalidate-node-lists-when-parsing.html
new file mode 100644
index 0000000..c4397dd
--- /dev/null
+++ b/LayoutTests/fast/dom/NodeList/invalidate-node-lists-when-parsing.html
@@ -0,0 +1,77 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" >
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>5360748</title>
+
+ <script type="text/javascript">
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ function print(message)
+ {
+ var paragraph = document.createElement("li");
+ paragraph.appendChild(document.createTextNode(message));
+ document.getElementById("console").appendChild(paragraph);
+ }
+
+ function runTest() {
+ result3 = testForElement("onload", "testElement2"); // expect to see "testElement2"
+
+ // don't show the results until the tests are finished -- it changes the DOM and could affect the tests
+ print(result1);
+ print(result2);
+ print(result3);
+ }
+ function testForElement(testName, elementId) {
+ var found = containsElementWithId(document.body, elementId);
+ if (window.GCController)
+ GCController.collect();
+ else {
+ // create lots of objects to force a garbage collection
+ var i = 0;
+ var s;
+ while (i < 5000) {
+ i = i+1.11;
+ s = s + " ";
+ }
+ }
+
+ return testName + ": " + (found ? "found" : "not found");
+ }
+ function containsElementWithId(el, id) {
+ var found = false;
+
+ if (el.id == id) {
+ found = true;
+ } else {
+ var children = el.childNodes;
+ for (var i=0; !found && i < children.length; i++)
+ found = containsElementWithId(children[i], id);
+ }
+
+ return found;
+ }
+ </script>
+ </head>
+ <body onload="runTest()">
+
+ <p>This test checks to see if the DOM ContainerNode's NodeList cache is correctly invalidated when new content is parsed.</p>
+ <p>If the test passes, you should see &quot;before: not found&quot;, &quot;after: found&quot; and &quot;onload: found&quot;.</p>
+ <p>If the cache is not invalidated when the testElement is parsed, both before and after will be &quot;not found&quot;, which is a failure.</p>
+ <hr>
+ <p><ol id=console></ol></p>
+
+ <script type="text/javascript">
+ result1 = testForElement("before", "testElement"); // expect not to see "testElement"
+ </script>
+
+ <p id="testElement"></p>
+
+ <script type="text/javascript">
+ result2 = testForElement("after", "testElement"); // expect to see "testElement"
+ </script>
+
+ <p id="testElement2"></p>
+</body>
+</html>