1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/xbl/test/test_bug398492.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,91 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> 1.7 +<!-- 1.8 +https://bugzilla.mozilla.org/show_bug.cgi?id=398492 1.9 +--> 1.10 +<window title="Mozilla Bug 398492" 1.11 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.12 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> 1.13 + <bindings xmlns="http://www.mozilla.org/xbl"> 1.14 + <binding id="test"> 1.15 + <content> 1.16 + <xul:hbox id="xxx" 1.17 + xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.18 + <children/> 1.19 + </xul:hbox> 1.20 + </content> 1.21 + </binding> 1.22 + </bindings> 1.23 + 1.24 + <!-- test results are displayed in the html:body --> 1.25 + <body xmlns="http://www.w3.org/1999/xhtml"> 1.26 + <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=398492" 1.27 + target="_blank">Mozilla Bug 398492</a> 1.28 + </body> 1.29 + 1.30 + <hbox id="testbox" style="-moz-binding: url(#test)">Text</hbox> 1.31 + 1.32 + <!-- test code goes here --> 1.33 + <script type="application/javascript"><![CDATA[ 1.34 + 1.35 + /** Test for Bug 398492 **/ 1.36 + SimpleTest.waitForExplicitFinish(); 1.37 + 1.38 + function getXBLParent(node) { 1.39 + var utils = Components.classes["@mozilla.org/inspector/dom-utils;1"] 1.40 + .getService(Components.interfaces.inIDOMUtils); 1.41 + return utils.getParentForNode(node, true); 1.42 + } 1.43 + 1.44 + addLoadEvent(function() { 1.45 + var n = $("testbox"); 1.46 + var kid = n.firstChild; 1.47 + var anonKid = document.getAnonymousNodes(n)[0]; 1.48 + is(anonKid instanceof XULElement, true, "Must be a XUL element"); 1.49 + is(anonKid, getXBLParent(kid), "Unexpected anonymous nodes"); 1.50 + 1.51 + var n2 = n.cloneNode(true); 1.52 + var kid2 = n2.firstChild; 1.53 + var anonKid2 = document.getAnonymousNodes(n2)[0]; 1.54 + is(anonKid2 instanceof XULElement, true, 1.55 + "Must be a XUL element after clone"); 1.56 + is(anonKid2, getXBLParent(kid2), 1.57 + "Unexpected anonymous nodes after clone"); 1.58 + 1.59 + var n3 = document.createElement("hbox"); 1.60 + document.documentElement.appendChild(n3); 1.61 + var kid3 = document.createTextNode("Text"); 1.62 + n3.appendChild(kid3); 1.63 + 1.64 + // Note - we rely on the fact that the binding is preloaded 1.65 + // by the other hbox here, so that the binding will be applied 1.66 + // sync. 1.67 + n3.style.MozBinding = "url(" + document.location.href + "#test)"; 1.68 + n3.getBoundingClientRect(); // Flush styles. 1.69 + 1.70 + var anonKid3 = document.getAnonymousNodes(n3)[0]; 1.71 + is(anonKid3 instanceof XULElement, true, 1.72 + "Must be a XUL element after addBinding"); 1.73 + is(anonKid3, getXBLParent(kid3), 1.74 + "Unexpected anonymous nodes after addBinding"); 1.75 + 1.76 + 1.77 + n.removeChild(kid); 1.78 + isnot(anonKid, getXBLParent(kid), 1.79 + "Should have removed kid from insertion point"); 1.80 + 1.81 + n2.removeChild(kid2); 1.82 + isnot(anonKid2, getXBLParent(kid2), 1.83 + "Should have removed kid2 from insertion point"); 1.84 + 1.85 + n3.removeChild(kid3); 1.86 + isnot(anonKid3, getXBLParent(kid3), 1.87 + "Should have removed kid3 from insertion point"); 1.88 + 1.89 + SimpleTest.finish(); 1.90 + }); 1.91 + 1.92 + 1.93 + ]]></script> 1.94 +</window>