Bug 912322 - Fix tests. r=bz
authorBobby Holley <bobbyholley@gmail.com>
Fri, 06 Sep 2013 09:12:56 -0700
changeset 153943 cc6d2facb9874908f6d4aa22e4b5b5e40c23e509
parent 153942 b0d98d8b93e5ff35c76d767b24aaf12bf165f0de
child 153944 b70ce5b872c1c9470a897629a685c3e09c8f4f73
push idunknown
push userunknown
push dateunknown
reviewersbz
bugs912322
milestone26.0a1
Bug 912322 - Fix tests. r=bz The crashtest changes are untested (aside from the fact that they don't crash).
content/base/crashtests/308120-1.xul
content/base/crashtests/330925-1.xhtml
content/base/crashtests/401993-1.html
content/base/test/test_base.xhtml
content/base/test/test_bug330925.xhtml
content/base/test/test_bug372086.html
content/base/test/test_bug444030.xhtml
content/html/content/crashtests/465466-1.xhtml
content/xbl/crashtests/472260-1.xhtml
content/xbl/test/file_bug379959_cross.html
content/xbl/test/file_bug379959_data.html
content/xbl/test/file_bug591198_inner.html
content/xbl/test/test_bug378866.xhtml
content/xbl/test/test_bug468210.xhtml
content/xslt/tests/mochitest/test_bug319374.xhtml
content/xul/content/crashtests/326864-1.xul
content/xul/content/crashtests/384740-1.xul
dom/base/crashtests/404869-1.xul
dom/indexedDB/test/head.js
js/xpconnect/crashtests/471366-1.html
layout/base/crashtests/379105-1.xhtml
layout/inspector/tests/test_bug522601.xhtml
layout/reftests/bugs/495385-2f.xhtml
layout/reftests/bugs/reftest.list
layout/style/test/test_selectors_on_anonymous_content.html
layout/xul/base/src/crashtests/328135-1.xul
layout/xul/base/src/crashtests/329477-1.xhtml
toolkit/content/tests/widgets/test_popupanchor.xul
--- a/content/base/crashtests/308120-1.xul
+++ b/content/base/crashtests/308120-1.xul
@@ -1,3 +1,3 @@
-<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="var button=document.getElementsByTagName('button')[0]; try { button.appendChild(document.getAnonymousNodes(button)[0]); } catch(e) { }">
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="var button=document.getElementsByTagName('button')[0]; try { button.appendChild(SpecialPowers.unwrap(SpecialPowers.wrap(document).getAnonymousNodes(button))[0]); } catch(e) { }">
   <button/>
 </window>
--- a/content/base/crashtests/330925-1.xhtml
+++ b/content/base/crashtests/330925-1.xhtml
@@ -5,17 +5,17 @@
 <script>
 
 function init()
 {
   var foopy = document.getElementById("foopy");
   var emb = document.getElementById("emb");
 
   try {  
-    foopy.appendChild(document.getAnonymousNodes(emb)[0]);
+    foopy.appendChild(SpecialPowers.unwrap(SpecialPowers.wrap(document).getAnonymousNodes(emb))[0]);
     emb.parentNode.removeChild(emb);
     foopy.parentNode.removeChild(foopy);
   } catch (e) {
   }
   
   document.documentElement.removeAttribute("class");
 }
 
--- a/content/base/crashtests/401993-1.html
+++ b/content/base/crashtests/401993-1.html
@@ -6,17 +6,17 @@ function s()
 {
   var x = document.getElementById("x");
   x.style.MozBinding = "url(401993-1.xml#foo)";
   
   setTimeout(boom, 0);
   
   function boom()
   {
-    var nodes = document.getAnonymousNodes(x);
+    var nodes = SpecialPowers.unwrap(SpecialPowers.wrap(document).getAnonymousNodes(x));
     if (!nodes) {
       setTimeout(boom, 10);
       return;
     }
 
     var newSpan = document.createElement("span");
     newSpan.contentEditable = "true";
     nodes[0].appendChild(newSpan);
--- a/content/base/test/test_base.xhtml
+++ b/content/base/test/test_base.xhtml
@@ -35,17 +35,17 @@ addLoadEvent(function() {
   }
   is(expected.length, 0, "found all expected nodes");
 
   var svgExpected =
     ["http://mochi.test:8888/tests/content/base/test/file_base_xbl.xml",
      "http://mochi.test:8888/tests/content/base/test/file_base_xbl.xml",
      "http://mochi.test:8888/tests/content/base/test/file_base_xbl.xml#shesellsseashellsbytheseashore",
      ];
-  node = document.getAnonymousNodes(document.getElementById("bound"))[0];
+  node = SpecialPowers.unwrap(SpecialPowers.wrap(document).getAnonymousNodes(document.getElementById("bound")))[0];
   while(node) {
     is(node.baseURI, svgExpected.shift(), "node base");
     node = node.firstChild;
   }
   is(svgExpected.length, 0, "found all expected nodes");
 
   SimpleTest.finish();
 });
--- a/content/base/test/test_bug330925.xhtml
+++ b/content/base/test/test_bug330925.xhtml
@@ -41,30 +41,31 @@ xbl textnode2
 
 // We have to wait until onload because XBL doesn't bind immediately.
 SimpleTest.waitForExplicitFinish();
 addLoadEvent(init);
 
 function init()
 {
   var t = document.getElementById("t");
+  var d = SpecialPowers.wrap(document);
 
-  is(document.getBindingParent(document.getAnonymousNodes(t)[0]), 
+  is(SpecialPowers.unwrap(d.getBindingParent(d.getAnonymousNodes(t)[0])),
      t,
      "Wrong binding parent for anonymous node");
      
-  is(document.getBindingParent(document.getAnonymousNodes(t)[1].childNodes[0]), 
+  is(SpecialPowers.unwrap(d.getBindingParent(d.getAnonymousNodes(t)[1].childNodes[0])),
      t,
      "Wrong binding parent for child of anonymous node");
      
-  is(document.getBindingParent(t), 
+  is(d.getBindingParent(t), 
      null,
      "Non-anonymous node should not have a binding parent");
      
-  is(document.getBindingParent(document.documentElement), 
+  is(d.getBindingParent(document.documentElement), 
      null,
      "Document element should not have a binding parent");
      
   SimpleTest.finish();
 }
 
 ]]>
 </script>
--- a/content/base/test/test_bug372086.html
+++ b/content/base/test/test_bug372086.html
@@ -37,34 +37,34 @@ function runTest() {
   range.setStart(c, 1);
   range.setEnd(c, 3);
   is(range.startContainer, c, "Unexpected start container");
   is(range.startOffset, 1, "Unexpected start offset");
   is(range.endContainer, c, "Unexpected end container");
   is(range.endOffset, 3, "Unexpected end offset");
   is(range.toString(), "bc", "Unexpected range serialization");
 
-  var anon = document.getAnonymousNodes($("d"))[0];
+  var anon = SpecialPowers.unwrap(SpecialPowers.wrap(document).getAnonymousNodes($("d")))[0];
   // Should collapse the range, because can't determine order
   range.setEnd(anon, 2);
   is(range.startContainer, anon, "Unexpected collapsed start container");
   is(range.startOffset, 2, "Unexpected collapsed start offset");
   is(range.endContainer, anon, "Unexpected collapsed end container");
   is(range.endOffset, 2, "Unexpected collapsed end offset");
   is(range.toString(), "", "Unexpected collapsed range serialization");
 
   range.setEnd(a, 2);
   range.setStart(a, 0);
   is(range.startContainer, a, "Unexpected start container after");
   is(range.startOffset, 0, "Unexpected start offset after");
   is(range.endContainer, a, "Unexpected end container after");
   is(range.endOffset, 2, "Unexpected end offset after");
   is(range.toString(), "de", "Unexpected range serialization after");
 
-  anon = document.getAnonymousNodes($("d"))[2];
+  anon = SpecialPowers.unwrap(SpecialPowers.wrap(document).getAnonymousNodes($("d")))[2];
   // Collapses because one endpoint is anonymous from point of view of
   // the other.  
   range.setStart(anon, 1);
   is(range.startContainer, anon, "Unexpected newly collapsed start container");
   is(range.startOffset, 1, "Unexpected newly collapsed start offset");
   is(range.endContainer, anon, "Unexpected newly collapsed end container");
   is(range.endOffset, 1, "Unexpected newly collapsed end offset");
   is(range.toString(), "", "Unexpected collapsed range serialization");
--- a/content/base/test/test_bug444030.xhtml
+++ b/content/base/test/test_bug444030.xhtml
@@ -21,17 +21,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 <![CDATA[
 
 /** Test for Bug 444030 **/
 
 function doTest() {
-  var anonTextNode = document.getAnonymousNodes(document.getElementById("boundElement"))[0];
+  var anonTextNode = SpecialPowers.unwrap(SpecialPowers.wrap(document).getAnonymousNodes(document.getElementById("boundElement")))[0];
   var hadException = false;
   try {
     var wholeText = anonTextNode.wholeText;
   } catch(e) {
     hadException = true;
   }
   ok(hadException,
      "Should have got an exception when using .wholeText with a text node child of the binding parent");
--- a/content/html/content/crashtests/465466-1.xhtml
+++ b/content/html/content/crashtests/465466-1.xhtml
@@ -6,17 +6,17 @@
 </binding></bindings>
 
 
 <script type="text/javascript">
 
 function boom()
 {
   var f = document.getElementById("f");
-  var anon = document.getAnonymousNodes(f)[0];
+  var anon = SpecialPowers.unwrap(SpecialPowers.wrap(document).getAnonymousNodes(f))[0];
   document.body.removeChild(f);
   anon.appendChild(document.createElement("label"));
 }
 
 </script>
 </head>
 
 <body onload="boom();"><form id="f" style="-moz-binding: url(#u);"><label></label></form></body>
--- a/content/xbl/crashtests/472260-1.xhtml
+++ b/content/xbl/crashtests/472260-1.xhtml
@@ -7,17 +7,17 @@
 </bindings>
 
 <script type="text/javascript">
 // <![CDATA[
 
 function boom()
 {
   var bo = document.getElementById("bo");
-  var anon = document.getAnonymousNodes(bo)[0];
+  var anon = SpecialPowers.wrap(document).getAnonymousNodes(bo)[0];
 
   bo.style.MozBinding = "url(#bar)";
 
   var fr = document.createElementNS("http://www.w3.org/1999/xhtml", "iframe");
   fr.setAttribute("src", "javascript:void 0;"); 
   anon.appendChild(fr);
   
   document.documentElement.removeAttribute("class");
--- a/content/xbl/test/file_bug379959_cross.html
+++ b/content/xbl/test/file_bug379959_cross.html
@@ -11,15 +11,15 @@
   -moz-binding: url(http://example.com/tests/content/xbl/test/file_bug379959_xbl.xml#xbltest);
 }
 </style>
 <body>
 <div id="div1"></div>
 <div id="div2"></div>
 <script>
 onload = function() {
-  nodes = document.getAnonymousNodes(document.getElementById('div1'));
+  nodes = SpecialPowers.wrap(document).getAnonymousNodes(document.getElementById('div1'));
   parent.postMessage(nodes ? nodes.length : 0, "http://mochi.test:8888");
-  nodes = document.getAnonymousNodes(document.getElementById('div2'));
+  nodes = SpecialPowers.wrap(document).getAnonymousNodes(document.getElementById('div2'));
   parent.postMessage(nodes ? nodes.length : 0, "http://mochi.test:8888");
 }
 </script>
 </html>
--- a/content/xbl/test/file_bug379959_data.html
+++ b/content/xbl/test/file_bug379959_data.html
@@ -6,13 +6,13 @@
   color: green;
   -moz-binding: url(data:text/xml;charset=utf-8,%3C%3Fxml%20version%3D%221.0%22%3F%3E%0A%3Cbindings%20id%3D%22xbltestBindings%22%20xmlns%3D%22http%3A//www.mozilla.org/xbl%22%3E%0A%20%20%3Cbinding%20id%3D%22xbltest%22%3E%3Ccontent%3EPASS%3C/content%3E%3C/binding%3E%0A%3C/bindings%3E%0A);
 }
 </style>
 <body>
 <div id="d"></div>
 <script>
 onload = function() {
-  nodes = document.getAnonymousNodes(document.getElementById('d'));
+  nodes = SpecialPowers.wrap(document).getAnonymousNodes(document.getElementById('d'));
   parent.postMessage(nodes ? nodes.length : 0, "http://mochi.test:8888");
 }
 </script>
 </html>
--- a/content/xbl/test/file_bug591198_inner.html
+++ b/content/xbl/test/file_bug591198_inner.html
@@ -17,17 +17,17 @@ function sendResults() {
 
   ps = document.getElementsByTagName('span');
   for (var i = 0; i < ps.length; i++) {
     res.widths.push(ps[i].offsetWidth);
   }
   
   try {
     res.anonChildCount =
-      document.getAnonymousNodes(document.getElementById('b')).length;
+      SpecialPowers.wrap(document).getAnonymousNodes(document.getElementById('b')).length;
   }
   catch (ex) {}
 
   parent.postMessage(JSON.stringify(res), "*");
 }
     </script>
   </head>
   <body onload="sendResults();">
--- a/content/xbl/test/test_bug378866.xhtml
+++ b/content/xbl/test/test_bug378866.xhtml
@@ -28,17 +28,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 <![CDATA[
 
 /** Test for Bug 378866 **/
 
 function runTest() {
-  var anon = document.getAnonymousNodes(document.getElementById('grandparent'));
+  var anon = SpecialPowers.unwrap(SpecialPowers.wrap(document).getAnonymousNodes(document.getElementById('grandparent')));
   var child = document.getElementById('child');
   var insertionPoint = anon[0].childNodes[0];
   insertionPoint.parentNode.removeChild(insertionPoint);
   child.appendChild(insertionPoint);
 
   var e = document.createEvent("Event");
   e.initEvent("foo", true, true);
   child.dispatchEvent(e);
--- a/content/xbl/test/test_bug468210.xhtml
+++ b/content/xbl/test/test_bug468210.xhtml
@@ -27,17 +27,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 <![CDATA[
 
 /** Test for Bug 468210 **/
 SimpleTest.waitForExplicitFinish();
 addLoadEvent(function() {
   var div = $("d");
   var n = document.anchors.length;
   is(n, 1, "Unexpected number of anchors");
-  var anon = document.getAnonymousNodes(div)[0];
+  var anon = SpecialPowers.unwrap(SpecialPowers.wrap(document).getAnonymousNodes(div))[0];
   is(anon instanceof HTMLSpanElement, true, "Unexpected node");
   is(anon.parentNode, div, "Unexpected parent");
   document.body.appendChild(div);
   is(anon.parentNode, null, "Parent should have become null");
   // An attr set to test notifications
   anon.setAttribute("h", "i");
 });
 addLoadEvent(SimpleTest.finish);
--- a/content/xslt/tests/mochitest/test_bug319374.xhtml
+++ b/content/xslt/tests/mochitest/test_bug319374.xhtml
@@ -26,45 +26,48 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 /** Test for Bug 319374 **/
 
   function testChangesInAnonymousTree() {
     // Test 1: Make sure that modifying anonymous content doesn't 
     //         cause non-anonymous XPath result to throw exceptions..
     var counter = 0;
     var error = null;
+    function getAnonymousNodes(e) {
+      return SpecialPowers.unwrap(SpecialPowers.wrap(document).getAnonymousNodes(e));
+    }
     try {
       var xp = new XPathEvaluator();
       var result = xp.evaluate("*",
                                document.getElementById('content'),
                                null,
                                SpecialPowers.Ci.nsIDOMXPathResult.
                                  UNORDERED_NODE_ITERATOR_TYPE,
                                null);
       var res = null;
       while (res = result.iterateNext()) {
         ++counter; 
-        var anon = document.getAnonymousNodes(res);
+        var anon = getAnonymousNodes(res);
         anon[0].removeChild(anon[0].firstChild); // Removing a child node
         anon[0].removeAttribute("attr1"); // Removing an attribute
         anon[1].firstChild.data = "anon text changed" // Modifying text data
       }
     } catch (e) {
       error = e;
     }
     ok(!error, error);
     ok(counter == 3, "XPathEvaluator should have found 3 elements.")
 
     // Test 2: If the context node is in anonymous content, changing some
     //         other anonymous tree shouldn't cause XPath result to throw.
     var anonAttr1 =
-      document.getAnonymousNodes(document.getElementById('content').
+      getAnonymousNodes(document.getElementById('content').
         firstChild)[0].getAttributeNode('attr');
     var anonAttr2 =
-      document.getAnonymousNodes(document.getElementById('content').
+      getAnonymousNodes(document.getElementById('content').
         lastChild)[0].getAttributeNode('attr');
     var resultAttr = null;
     try {
       var xp2 = xp.evaluate(".",
                             anonAttr1,
                             null,
                             SpecialPowers.Ci.nsIDOMXPathResult.
                               UNORDERED_NODE_ITERATOR_TYPE,
--- a/content/xul/content/crashtests/326864-1.xul
+++ b/content/xul/content/crashtests/326864-1.xul
@@ -1,23 +1,27 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
 
 <script>
 
+function getAnonymousNodes(e) {
+  return SpecialPowers.unwrap(SpecialPowers.wrap(document).getAnonymousNodes(e));
+}
+
 function init()
 {
   var tt = document.getElementById("textbox");
-  var hb = document.getAnonymousNodes(tt)[0]; // hbox
-  var men = document.getAnonymousNodes(hb)[1]; // menupopup
+  var hb = getAnonymousNodes(tt)[0]; // hbox
+  var men = getAnonymousNodes(hb)[1]; // menupopup
   var menitem = men.childNodes[0]; // menuitem
-  var hb2 = document.getAnonymousNodes(menitem)[1]; // hbox
+  var hb2 = getAnonymousNodes(menitem)[1]; // hbox
   var label2 = hb2.childNodes[0]; // label
 
   men.menu = null;
   label2.click();
 }
 
 window.addEventListener("load", init, false);
 
--- a/content/xul/content/crashtests/384740-1.xul
+++ b/content/xul/content/crashtests/384740-1.xul
@@ -7,17 +7,17 @@
 <script>
 
 function boom()
 {
   var XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 
   var scrollbar = document.createElementNS(XUL_NS, 'scrollbar');
   document.documentElement.appendChild(scrollbar);
-  var sbb = document.getAnonymousNodes(scrollbar)[0];
+  var sbb = SpecialPowers.unwrap(SpecialPowers.wrap(document).getAnonymousNodes(scrollbar))[0];
   var action = document.createElementNS(XUL_NS, 'action');
   action.setAttribute('datasources', "");
   sbb.appendChild(action);
 }
 
 </script>
 
 </window>
--- a/dom/base/crashtests/404869-1.xul
+++ b/dom/base/crashtests/404869-1.xul
@@ -5,17 +5,17 @@
   <binding id="empty"><content></content></binding>
 </bindings>
 
 <script type="text/javascript">
 
 function boom()
 {
   var menupopup = document.getElementById("menupopup");
-  var x = document.getAnonymousNodes(menupopup)[0];
+  var x = SpecialPowers.wrap(document).getAnonymousNodes(menupopup)[0];
   menupopup.style.MozBinding = "url('#empty')";
   for (var ppp in x) {
   }
 }
 
 </script>
 
 <menupopup id="menupopup"/>
--- a/dom/indexedDB/test/head.js
+++ b/dom/indexedDB/test/head.js
@@ -55,17 +55,17 @@ function triggerSecondaryCommand(popup, 
 {
   info("triggering secondary command, " + index);
   let notifications = popup.childNodes;
   ok(notifications.length > 0, "at least one notification displayed");
   let notification = notifications[0];
 
   // Cancel the arrow panel slide-in transition (bug 767133) such that
   // it won't interfere with us interacting with the dropdown.
-  document.getAnonymousNodes(popup)[0].style.transition = "none";
+  SpecialPowers.wrap(document).getAnonymousNodes(popup)[0].style.transition = "none";
 
   notification.button.focus();
 
   popup.addEventListener("popupshown", function () {
     popup.removeEventListener("popupshown", arguments.callee, false);
 
     // Press down until the desired command is selected
     for (let i = 0; i <= index; i++)
--- a/js/xpconnect/crashtests/471366-1.html
+++ b/js/xpconnect/crashtests/471366-1.html
@@ -1,12 +1,12 @@
 <!DOCTYPE html>
 <html>
 <head>
 <script type="text/javascript">
 
-document.getAnonymousNodes({__proto__: XPCNativeWrapper.prototype});
+SpecialPowers.wrap(document).getAnonymousNodes({__proto__: XPCNativeWrapper.prototype});
 
 </script>
 </head>
 <body>
 </body>
 </html>
--- a/layout/base/crashtests/379105-1.xhtml
+++ b/layout/base/crashtests/379105-1.xhtml
@@ -20,17 +20,17 @@ function boom1()
 {
   xbltarget = document.getElementById("xbltarget");
   xbltarget.style.MozBinding = "url('#x')";
   setTimeout(boom2, 0);
 }
 
 function boom2()
 {
-  var nodes = document.getAnonymousNodes(xbltarget);
+  var nodes = SpecialPowers.unwrap(SpecialPowers.wrap(document).getAnonymousNodes(xbltarget));
   if (!nodes) {
     setTimeout(boom2, 10);
     return;
   }
   var anox = nodes[0];
   var frame = document.createElementNS("http://www.w3.org/1999/xhtml", "frame")
   frame.src = "data:text/html,<html><body>Hi!</body></html>";
   anox.appendChild(frame);
--- a/layout/inspector/tests/test_bug522601.xhtml
+++ b/layout/inspector/tests/test_bug522601.xhtml
@@ -101,17 +101,17 @@ addLoadEvent(function() {
   testFunc(walkerNonAnon, "previousNode", $("s"), "step back to span");
   testFunc(walkerNonAnon, "previousNode", $("s").previousSibling,
            "step back to some text");
   testFunc(walkerNonAnon, "previousNode", $("display"),
            "step back to root");
   testFunc(walkerNonAnon, "previousNode", null,
            "step back past root");
 
-  var anonDiv = document.getAnonymousNodes($("display"))[0];
+  var anonDiv = SpecialPowers.unwrap(SpecialPowers.wrap(document).getAnonymousNodes($("display")))[0];
 
   var walkerAnon =
     SpecialPowers.Cc["@mozilla.org/inspector/deep-tree-walker;1"]
               .createInstance(SpecialPowers.Ci.inIDeepTreeWalker);
   walkerAnon.showAnonymousContent = true;
   walkerAnon.init($("display"), NodeFilter.SHOW_ALL);
 
   is(SpecialPowers.unwrap(walkerAnon.currentNode), $("display"), "Unexpected anon root");
--- a/layout/reftests/bugs/495385-2f.xhtml
+++ b/layout/reftests/bugs/495385-2f.xhtml
@@ -8,31 +8,41 @@
   <binding id="after">
     <content><children/>Kitty</content>
   </binding>
   <binding id="empty1">
     <content><div xmlns="http://www.w3.org/1999/xhtml">Hello</div><children/></content>
   </binding>
   <binding id="empty2">
     <content><children/><div xmlns="http://www.w3.org/1999/xhtml">Kitty</div></content>
+    <implementation>
+      <constructor>
+        // We used to do this in an onload handler, but getAnonymousNodes is no
+        // longer accessible to content, and we can't use SpecialPowers in
+        // reftests. So we enable XBL scopes and take advantage of the fact that XBL
+        // scopes can access these functions. We apply this binding
+        // programatically to make absolutely sure this constructor runs after all the
+        // other bindings have been set up.
+        document.body.offsetHeight;
+        document.getAnonymousNodes(document.getElementById("d3"))[0].style.display = 'inline';
+        document.getAnonymousNodes(document.getElementById("d4"))[2].style.display = 'inline';
+      </constructor>
+    </implementation>
   </binding>
 </bindings>
 <style>
 body > div { border:1px solid black; margin:1em;
              font-family:sans-serif; letter-spacing:2px; }
 #d1 { -moz-binding:url(#before); }
 #d2 { -moz-binding:url(#after); }
 #d3 { -moz-binding:url(#empty1); }
-#d4 { -moz-binding:url(#empty2); }
 </style>
 <script>
 function loaded() {
-  document.body.offsetHeight;
-  document.getAnonymousNodes(document.getElementById("d3"))[0].style.display = 'inline';
-  document.getAnonymousNodes(document.getElementById("d4"))[2].style.display = 'inline';
+  document.getElementById('d4').style.MozBinding = "url(#empty2)";
 }
 </script>
 </head>
 <body onload="loaded()">
   <div id="d1"> <span>Kitty</span></div>
   <div id="d2"><span>Hello</span> </div>
   <div id="d3"> <span>Kitty</span></div>
   <div id="d4"><span>Hello</span> </div>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -1365,17 +1365,17 @@ fails-if(Android) == 488685-1.html 48868
 == 495385-1d.html 495385-1-ref.html
 == 495385-1e.html 495385-1-ref.html
 == 495385-1f.html 495385-1-ref.html
 == 495385-2a.html 495385-2-ref.html
 == 495385-2b.html 495385-2-ref.html
 == 495385-2c.html 495385-2-ref.html
 == 495385-2d.html 495385-2-ref.html
 == 495385-2e.html 495385-2-ref.html
-== 495385-2f.xhtml 495385-2-ref.html
+pref(dom.use_xbl_scopes_for_remote_xul,true) == 495385-2f.xhtml 495385-2-ref.html
 == 495385-2g.html 495385-2-ref.html
 == 495385-2h.html 495385-2-ref.html
 == 495385-2i.html 495385-2-ref.html
 == 495385-3.html 495385-3-ref.html
 == 495385-4.html 495385-4-ref.html
 == 495385-5.html 495385-5-ref.html
 asserts(1) == 496032-1.html 496032-1-ref.html # bug 399262
 == 496840-1.html 496840-1-ref.html
--- a/layout/style/test/test_selectors_on_anonymous_content.html
+++ b/layout/style/test/test_selectors_on_anonymous_content.html
@@ -37,17 +37,17 @@ function run() {
     var gCounter = 0;
 
     function test_selector(selector, matches_docdiv, matches_anondiv)
     {
         var zi = ++gCounter;
         style_text.data = selector + "{ z-index: " + zi + " }";
 
         var doc_div = document.getElementById("display");
-        var anon_div = document.getAnonymousNodes(doc_div)[0];
+        var anon_div = SpecialPowers.unwrap(SpecialPowers.wrap(document).getAnonymousNodes(doc_div))[0];
         var should_match = [];
         var should_not_match = [];
         (matches_docdiv ? should_match : should_not_match).push(doc_div);
         (matches_anondiv ? should_match : should_not_match).push(anon_div);
 
         for (var i = 0; i < should_match.length; ++i) {
             var e = should_match[i];
             is(getComputedStyle(e, "").zIndex, zi,
--- a/layout/xul/base/src/crashtests/328135-1.xul
+++ b/layout/xul/base/src/crashtests/328135-1.xul
@@ -4,17 +4,17 @@
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
 
 
 <script>
 
 function init() { 
   var pop = document.getElementsByTagName("popup")[0];
-  document.getAnonymousNodes(pop)[0];
+  SpecialPowers.wrap(document).getAnonymousNodes(pop)[0];
   eval.eee = document.documentElement;
 };
 
 
 window.addEventListener("load", init, false);
 
 </script>
 
--- a/layout/xul/base/src/crashtests/329477-1.xhtml
+++ b/layout/xul/base/src/crashtests/329477-1.xhtml
@@ -4,18 +4,18 @@
 <script>
 
 <![CDATA[
 
 
 function init() 
 { 
   var textbox = document.getElementsByTagName("textbox")[0];
-  var hbox = document.getAnonymousNodes(textbox)[0];
-  var menupopup = document.getAnonymousNodes(hbox)[1];
+  var hbox = SpecialPowers.wrap(document).getAnonymousNodes(textbox)[0];
+  var menupopup = SpecialPowers.wrap(document).getAnonymousNodes(hbox)[1];
 
   menupopup.click();
 }
 
 window.addEventListener("load", init, false);
 
 ]]>
 </script>
--- a/toolkit/content/tests/widgets/test_popupanchor.xul
+++ b/toolkit/content/tests/widgets/test_popupanchor.xul
@@ -378,17 +378,17 @@ function runTests() {
   runNextTest();
 }
 
 SimpleTest.waitForExplicitFinish();
 
 addEventListener("load", function() {
   // anchor is set by the test runner above
   panel = document.getElementById("testPanel");
-  arrow = document.getAnonymousElementByAttribute(panel, "anonid", "arrow");
+  arrow = SpecialPowers.wrap(document).getAnonymousElementByAttribute(panel, "anonid", "arrow");
   // Cancel the arrow panel slide-in transition (bug 767133) so the size and
   // position are "stable" enough to test without jumping through hoops...
   arrow.style.transition = "none";
   runTests();
 });
 
 ]]>
 </script>