dom/xbl/test/test_bug398492.xul

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial