Refactoring: Pull all fullscreen code out of Document and into its own helper class
[WebKit-https.git] / LayoutTests / traversal / stay-within-root.html
1 <html>
2 <head>
3 <script language="JavaScript">
4 if (window.testRunner)
5     testRunner.dumpAsText();
6
7 function log(message) {
8     var console = document.getElementById("console");
9     var li = document.createElement("li");
10     var text = document.createTextNode(message);
11     li.appendChild(text);
12     console.appendChild(li);
13 }
14
15 function iteratorTest() {
16     log("NodeIterator: testing nextNode() (5 should be null)");
17     var iterator = document.createNodeIterator(divB, NodeFilter.SHOW_ELEMENT, null, false);
18     iterator.root = divB;
19     for (i=0; i < 4; i++)
20         log(iterator.nextNode());
21
22     log("NodeIterator: testing previousNode() (7 should be null)");
23     iterator = document.createNodeIterator(divB, NodeFilter.SHOW_ELEMENT, null, false);
24     log(iterator.previousNode());
25     
26     log("TreeWalker: testing nextNode() (11 should be null)");
27     iterator = document.createTreeWalker(divB, NodeFilter.SHOW_ELEMENT, null, false);
28     for (i=0; i < 3; i++)
29         log(iterator.nextNode());
30
31     log("TreeWalker: testing previousNode() (13 should be null)");
32     iterator = document.createTreeWalker(divB, NodeFilter.SHOW_ELEMENT, null, false);
33     log(iterator.previousNode());
34 }
35 </script>
36 </head>
37
38 <body>
39 <div id="divA">
40 This test checks that the NodeIterator and TreeWalker functions do not go past the root element that they are supposed to stay within.
41 <div id="divB">
42 <div id="divC">
43 </div>
44 <div id="divD">
45 </div>
46
47 </div>
48 </div>
49
50 <ol id="console" > </ol>
51
52 <script>
53 iteratorTest();
54 </script>
55
56 </body>
57
58 </html>