1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/inspector/tests/test_bug522601.xhtml Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,179 @@ 1.4 +<html xmlns="http://www.w3.org/1999/xhtml"> 1.5 +<!-- 1.6 +https://bugzilla.mozilla.org/show_bug.cgi?id=522601 1.7 +--> 1.8 +<head> 1.9 + <title>Test for Bug 522601</title> 1.10 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.11 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.12 + 1.13 + <bindings xmlns="http://www.mozilla.org/xbl"> 1.14 + <binding id="testBinding"> 1.15 + <content><div><children/></div><children includes="span"/></content> 1.16 + </binding> 1.17 + </bindings> 1.18 +</head> 1.19 +<body> 1.20 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=522601">Mozilla Bug 522601</a> 1.21 +<p id="display" style="-moz-binding: url(#testBinding)"> 1.22 + <span id="s">This is some text</span> 1.23 + More text 1.24 + <b id="b">Even more <i id="i1">Italic</i>text<i id="i2">And more italic</i></b></p> 1.25 +<div id="content" style="display: none"> 1.26 + 1.27 +</div> 1.28 +<pre id="test"> 1.29 +<script type="application/javascript"> 1.30 +<![CDATA[ 1.31 + 1.32 +/** Test for Bug 522601 **/ 1.33 +SimpleTest.waitForExplicitFinish(); 1.34 + 1.35 +function testFunc(walker, func, expectedNode, str) { 1.36 + var oldCurrent = SpecialPowers.unwrap(walker.currentNode); 1.37 + var newNode = SpecialPowers.unwrap(walker[func]()); 1.38 + is(newNode, expectedNode, "Unexpected node after " + str); 1.39 + is(SpecialPowers.unwrap(walker.currentNode), newNode ? newNode : oldCurrent, 1.40 + "Unexpected current node after " + str); 1.41 +} 1.42 + 1.43 +addLoadEvent(function() { 1.44 + var walkerNonAnon = 1.45 + SpecialPowers.Cc["@mozilla.org/inspector/deep-tree-walker;1"] 1.46 + .createInstance(SpecialPowers.Ci.inIDeepTreeWalker); 1.47 + walkerNonAnon.init($("display"), NodeFilter.SHOW_ALL); 1.48 + walkerNonAnon.showAnonymousContent = false; 1.49 + 1.50 + is(SpecialPowers.unwrap(walkerNonAnon.currentNode), $("display"), "Unexpected non-anon root"); 1.51 + testFunc(walkerNonAnon, "nextNode", $("s").previousSibling, 1.52 + "step to some text"); 1.53 + testFunc(walkerNonAnon, "nextNode", $("s"), "step to span"); 1.54 + testFunc(walkerNonAnon, "nextNode", $("s").firstChild, "step to span text"); 1.55 + testFunc(walkerNonAnon, "nextNode", $("s").nextSibling, "step to more text"); 1.56 + testFunc(walkerNonAnon, "nextNode", $("b"), "step to bold"); 1.57 + testFunc(walkerNonAnon, "nextNode", $("b").firstChild, "step to bold text"); 1.58 + testFunc(walkerNonAnon, "nextNode", $("i1"), "step to first italic"); 1.59 + testFunc(walkerNonAnon, "nextNode", $("i1").firstChild, 1.60 + "step to first italic text"); 1.61 + testFunc(walkerNonAnon, "nextNode", $("i1").nextSibling, 1.62 + "step to more bold text"); 1.63 + testFunc(walkerNonAnon, "nextNode", $("i2"), "step to second italic"); 1.64 + testFunc(walkerNonAnon, "nextNode", $("i2").firstChild, 1.65 + "step to second italic text"); 1.66 + testFunc(walkerNonAnon, "nextNode", null, "step past end"); 1.67 + testFunc(walkerNonAnon, "parentNode", $("i2"), "step up to second italic"); 1.68 + testFunc(walkerNonAnon, "parentNode", $("b"), "step up to bold"); 1.69 + testFunc(walkerNonAnon, "nextNode", $("b").firstChild, "step to bold text again"); 1.70 + testFunc(walkerNonAnon, "parentNode", $("b"), "step up to bold again"); 1.71 + testFunc(walkerNonAnon, "parentNode", $("display"), "step up to display"); 1.72 + testFunc(walkerNonAnon, "parentNode", null, "step up past root"); 1.73 + testFunc(walkerNonAnon, "firstChild", $("s").previousSibling, 1.74 + "step firstChild to display first child"); 1.75 + testFunc(walkerNonAnon, "nextSibling", $("s"), 1.76 + "step nextSibling to span"); 1.77 + testFunc(walkerNonAnon, "nextSibling", $("s").nextSibling, 1.78 + "step nextSibling to more text"); 1.79 + testFunc(walkerNonAnon, "nextSibling", $("b"), "step nextSibling to bold"); 1.80 + testFunc(walkerNonAnon, "nextSibling", null, "step nextSibling past end"); 1.81 + testFunc(walkerNonAnon, "previousSibling", $("s").nextSibling, 1.82 + "step previousSibling to more text"); 1.83 + testFunc(walkerNonAnon, "previousSibling", $("s"), 1.84 + "step previousSibling to span"); 1.85 + testFunc(walkerNonAnon, "previousSibling", $("s").previousSibling, 1.86 + "step previousSibling to display first child"); 1.87 + testFunc(walkerNonAnon, "previousSibling", null, 1.88 + "step previousSibling past end"); 1.89 + 1.90 + // Move the walker over to the end 1.91 + while (walkerNonAnon.nextNode()) { /* do nothing */ } 1.92 + is(SpecialPowers.unwrap(walkerNonAnon.currentNode), $("i2").firstChild, "unexpected last node"); 1.93 + testFunc(walkerNonAnon, "previousNode", $("i2"), "step back to second italic"); 1.94 + testFunc(walkerNonAnon, "previousNode", $("i1").nextSibling, 1.95 + "step back to more bold text"); 1.96 + testFunc(walkerNonAnon, "previousNode", $("i1").firstChild, 1.97 + "step back to first italic text"); 1.98 + testFunc(walkerNonAnon, "previousNode", $("i1"), "step back to first italic"); 1.99 + testFunc(walkerNonAnon, "previousNode", $("b").firstChild, 1.100 + "step back to bold text"); 1.101 + testFunc(walkerNonAnon, "previousNode", $("b"), "step back to bold"); 1.102 + testFunc(walkerNonAnon, "previousNode", $("s").nextSibling, "step back to more text"); 1.103 + testFunc(walkerNonAnon, "previousNode", $("s").firstChild, "step back to span text"); 1.104 + testFunc(walkerNonAnon, "previousNode", $("s"), "step back to span"); 1.105 + testFunc(walkerNonAnon, "previousNode", $("s").previousSibling, 1.106 + "step back to some text"); 1.107 + testFunc(walkerNonAnon, "previousNode", $("display"), 1.108 + "step back to root"); 1.109 + testFunc(walkerNonAnon, "previousNode", null, 1.110 + "step back past root"); 1.111 + 1.112 + var anonDiv = SpecialPowers.unwrap(SpecialPowers.wrap(document).getAnonymousNodes($("display")))[0]; 1.113 + 1.114 + var walkerAnon = 1.115 + SpecialPowers.Cc["@mozilla.org/inspector/deep-tree-walker;1"] 1.116 + .createInstance(SpecialPowers.Ci.inIDeepTreeWalker); 1.117 + walkerAnon.showAnonymousContent = true; 1.118 + walkerAnon.init($("display"), NodeFilter.SHOW_ALL); 1.119 + 1.120 + is(SpecialPowers.unwrap(walkerAnon.currentNode), $("display"), "Unexpected anon root"); 1.121 + testFunc(walkerAnon, "nextNode", anonDiv, 1.122 + "step to anonymous div"); 1.123 + testFunc(walkerAnon, "nextNode", $("s").previousSibling, 1.124 + "step to some text (anon)"); 1.125 + testFunc(walkerAnon, "nextNode", $("s").nextSibling, "step to more text (anon)"); 1.126 + testFunc(walkerAnon, "nextNode", $("b"), "step to bold (anon)"); 1.127 + testFunc(walkerAnon, "nextNode", $("b").firstChild, "step to bold text (anon)"); 1.128 + testFunc(walkerAnon, "nextNode", $("i1"), "step to first italic (anon)"); 1.129 + testFunc(walkerAnon, "nextNode", $("i1").firstChild, 1.130 + "step to first italic text (anon)"); 1.131 + testFunc(walkerAnon, "nextNode", $("i1").nextSibling, 1.132 + "step to more bold text (anon)"); 1.133 + testFunc(walkerAnon, "nextNode", $("i2"), "step to second italic (anon)"); 1.134 + testFunc(walkerAnon, "nextNode", $("i2").firstChild, 1.135 + "step to second italic text (anon)"); 1.136 + testFunc(walkerAnon, "nextNode", $("s"), "step to span (anon)"); 1.137 + testFunc(walkerAnon, "nextNode", $("s").firstChild, "step to span text (anon)"); 1.138 + testFunc(walkerAnon, "nextNode", null, "step past end (anon)"); 1.139 + testFunc(walkerAnon, "parentNode", $("s"), "step up to span (anon)"); 1.140 + testFunc(walkerAnon, "parentNode", $("display"), "step up to display (anon)"); 1.141 + testFunc(walkerAnon, "nextNode", anonDiv, "step to anonymous div again"); 1.142 + testFunc(walkerAnon, "parentNode", $("display"), 1.143 + "step up to display again (anon)"); 1.144 + testFunc(walkerAnon, "parentNode", null, "step up past root (anon)"); 1.145 + testFunc(walkerAnon, "firstChild", anonDiv, 1.146 + "step firstChild to display first child (anon)"); 1.147 + testFunc(walkerAnon, "nextSibling", $("s"), 1.148 + "step nextSibling to span (anon)"); 1.149 + testFunc(walkerAnon, "nextSibling", null, "step nextSibling past end (anon)"); 1.150 + testFunc(walkerAnon, "previousSibling", anonDiv, 1.151 + "step previousSibling to anonymous div"); 1.152 + testFunc(walkerAnon, "previousSibling", null, "step previousSibling past end (anon)"); 1.153 + 1.154 + // Move the walker over to the end 1.155 + while (walkerAnon.nextNode()) { /* do nothing */ } 1.156 + testFunc(walkerAnon, "previousNode", $("s"), "step back to span (anon)"); 1.157 + testFunc(walkerAnon, "previousNode", $("i2").firstChild, 1.158 + "step back to second italic text (anon)"); 1.159 + testFunc(walkerAnon, "previousNode", $("i2"), "step back to second italic (anon)"); 1.160 + testFunc(walkerAnon, "previousNode", $("i1").nextSibling, 1.161 + "step back to more bold text (anon)"); 1.162 + testFunc(walkerAnon, "previousNode", $("i1").firstChild, 1.163 + "step back to first italic text (anon)"); 1.164 + testFunc(walkerAnon, "previousNode", $("i1"), "step back to first italic (anon)"); 1.165 + testFunc(walkerAnon, "previousNode", $("b").firstChild, "step back to bold text (anon)"); 1.166 + testFunc(walkerAnon, "previousNode", $("b"), "step back to bold (anon)"); 1.167 + testFunc(walkerAnon, "previousNode", $("s").nextSibling, "step back to more text (anon)"); 1.168 + testFunc(walkerAnon, "previousNode", $("s").previousSibling, 1.169 + "step back to some text (anon)"); 1.170 + testFunc(walkerAnon, "previousNode", anonDiv, 1.171 + "step back to anonymous div"); 1.172 + testFunc(walkerAnon, "previousNode", $("display"), "step back to root (anon)"); 1.173 + testFunc(walkerAnon, "previousNode", null, "step back past root (anon)"); 1.174 + 1.175 + SimpleTest.finish(); 1.176 +}); 1.177 + 1.178 +]]> 1.179 +</script> 1.180 +</pre> 1.181 +</body> 1.182 +</html>