|
1 <?xml version="1.0"?> |
|
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
|
3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> |
|
4 <!-- |
|
5 https://bugzilla.mozilla.org/show_bug.cgi?id=398492 |
|
6 --> |
|
7 <window title="Mozilla Bug 398492" |
|
8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
|
9 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> |
|
10 <bindings xmlns="http://www.mozilla.org/xbl"> |
|
11 <binding id="test"> |
|
12 <content> |
|
13 <xul:hbox id="xxx" |
|
14 xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
|
15 <children/> |
|
16 </xul:hbox> |
|
17 </content> |
|
18 </binding> |
|
19 </bindings> |
|
20 |
|
21 <!-- test results are displayed in the html:body --> |
|
22 <body xmlns="http://www.w3.org/1999/xhtml"> |
|
23 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=398492" |
|
24 target="_blank">Mozilla Bug 398492</a> |
|
25 </body> |
|
26 |
|
27 <hbox id="testbox" style="-moz-binding: url(#test)">Text</hbox> |
|
28 |
|
29 <!-- test code goes here --> |
|
30 <script type="application/javascript"><![CDATA[ |
|
31 |
|
32 /** Test for Bug 398492 **/ |
|
33 SimpleTest.waitForExplicitFinish(); |
|
34 |
|
35 function getXBLParent(node) { |
|
36 var utils = Components.classes["@mozilla.org/inspector/dom-utils;1"] |
|
37 .getService(Components.interfaces.inIDOMUtils); |
|
38 return utils.getParentForNode(node, true); |
|
39 } |
|
40 |
|
41 addLoadEvent(function() { |
|
42 var n = $("testbox"); |
|
43 var kid = n.firstChild; |
|
44 var anonKid = document.getAnonymousNodes(n)[0]; |
|
45 is(anonKid instanceof XULElement, true, "Must be a XUL element"); |
|
46 is(anonKid, getXBLParent(kid), "Unexpected anonymous nodes"); |
|
47 |
|
48 var n2 = n.cloneNode(true); |
|
49 var kid2 = n2.firstChild; |
|
50 var anonKid2 = document.getAnonymousNodes(n2)[0]; |
|
51 is(anonKid2 instanceof XULElement, true, |
|
52 "Must be a XUL element after clone"); |
|
53 is(anonKid2, getXBLParent(kid2), |
|
54 "Unexpected anonymous nodes after clone"); |
|
55 |
|
56 var n3 = document.createElement("hbox"); |
|
57 document.documentElement.appendChild(n3); |
|
58 var kid3 = document.createTextNode("Text"); |
|
59 n3.appendChild(kid3); |
|
60 |
|
61 // Note - we rely on the fact that the binding is preloaded |
|
62 // by the other hbox here, so that the binding will be applied |
|
63 // sync. |
|
64 n3.style.MozBinding = "url(" + document.location.href + "#test)"; |
|
65 n3.getBoundingClientRect(); // Flush styles. |
|
66 |
|
67 var anonKid3 = document.getAnonymousNodes(n3)[0]; |
|
68 is(anonKid3 instanceof XULElement, true, |
|
69 "Must be a XUL element after addBinding"); |
|
70 is(anonKid3, getXBLParent(kid3), |
|
71 "Unexpected anonymous nodes after addBinding"); |
|
72 |
|
73 |
|
74 n.removeChild(kid); |
|
75 isnot(anonKid, getXBLParent(kid), |
|
76 "Should have removed kid from insertion point"); |
|
77 |
|
78 n2.removeChild(kid2); |
|
79 isnot(anonKid2, getXBLParent(kid2), |
|
80 "Should have removed kid2 from insertion point"); |
|
81 |
|
82 n3.removeChild(kid3); |
|
83 isnot(anonKid3, getXBLParent(kid3), |
|
84 "Should have removed kid3 from insertion point"); |
|
85 |
|
86 SimpleTest.finish(); |
|
87 }); |
|
88 |
|
89 |
|
90 ]]></script> |
|
91 </window> |