Bug 1568883. Remove the QI implementation from Web IDL elements. r=peterv,mossop
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 11 Oct 2019 22:10:20 +0000
changeset 497438 02578c5bb2032fa0d91e712a03667b9757314ed0
parent 497437 8fb923925923f5ba7a8d67ecd46f50eb527f3386
child 497439 cdfbf9c0a9f1caad870e9fb59f9c1b76a7d0cb41
push id36689
push userncsoregi@mozilla.com
push dateMon, 14 Oct 2019 21:30:51 +0000
treeherdermozilla-central@a212b426f665 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv, mossop
bugs1568883
milestone71.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1568883. Remove the QI implementation from Web IDL elements. r=peterv,mossop The XBL test is being removed because it was the only remaining consumer of xbl's implements="interfacename" in the tree, and was triggering QI on elements for that codepath. I've verified that a try run that MOZ_CRASHes when the C++ binding QueryInterface implementation is invoked is green with these changes. Differential Revision: https://phabricator.services.mozilla.com/D48249
dom/base/test/chrome/cpows_parent.xul
dom/bindings/test/mochitest.ini
dom/bindings/test/test_queryInterface.html
dom/webidl/LegacyQueryInterface.webidl
dom/xbl/test/chrome.ini
dom/xbl/test/file_bug950909.html
dom/xbl/test/file_bug950909.xml
dom/xbl/test/mochitest.ini
dom/xbl/test/test_bug950909.xul
js/xpconnect/tests/chrome/test_wrappers.xul
toolkit/content/tests/chrome/test_custom_element_base.xul
--- a/dom/base/test/chrome/cpows_parent.xul
+++ b/dom/base/test/chrome/cpows_parent.xul
@@ -206,38 +206,26 @@
     function recvErrorReportingTest(message) {
       throw "Test Error Probe";
     }
 
     let savedElement = null;
     function recvDomTest(message) {
       savedElement = message.objects.element;
 
-      is(savedElement.QueryInterface(Ci.nsISupports), savedElement,
-         "QI to nsISupports works");
-
-      function testNoInterface(savedElement, i) {
-        try {
-          savedElement.QueryInterface(i);
-          ok(false, "should have thrown an exception");
-        } catch (e) {
-          is(e.result, Cr.NS_ERROR_NO_INTERFACE, "threw the right exception");
-        }
-      }
-
-      testNoInterface(savedElement, Ci.nsIClassInfo);
+      is(savedElement.QueryInterface, undefined,
+         "Should not have a QueryInterface");
 
       // Test to ensure that we don't pass CPOWs to C++-implemented interfaces.
       // See bug 1072980.
       if (test_state == "remote") {
         // This doesn't work because we intercept toString specially
         // and don't cache the function pointer.
         // See bug 1140636.
         todo_is(savedElement.toString, savedElement.toString, "toString identity works");
-        is(savedElement.QueryInterface, savedElement.QueryInterface, "QueryInterface identity works");
 
         is(Object.prototype.toString.call(savedElement), "[object HTMLDivElement]",
            "prove that this works (and doesn't leak)");
 
         is(Object.prototype.toString.call(savedElement), "[object HTMLDivElement]",
            "prove that this works twice (since we cache it and doesn't leak)");
 
         // This does work because we create a CPOW for isEqualNode that stays
--- a/dom/bindings/test/mochitest.ini
+++ b/dom/bindings/test/mochitest.ini
@@ -40,17 +40,16 @@ support-files =
 [test_exceptions_from_jsimplemented.html]
 tags = webrtc
 [test_lenientThis.html]
 [test_lookupGetter.html]
 [test_namedNoIndexed.html]
 [test_named_getter_enumerability.html]
 [test_Object.prototype_props.html]
 [test_proxy_expandos.html]
-[test_queryInterface.html]
 [test_returnUnion.html]
 skip-if = debug == false
 [test_usvstring.html]
 skip-if = debug == false
 [test_sequence_wrapping.html]
 subsuite = gpu
 [test_setWithNamedGetterNoNamedSetter.html]
 [test_throwing_method_noDCE.html]
deleted file mode 100644
--- a/dom/bindings/test/test_queryInterface.html
+++ /dev/null
@@ -1,41 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=827546
--->
-<head>
-  <meta charset="utf-8">
-  <title>Test for Bug 827546</title>
-  <script src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-  <script type="application/javascript">
-
-  /** Test for Bug 827546 **/
-
-  var notImage = document.createElement("div");
-  var thrown;
-  try {
-    thrown = false;
-    SpecialPowers.do_QueryInterface(notImage, "nsIImageLoadingContent");
-  } catch (e) {
-    thrown = true;
-  }
-  ok(thrown,
-     "QI to nsIImageLoadingContent on a non-image element should fail");
-
-  var image = document.createElement("img");
-  ok(SpecialPowers.do_QueryInterface(image, "nsIImageLoadingContent"),
-     "Image  element needs to support QI to nsIImageLoadingContent");
-
-  </script>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=827546">Mozilla Bug 827546</a>
-<p id="display"></p>
-<div id="content" style="display: none">
-
-</div>
-<pre id="test">
-</pre>
-</body>
-</html>
--- a/dom/webidl/LegacyQueryInterface.webidl
+++ b/dom/webidl/LegacyQueryInterface.webidl
@@ -7,10 +7,8 @@
 interface nsISupports;
 
 [Exposed=Window]
 interface mixin LegacyQueryInterface {
   // Legacy QueryInterface, only exposed to chrome code on the main thread.
   [Exposed=Window, ChromeOnly]
   nsISupports QueryInterface(any iid);
 };
-
-Element includes LegacyQueryInterface;
--- a/dom/xbl/test/chrome.ini
+++ b/dom/xbl/test/chrome.ini
@@ -1,15 +1,13 @@
 [DEFAULT]
 support-files =
-  file_bug950909.xml
   file_fieldScopeChain.xml
 
 [test_bug378518.xul]
 skip-if = (verify && debug && (os == 'linux' || os == 'mac'))
 [test_bug398135.xul]
 [test_bug398492.xul]
 [test_bug721452.xul]
 [test_bug723676.xul]
 [test_bug772966.xul]
-[test_bug950909.xul]
 [test_bug1086996.xhtml]
 [test_fieldScopeChain.html]
deleted file mode 100644
--- a/dom/xbl/test/file_bug950909.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-</head>
-<body>
-<div style="-moz-binding: url(chrome://mochitests/content/chrome/dom/xbl/test/file_bug950909.xml#testBinding"></div>
-</body>
-</html>
deleted file mode 100644
--- a/dom/xbl/test/file_bug950909.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0"?>
-<bindings id="chromeTestBindings" xmlns="http://www.mozilla.org/xbl">
-  <binding id="testBinding" bindToUntrustedContent="true">
-    <implementation implements="nsIObserver">
-      <constructor>
-      <![CDATA[
-        var win = window;
-        var SpecialPowers = win.SpecialPowers;
-        var ok = SpecialPowers.unwrap(SpecialPowers.wrap(window).parent.ok);
-
-        // Generate an XPCWrappedJS for the reflector. We need to do this
-        // explicitly with a testing helper, because we're converging on
-        // removing XPConnect from the web, which means that it won't be
-        // possible to generate an XPCWrappedJS from content (or XBL) code.
-        var scope = {};
-        var holder = SpecialPowers.Cu.generateXPCWrappedJS(this, scope);
-
-        // Now, QI |this|, which will generate an aggregated native.
-        SpecialPowers.wrap(this).QueryInterface(SpecialPowers.Ci.nsIObserver);
-
-        ok(true, "Didn't assert or crash");
-
-        SpecialPowers.wrap(window).parent.SimpleTest.finish();
-      ]]>
-      </constructor>
-      <method name="observe">
-        <parameter name="aSubject"/>
-        <parameter name="aTopic"/>
-        <parameter name="aData"/>
-        <body><![CDATA[]]></body>
-      </method>
-    </implementation>
-  </binding>
-</bindings>
--- a/dom/xbl/test/mochitest.ini
+++ b/dom/xbl/test/mochitest.ini
@@ -8,17 +8,16 @@ support-files =
   file_bug379959_data.html
   file_bug379959_xbl.xml
   file_bug397934.xhtml
   file_bug481558.xbl
   file_bug481558css.sjs
   file_bug591198_inner.html
   file_bug591198_xbl.xml
   file_bug844783.xhtml
-  file_bug950909.html
 
 [test_bug310107.html]
 [test_bug366770.html]
 [test_bug371724.xhtml]
 [test_bug372769.html]
 [test_bug378866.xhtml]
 [test_bug379959.html]
 [test_bug389322.xhtml]
deleted file mode 100644
--- a/dom/xbl/test/test_bug950909.xul
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0"?>
-<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
-<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=950909
--->
-<window title="Mozilla Bug 950909"
-        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
-
-  <!-- test results are displayed in the html:body -->
-  <body xmlns="http://www.w3.org/1999/xhtml">
-  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=950909"
-     target="_blank">Mozilla Bug 950909</a>
-  </body>
-
-  <!-- test code goes here -->
-  <script type="application/javascript">
-  <![CDATA[
-
-  /*
-   * Test for bug 950909. This has to be a chrome tests because content needs
-   * to apply a chrome binding (file_bug950909.xml), which will only be registered
-   * as a chrome:// URI during mochitest-chrome runs. And the binding has to be
-   * served from a chrome origin, because otherwise implements="nsIFoo" attributes
-   * are ignored. So this test needs 3 files, all told. Ugh.
-   */
-
-  // Just wait. When the iframe loads, it'll apply the binding, which will
-  // trigger the constructor for the binding.
-  SimpleTest.waitForExplicitFinish();
-
-  ]]>
-  </script>
-  <iframe src="http://example.com/tests/dom/xbl/test/file_bug950909.html"/>
-</window>
--- a/js/xpconnect/tests/chrome/test_wrappers.xul
+++ b/js/xpconnect/tests/chrome/test_wrappers.xul
@@ -67,24 +67,16 @@ https://bugzilla.mozilla.org/show_bug.cg
       "stringifying a native function." + " " + eventTargetToString + " " + nativeToString);
 
    is(win.XPathResult.NUMBER_TYPE, 1, "can access constants on constructors");
    is(typeof win.IDBKeyRange.bound, "function", "can access crazy IDBKeyRange static functions");
 
    // Test getter/setter lookup on Xray wrappers.
    ok(Object.prototype.__lookupGetter__.call(win.document, 'title'), 'found getter on document');
    ok(Object.prototype.__lookupGetter__.call(win.document, 'title'), 'found getter on document');
-
-   // Test QI on new dom bindings.
-   try {
-     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");
-   }
   }
 
   SimpleTest.waitForExplicitFinish();
 
   ]]></script>
   <iframe type="content"
           src="http://example.org/tests/js/xpconnect/tests/mochitest/chrome_wrappers_helper.html"
           onload="go()"
--- a/toolkit/content/tests/chrome/test_custom_element_base.xul
+++ b/toolkit/content/tests/chrome/test_custom_element_base.xul
@@ -297,22 +297,18 @@
     customElements.define("simpleelement", SimpleElement);
 
     let twoElement = document.getElementById("two");
 
     is(document.documentElement.getCustomInterfaceCallback, undefined,
        "No getCustomInterfaceCallback on non-custom element");
     is(typeof twoElement.getCustomInterfaceCallback, "function",
        "getCustomInterfaceCallback available on custom element when set");
-    try {
-      document.documentElement.QueryInterface(Ci.nsIDOMXULControlElement)
-      ok(false, "Non-custom element implements custom interface");
-    } catch (ex) {
-      ok(true, "Non-custom element implements custom interface");
-    }
+    is(document.documentElement.QueryInterface, undefined,
+       "Non-custom element should not have a QueryInterface implementation");
 
     // Try various ways to get the custom interface.
 
     let asControl = twoElement.getCustomInterfaceCallback(Ci.nsIDOMXULControlElement);
 
     // XXX: Switched to from ok() to todo_is() in Bug 1467712. Follow up in 1500967
     // Not sure if this was suppose to simply check for existence or equality?
     todo_is(asControl, twoElement, "getCustomInterface returns interface implementation ");