|
1 <html xmlns="http://www.w3.org/1999/xhtml"> |
|
2 <!-- |
|
3 https://bugzilla.mozilla.org/show_bug.cgi?id=609549 |
|
4 --> |
|
5 <head> |
|
6 <title>Test for Bug 609549</title> |
|
7 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
8 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
9 |
|
10 <bindings xmlns="http://www.mozilla.org/xbl"> |
|
11 <binding id="testBinding"> |
|
12 <!-- No linebreaks since this is html and whitespace is preserved. --> |
|
13 <content><div anonid="box-A">x</div><div anonid="box-B"><children includes="span"/></div><div anonid="box-C">x</div><children/></content> |
|
14 </binding> |
|
15 </bindings> |
|
16 </head> |
|
17 |
|
18 <body> |
|
19 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=609549">Mozilla Bug 609549</a> |
|
20 <div id="bound" style="-moz-binding: url(#testBinding);"><p id="p">lorem ipsum dolor sit amet</p><span id="sandwiched">sandwiched</span></div> |
|
21 |
|
22 <div id="content" style="display: none"> |
|
23 |
|
24 </div> |
|
25 <pre id="test"> |
|
26 <script type="application/javascript"> |
|
27 <![CDATA[ |
|
28 |
|
29 /** Test for Bug 609549 **/ |
|
30 SimpleTest.waitForExplicitFinish(); |
|
31 |
|
32 addLoadEvent(function() { |
|
33 var domUtils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]. |
|
34 getService(SpecialPowers.Ci.inIDOMUtils); |
|
35 ok("getChildrenForNode" in domUtils, "domUtils has no getChildrenForNode"); |
|
36 var withoutAnons = SpecialPowers.unwrap(domUtils.getChildrenForNode($("bound"), false)); |
|
37 |
|
38 is(withoutAnons.length, $("bound").childNodes.length, |
|
39 "withoutAnons should be the same length as childNodes"); |
|
40 is(withoutAnons[0], $("p"), "didn't get paragraph - without anons"); |
|
41 is(withoutAnons[1], $("sandwiched"), |
|
42 "didn't get sandwiched span - without anons"); |
|
43 |
|
44 var withAnons = domUtils.getChildrenForNode($("bound"), true); |
|
45 |
|
46 is(withAnons.length, 4, "bad withAnons.length"); |
|
47 is(withAnons[0].getAttribute("anonid"), "box-A", |
|
48 "didn't get anonymous box-A"); |
|
49 is(withAnons[1].getAttribute("anonid"), "box-B", |
|
50 "didn't get anonymous box-B"); |
|
51 is(withAnons[2].getAttribute("anonid"), "box-C", |
|
52 "didn't get anonymous box-C"); |
|
53 is(withAnons[3].id, "p", "didn't get paragraph - with anons"); |
|
54 |
|
55 var bKids = domUtils.getChildrenForNode(withAnons[1], true); |
|
56 is(bKids.length, 1, "bKids.length is bad"); |
|
57 is(SpecialPowers.unwrap(bKids[0]), $("sandwiched"), |
|
58 "didn't get sandwiched span inserted into box-B"); |
|
59 |
|
60 SimpleTest.finish(); |
|
61 }); |
|
62 |
|
63 ]]> |
|
64 </script> |
|
65 </pre> |
|
66 </body> |
|
67 </html> |