1 <html xmlns=
"http://www.w3.org/1999/xhtml">
3 https://bugzilla.mozilla.org/show_bug.cgi?id=522601
6 <title>Test for Bug
522601</title>
7 <script type=
"application/javascript" src=
"/MochiKit/packed.js"></script>
8 <script type=
"application/javascript" src=
"/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
11 <bindings xmlns=
"http://www.mozilla.org/xbl">
12 <binding id=
"testBinding">
13 <content><div><children/></div><children includes=
"span"/></content>
18 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=522601">Mozilla Bug
522601</a>
19 <p id=
"display" style=
"-moz-binding: url(#testBinding)">
20 <span id=
"s">This is some text
</span>
22 <b id=
"b">Even more
<i id=
"i1">Italic
</i>text
<i id=
"i2">And more italic
</i></b></p>
23 <div id=
"content" style=
"display: none">
27 <script type=
"application/javascript">
30 /** Test for Bug
522601 **/
31 SimpleTest.waitForExplicitFinish();
33 function testFunc(walker, func, expectedNode, str) {
34 var oldCurrent = walker.currentNode;
35 var newNode = walker[func]();
36 is(newNode, expectedNode,
"Unexpected node after " + str);
37 is(walker.currentNode, newNode ? newNode : oldCurrent,
38 "Unexpected current node after " + str);
41 addLoadEvent(function() {
42 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
44 Components.classes[
"@mozilla.org/inspector/deep-tree-walker;1"]
45 .createInstance(Components.interfaces.inIDeepTreeWalker);
46 walkerNonAnon.init($(
"display"), NodeFilter.SHOW_ALL);
47 walkerNonAnon.showAnonymousContent = false;
49 is(walkerNonAnon.currentNode, $(
"display"),
"Unexpected non-anon root");
50 testFunc(walkerNonAnon,
"nextNode", $(
"s").previousSibling,
52 testFunc(walkerNonAnon,
"nextNode", $(
"s"),
"step to span");
53 testFunc(walkerNonAnon,
"nextNode", $(
"s").firstChild,
"step to span text");
54 testFunc(walkerNonAnon,
"nextNode", $(
"s").nextSibling,
"step to more text");
55 testFunc(walkerNonAnon,
"nextNode", $(
"b"),
"step to bold");
56 testFunc(walkerNonAnon,
"nextNode", $(
"b").firstChild,
"step to bold text");
57 testFunc(walkerNonAnon,
"nextNode", $(
"i1"),
"step to first italic");
58 testFunc(walkerNonAnon,
"nextNode", $(
"i1").firstChild,
59 "step to first italic text");
60 testFunc(walkerNonAnon,
"nextNode", $(
"i1").nextSibling,
61 "step to more bold text");
62 testFunc(walkerNonAnon,
"nextNode", $(
"i2"),
"step to second italic");
63 testFunc(walkerNonAnon,
"nextNode", $(
"i2").firstChild,
64 "step to second italic text");
65 testFunc(walkerNonAnon,
"nextNode", null,
"step past end");
66 testFunc(walkerNonAnon,
"parentNode", $(
"i2"),
"step up to second italic");
67 testFunc(walkerNonAnon,
"parentNode", $(
"b"),
"step up to bold");
68 testFunc(walkerNonAnon,
"nextNode", $(
"b").firstChild,
"step to bold text again");
69 testFunc(walkerNonAnon,
"parentNode", $(
"b"),
"step up to bold again");
70 testFunc(walkerNonAnon,
"parentNode", $(
"display"),
"step up to display");
71 testFunc(walkerNonAnon,
"parentNode", null,
"step up past root");
72 testFunc(walkerNonAnon,
"firstChild", $(
"s").previousSibling,
73 "step firstChild to display first child");
74 testFunc(walkerNonAnon,
"nextSibling", $(
"s"),
75 "step nextSibling to span");
76 testFunc(walkerNonAnon,
"nextSibling", $(
"s").nextSibling,
77 "step nextSibling to more text");
78 testFunc(walkerNonAnon,
"nextSibling", $(
"b"),
"step nextSibling to bold");
79 testFunc(walkerNonAnon,
"nextSibling", null,
"step nextSibling past end");
80 testFunc(walkerNonAnon,
"previousSibling", $(
"s").nextSibling,
81 "step previousSibling to more text");
82 testFunc(walkerNonAnon,
"previousSibling", $(
"s"),
83 "step previousSibling to span");
84 testFunc(walkerNonAnon,
"previousSibling", $(
"s").previousSibling,
85 "step previousSibling to display first child");
86 testFunc(walkerNonAnon,
"previousSibling", null,
87 "step previousSibling past end");
89 // Move the walker over to the end
90 while (walkerNonAnon.nextNode()) { /* do nothing */ }
91 is(walkerNonAnon.currentNode, $(
"i2").firstChild,
"unexpected last node");
92 testFunc(walkerNonAnon,
"previousNode", $(
"i2"),
"step back to second italic");
93 testFunc(walkerNonAnon,
"previousNode", $(
"i1").nextSibling,
94 "step back to more bold text");
95 testFunc(walkerNonAnon,
"previousNode", $(
"i1").firstChild,
96 "step back to first italic text");
97 testFunc(walkerNonAnon,
"previousNode", $(
"i1"),
"step back to first italic");
98 testFunc(walkerNonAnon,
"previousNode", $(
"b").firstChild,
99 "step back to bold text");
100 testFunc(walkerNonAnon,
"previousNode", $(
"b"),
"step back to bold");
101 testFunc(walkerNonAnon,
"previousNode", $(
"s").nextSibling,
"step back to more text");
102 testFunc(walkerNonAnon,
"previousNode", $(
"s").firstChild,
"step back to span text");
103 testFunc(walkerNonAnon,
"previousNode", $(
"s"),
"step back to span");
104 testFunc(walkerNonAnon,
"previousNode", $(
"s").previousSibling,
105 "step back to some text");
106 testFunc(walkerNonAnon,
"previousNode", $(
"display"),
107 "step back to root");
108 testFunc(walkerNonAnon,
"previousNode", null,
109 "step back past root");
111 var anonDiv = document.getAnonymousNodes($(
"display"))[
0];
114 Components.classes[
"@mozilla.org/inspector/deep-tree-walker;1"]
115 .createInstance(Components.interfaces.inIDeepTreeWalker);
116 walkerAnon.showAnonymousContent = true;
117 walkerAnon.init($(
"display"), NodeFilter.SHOW_ALL);
119 is(walkerAnon.currentNode, $(
"display"),
"Unexpected anon root");
120 testFunc(walkerAnon,
"nextNode", anonDiv,
121 "step to anonymous div");
122 testFunc(walkerAnon,
"nextNode", $(
"s").previousSibling,
123 "step to some text (anon)");
124 testFunc(walkerAnon,
"nextNode", $(
"s").nextSibling,
"step to more text (anon)");
125 testFunc(walkerAnon,
"nextNode", $(
"b"),
"step to bold (anon)");
126 testFunc(walkerAnon,
"nextNode", $(
"b").firstChild,
"step to bold text (anon)");
127 testFunc(walkerAnon,
"nextNode", $(
"i1"),
"step to first italic (anon)");
128 testFunc(walkerAnon,
"nextNode", $(
"i1").firstChild,
129 "step to first italic text (anon)");
130 testFunc(walkerAnon,
"nextNode", $(
"i1").nextSibling,
131 "step to more bold text (anon)");
132 testFunc(walkerAnon,
"nextNode", $(
"i2"),
"step to second italic (anon)");
133 testFunc(walkerAnon,
"nextNode", $(
"i2").firstChild,
134 "step to second italic text (anon)");
135 testFunc(walkerAnon,
"nextNode", $(
"s"),
"step to span (anon)");
136 testFunc(walkerAnon,
"nextNode", $(
"s").firstChild,
"step to span text (anon)");
137 testFunc(walkerAnon,
"nextNode", null,
"step past end (anon)");
138 testFunc(walkerAnon,
"parentNode", $(
"s"),
"step up to span (anon)");
139 testFunc(walkerAnon,
"parentNode", $(
"display"),
"step up to display (anon)");
140 testFunc(walkerAnon,
"nextNode", anonDiv,
"step to anonymous div again");
141 testFunc(walkerAnon,
"parentNode", $(
"display"),
142 "step up to display again (anon)");
143 testFunc(walkerAnon,
"parentNode", null,
"step up past root (anon)");
144 testFunc(walkerAnon,
"firstChild", anonDiv,
145 "step firstChild to display first child (anon)");
146 testFunc(walkerAnon,
"nextSibling", $(
"s"),
147 "step nextSibling to span (anon)");
148 testFunc(walkerAnon,
"nextSibling", null,
"step nextSibling past end (anon)");
149 testFunc(walkerAnon,
"previousSibling", anonDiv,
150 "step previousSibling to anonymous div");
151 testFunc(walkerAnon,
"previousSibling", null,
"step previousSibling past end (anon)");
153 // Move the walker over to the end
154 while (walkerAnon.nextNode()) { /* do nothing */ }
155 testFunc(walkerAnon,
"previousNode", $(
"s"),
"step back to span (anon)");
156 testFunc(walkerAnon,
"previousNode", $(
"i2").firstChild,
157 "step back to second italic text (anon)");
158 testFunc(walkerAnon,
"previousNode", $(
"i2"),
"step back to second italic (anon)");
159 testFunc(walkerAnon,
"previousNode", $(
"i1").nextSibling,
160 "step back to more bold text (anon)");
161 testFunc(walkerAnon,
"previousNode", $(
"i1").firstChild,
162 "step back to first italic text (anon)");
163 testFunc(walkerAnon,
"previousNode", $(
"i1"),
"step back to first italic (anon)");
164 testFunc(walkerAnon,
"previousNode", $(
"b").firstChild,
"step back to bold text (anon)");
165 testFunc(walkerAnon,
"previousNode", $(
"b"),
"step back to bold (anon)");
166 testFunc(walkerAnon,
"previousNode", $(
"s").nextSibling,
"step back to more text (anon)");
167 testFunc(walkerAnon,
"previousNode", $(
"s").previousSibling,
168 "step back to some text (anon)");
169 testFunc(walkerAnon,
"previousNode", anonDiv,
170 "step back to anonymous div");
171 testFunc(walkerAnon,
"previousNode", $(
"display"),
"step back to root (anon)");
172 testFunc(walkerAnon,
"previousNode", null,
"step back past root (anon)");