From a41e846699d7761ccf942311578b939c5d421ec4 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 24 Jul 2019 19:46:46 +0000 Subject: [PATCH] Bug 1568579. Remove test-only uses of QueryInterface on Window objects. r=bholley Differential Revision: https://phabricator.services.mozilla.com/D39219 --HG-- extra : moz-landing-system : lando --- js/xpconnect/tests/chrome/test_wrappers.xul | 2 +- .../Harness_sanity/test_SpecialPowersExtension.html | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/js/xpconnect/tests/chrome/test_wrappers.xul b/js/xpconnect/tests/chrome/test_wrappers.xul index 6f59f2383ea1..69da0e0a4a14 100644 --- a/js/xpconnect/tests/chrome/test_wrappers.xul +++ b/js/xpconnect/tests/chrome/test_wrappers.xul @@ -75,7 +75,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=500931 // Test QI on new dom bindings. try { - var QIed = win.QueryInterface(Ci.nsIClassInfo); + var QIed = win.document.documentElement.QueryInterface(Ci.nsIClassInfo); ok(false, "Should throw for new binding objects not having classinfo"); } catch(e) { is(e.name, "NS_NOINTERFACE", "Threw while QI-ing on wrapper"); diff --git a/testing/mochitest/tests/Harness_sanity/test_SpecialPowersExtension.html b/testing/mochitest/tests/Harness_sanity/test_SpecialPowersExtension.html index 51e343b44236..989db4e5e3a9 100644 --- a/testing/mochitest/tests/Harness_sanity/test_SpecialPowersExtension.html +++ b/testing/mochitest/tests/Harness_sanity/test_SpecialPowersExtension.html @@ -82,9 +82,15 @@ async function starttest(){ // QueryInterface and getPrivilegedProps tests is(SpecialPowers.can_QI(SpecialPowers), false); - ok(SpecialPowers.can_QI(window)); - ok(SpecialPowers.do_QueryInterface(window, "nsIDOMWindow")); - is(SpecialPowers.getPrivilegedProps(SpecialPowers.do_QueryInterface(window, "nsIDOMWindow"), "document.nodeName"), "#document"); + let doc = SpecialPowers.wrap(document); + is(SpecialPowers.getPrivilegedProps(doc, "baseURIObject.fileName"), null, + "Should not have a fileName property yet"); + let uri = SpecialPowers.getPrivilegedProps(doc, "baseURIObject"); + ok(SpecialPowers.can_QI(uri)); + ok(SpecialPowers.do_QueryInterface(uri, "nsIURL")); + is(SpecialPowers.getPrivilegedProps(doc, "baseURIObject.fileName"), + "test_SpecialPowersExtension.html", + "Should have a fileName property now"); //try to run garbage collection SpecialPowers.gc();