• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" >
2<html>
3    <head>
4        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5        <title>5360748</title>
6
7        <script type="text/javascript">
8            if (window.layoutTestController)
9                layoutTestController.dumpAsText();
10
11            function print(message)
12            {
13                var paragraph = document.createElement("li");
14                paragraph.appendChild(document.createTextNode(message));
15                document.getElementById("console").appendChild(paragraph);
16            }
17
18            function runTest() {
19                result3 = testForElement("onload", "testElement2");    // expect to see "testElement2"
20
21                // don't show the results until the tests are finished -- it changes the DOM and could affect the tests
22                print(result1);
23                print(result2);
24                print(result3);
25            }
26            function testForElement(testName, elementId) {
27                var found = containsElementWithId(document.body, elementId);
28                if (window.GCController)
29                    GCController.collect();
30                else {
31                    // create lots of objects to force a garbage collection
32                    var i = 0;
33                    var s;
34                    while (i < 5000) {
35                        i = i+1.11;
36                        s = s + " ";
37                    }
38                }
39
40                return testName + ": " + (found ? "found" : "not found");
41            }
42            function containsElementWithId(el, id) {
43                var found = false;
44
45                if (el.id == id) {
46                    found = true;
47                } else {
48                    var children = el.childNodes;
49                    for (var i=0; !found && i < children.length; i++)
50                        found = containsElementWithId(children[i], id);
51                }
52
53                return found;
54            }
55        </script>
56    </head>
57    <body onload="runTest()">
58
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 &quot;before: not found&quot;, &quot;after: found&quot; and &quot;onload: found&quot;.</p>
61    <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>
62    <hr>
63    <p><ol id=console></ol></p>
64
65    <script type="text/javascript">
66        result1 = testForElement("before", "testElement");    // expect not to see "testElement"
67    </script>
68
69    <p id="testElement"></p>
70
71    <script type="text/javascript">
72        result2 = testForElement("after", "testElement");    // expect to see "testElement"
73    </script>
74
75    <p id="testElement2"></p>
76</body>
77</html>
78