commit 5cd158557d04d3918b9911f624777a3f44fb1007 Author: Bobby Holley bobbyholley@gmail.com Date: Mon Feb 10 14:07:27 2014 -0800
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 | 2 +- content/base/crashtests/330925-1.xhtml | 2 +- content/base/crashtests/401993-1.html | 2 +- content/base/test/test_base.xhtml | 2 +- content/base/test/test_bug330925.xhtml | 9 +++++---- content/base/test/test_bug372086.html | 4 ++-- content/base/test/test_bug444030.xhtml | 2 +- content/html/content/crashtests/465466-1.xhtml | 2 +- content/xbl/crashtests/472260-1.xhtml | 2 +- content/xbl/test/file_bug379959_cross.html | 4 ++-- content/xbl/test/file_bug379959_data.html | 2 +- content/xbl/test/file_bug591198_inner.html | 2 +- content/xbl/test/test_bug378866.xhtml | 2 +- content/xbl/test/test_bug468210.xhtml | 2 +- content/xslt/tests/mochitest/test_bug319374.xhtml | 9 ++++++--- content/xul/content/crashtests/326864-1.xul | 10 +++++++--- content/xul/content/crashtests/384740-1.xul | 2 +- dom/base/crashtests/404869-1.xul | 2 +- dom/indexedDB/test/head.js | 2 +- js/xpconnect/crashtests/471366-1.html | 2 +- layout/base/crashtests/379105-1.xhtml | 2 +- layout/inspector/tests/test_bug522601.xhtml | 2 +- layout/reftests/bugs/495385-2f.xhtml | 18 ++++++++++++++---- layout/reftests/bugs/reftest.list | 2 +- .../test/test_selectors_on_anonymous_content.html | 2 +- layout/xul/base/src/crashtests/328135-1.xul | 2 +- layout/xul/base/src/crashtests/329477-1.xhtml | 4 ++-- toolkit/content/tests/widgets/test_popupanchor.xul | 2 +- 28 files changed, 59 insertions(+), 41 deletions(-)
diff --git a/content/base/crashtests/308120-1.xul b/content/base/crashtests/308120-1.xul index dc8a21c..55963d7 100644 --- 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> diff --git a/content/base/crashtests/330925-1.xhtml b/content/base/crashtests/330925-1.xhtml index 02e1dac..7dac837 100644 --- a/content/base/crashtests/330925-1.xhtml +++ b/content/base/crashtests/330925-1.xhtml @@ -10,7 +10,7 @@ function init() 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) { diff --git a/content/base/crashtests/401993-1.html b/content/base/crashtests/401993-1.html index ba071e2..b8679df 100644 --- a/content/base/crashtests/401993-1.html +++ b/content/base/crashtests/401993-1.html @@ -11,7 +11,7 @@ function s()
function boom() { - var nodes = document.getAnonymousNodes(x); + var nodes = SpecialPowers.unwrap(SpecialPowers.wrap(document).getAnonymousNodes(x)); if (!nodes) { setTimeout(boom, 10); return; diff --git a/content/base/test/test_base.xhtml b/content/base/test/test_base.xhtml index 41e5bbc..b77551a 100644 --- a/content/base/test/test_base.xhtml +++ b/content/base/test/test_base.xhtml @@ -40,7 +40,7 @@ addLoadEvent(function() { "http://mochi.test:8888/tests/content/base/test/file_base_xbl.xml", "http://mochi.test:8888/tests/content/base/test/file_base_xbl.xml#shesellssea...", ]; - 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; diff --git a/content/base/test/test_bug330925.xhtml b/content/base/test/test_bug330925.xhtml index 3784bd1..a26ab94 100644 --- a/content/base/test/test_bug330925.xhtml +++ b/content/base/test/test_bug330925.xhtml @@ -46,20 +46,21 @@ 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");
diff --git a/content/base/test/test_bug372086.html b/content/base/test/test_bug372086.html index d439215..43d8c6e 100644 --- a/content/base/test/test_bug372086.html +++ b/content/base/test/test_bug372086.html @@ -42,7 +42,7 @@ function runTest() { 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"); @@ -59,7 +59,7 @@ function runTest() { 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); diff --git a/content/base/test/test_bug444030.xhtml b/content/base/test/test_bug444030.xhtml index 92f6ba0..6ba2c6e 100644 --- a/content/base/test/test_bug444030.xhtml +++ b/content/base/test/test_bug444030.xhtml @@ -26,7 +26,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=444030 /** 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; diff --git a/content/html/content/crashtests/465466-1.xhtml b/content/html/content/crashtests/465466-1.xhtml index d1b85da..4e12587 100644 --- a/content/html/content/crashtests/465466-1.xhtml +++ b/content/html/content/crashtests/465466-1.xhtml @@ -11,7 +11,7 @@ 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")); } diff --git a/content/xbl/crashtests/472260-1.xhtml b/content/xbl/crashtests/472260-1.xhtml index 4b8d97f..49d5407 100644 --- a/content/xbl/crashtests/472260-1.xhtml +++ b/content/xbl/crashtests/472260-1.xhtml @@ -12,7 +12,7 @@ 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)";
diff --git a/content/xbl/test/file_bug379959_cross.html b/content/xbl/test/file_bug379959_cross.html index 29a456d..8f356d2 100644 --- a/content/xbl/test/file_bug379959_cross.html +++ b/content/xbl/test/file_bug379959_cross.html @@ -16,9 +16,9 @@ <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> diff --git a/content/xbl/test/file_bug379959_data.html b/content/xbl/test/file_bug379959_data.html index a84b63c..dd10176 100644 --- a/content/xbl/test/file_bug379959_data.html +++ b/content/xbl/test/file_bug379959_data.html @@ -11,7 +11,7 @@ <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> diff --git a/content/xbl/test/file_bug591198_inner.html b/content/xbl/test/file_bug591198_inner.html index 12fc9f5..89b547a 100644 --- a/content/xbl/test/file_bug591198_inner.html +++ b/content/xbl/test/file_bug591198_inner.html @@ -22,7 +22,7 @@ function sendResults() {
try { res.anonChildCount = - document.getAnonymousNodes(document.getElementById('b')).length; + SpecialPowers.wrap(document).getAnonymousNodes(document.getElementById('b')).length; } catch (ex) {}
diff --git a/content/xbl/test/test_bug378866.xhtml b/content/xbl/test/test_bug378866.xhtml index d4de492..8dcbf11 100644 --- a/content/xbl/test/test_bug378866.xhtml +++ b/content/xbl/test/test_bug378866.xhtml @@ -33,7 +33,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=378866 /** 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); diff --git a/content/xbl/test/test_bug468210.xhtml b/content/xbl/test/test_bug468210.xhtml index f930880..04434fd 100644 --- a/content/xbl/test/test_bug468210.xhtml +++ b/content/xbl/test/test_bug468210.xhtml @@ -32,7 +32,7 @@ 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); diff --git a/content/xslt/tests/mochitest/test_bug319374.xhtml b/content/xslt/tests/mochitest/test_bug319374.xhtml index c891fb3..a3496b7 100644 --- a/content/xslt/tests/mochitest/test_bug319374.xhtml +++ b/content/xslt/tests/mochitest/test_bug319374.xhtml @@ -31,6 +31,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=319374 // 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("*", @@ -42,7 +45,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=319374 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 @@ -56,10 +59,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=319374 // 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 { diff --git a/content/xul/content/crashtests/326864-1.xul b/content/xul/content/crashtests/326864-1.xul index 154b134..5515ca2 100644 --- a/content/xul/content/crashtests/326864-1.xul +++ b/content/xul/content/crashtests/326864-1.xul @@ -6,13 +6,17 @@
<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; diff --git a/content/xul/content/crashtests/384740-1.xul b/content/xul/content/crashtests/384740-1.xul index 3f47b47..374f47c 100644 --- a/content/xul/content/crashtests/384740-1.xul +++ b/content/xul/content/crashtests/384740-1.xul @@ -12,7 +12,7 @@ function boom()
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); diff --git a/dom/base/crashtests/404869-1.xul b/dom/base/crashtests/404869-1.xul index e530f7e..f5c7fac 100644 --- a/dom/base/crashtests/404869-1.xul +++ b/dom/base/crashtests/404869-1.xul @@ -10,7 +10,7 @@ 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) { } diff --git a/dom/indexedDB/test/head.js b/dom/indexedDB/test/head.js index 514b509..f47bead 100644 --- a/dom/indexedDB/test/head.js +++ b/dom/indexedDB/test/head.js @@ -60,7 +60,7 @@ function triggerSecondaryCommand(popup, index)
// 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();
diff --git a/js/xpconnect/crashtests/471366-1.html b/js/xpconnect/crashtests/471366-1.html index 75d0f25..b450d5e 100644 --- a/js/xpconnect/crashtests/471366-1.html +++ b/js/xpconnect/crashtests/471366-1.html @@ -3,7 +3,7 @@ <head> <script type="text/javascript">
-document.getAnonymousNodes({__proto__: XPCNativeWrapper.prototype}); +SpecialPowers.wrap(document).getAnonymousNodes({__proto__: XPCNativeWrapper.prototype});
</script> </head> diff --git a/layout/base/crashtests/379105-1.xhtml b/layout/base/crashtests/379105-1.xhtml index 662ebbd..e20cced 100644 --- a/layout/base/crashtests/379105-1.xhtml +++ b/layout/base/crashtests/379105-1.xhtml @@ -25,7 +25,7 @@ function boom1()
function boom2() { - var nodes = document.getAnonymousNodes(xbltarget); + var nodes = SpecialPowers.unwrap(SpecialPowers.wrap(document).getAnonymousNodes(xbltarget)); if (!nodes) { setTimeout(boom2, 10); return; diff --git a/layout/inspector/tests/test_bug522601.xhtml b/layout/inspector/tests/test_bug522601.xhtml index 8a94fe6..344dc61 100644 --- a/layout/inspector/tests/test_bug522601.xhtml +++ b/layout/inspector/tests/test_bug522601.xhtml @@ -106,7 +106,7 @@ addLoadEvent(function() { 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"] diff --git a/layout/reftests/bugs/495385-2f.xhtml b/layout/reftests/bugs/495385-2f.xhtml index 9b01963..3c35872 100644 --- a/layout/reftests/bugs/495385-2f.xhtml +++ b/layout/reftests/bugs/495385-2f.xhtml @@ -13,6 +13,19 @@ </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> @@ -21,13 +34,10 @@ body > div { border:1px solid black; margin:1em; #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> diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list index d4424e4..0dbd0e6 100644 --- a/layout/reftests/bugs/reftest.list +++ b/layout/reftests/bugs/reftest.list @@ -1370,7 +1370,7 @@ fails-if(Android) == 488685-1.html 488685-1-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 diff --git a/layout/style/test/test_selectors_on_anonymous_content.html b/layout/style/test/test_selectors_on_anonymous_content.html index 89da83fe..7a65f53 100644 --- a/layout/style/test/test_selectors_on_anonymous_content.html +++ b/layout/style/test/test_selectors_on_anonymous_content.html @@ -42,7 +42,7 @@ function run() { 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); diff --git a/layout/xul/base/src/crashtests/328135-1.xul b/layout/xul/base/src/crashtests/328135-1.xul index 1a532e18..77a4679 100644 --- a/layout/xul/base/src/crashtests/328135-1.xul +++ b/layout/xul/base/src/crashtests/328135-1.xul @@ -9,7 +9,7 @@
function init() { var pop = document.getElementsByTagName("popup")[0]; - document.getAnonymousNodes(pop)[0]; + SpecialPowers.wrap(document).getAnonymousNodes(pop)[0]; eval.eee = document.documentElement; };
diff --git a/layout/xul/base/src/crashtests/329477-1.xhtml b/layout/xul/base/src/crashtests/329477-1.xhtml index 87c8bd6..fcbd3da 100644 --- a/layout/xul/base/src/crashtests/329477-1.xhtml +++ b/layout/xul/base/src/crashtests/329477-1.xhtml @@ -9,8 +9,8 @@ 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(); } diff --git a/toolkit/content/tests/widgets/test_popupanchor.xul b/toolkit/content/tests/widgets/test_popupanchor.xul index ec6548d..9ad60e2 100644 --- a/toolkit/content/tests/widgets/test_popupanchor.xul +++ b/toolkit/content/tests/widgets/test_popupanchor.xul @@ -383,7 +383,7 @@ 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";
tbb-commits@lists.torproject.org