Bug 1476142 part 4. Remove some unnecessary QIs on window in various parts of the tree. r=kmag
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 02 Aug 2018 15:26:48 -0400
changeset 826125 b5b69cf20e9625bcdb85f02409f84aabffda41a6
parent 826124 95a8a26a5a8600413f2390d476ec3fa13634c79b
child 826126 7bfbfba4b30c0940062fd7d321737c6eca760f25
push id118244
push usernnethercote@mozilla.com
push dateFri, 03 Aug 2018 00:00:34 +0000
reviewerskmag
bugs1476142
milestone63.0a1
Bug 1476142 part 4. Remove some unnecessary QIs on window in various parts of the tree. r=kmag The crashtest was not testing anything useful, because getInterface is no longer exposed to web content.
accessible/tests/mochitest/test_nsIAccessibleDocument.html
dom/xul/test/test_bug757137.xul
extensions/spellcheck/tests/mochitest/helper_bug1170484.js
extensions/spellcheck/tests/mochitest/test_bug1272623.html
js/xpconnect/crashtests/705875.html
js/xpconnect/crashtests/crashtests.list
layout/tools/reftest/reftest-content.js
testing/mochitest/tests/SimpleTest/ChromePowers.js
--- a/accessible/tests/mochitest/test_nsIAccessibleDocument.html
+++ b/accessible/tests/mochitest/test_nsIAccessibleDocument.html
@@ -62,17 +62,17 @@ https://bugzilla.mozilla.org/show_bug.cg
           domDoc = docAcc.DOMDocument;
         } catch (e) {}
         ok(domDoc, "no Document for this doc accessible!");
         is(domDoc, document, "Document nodes do not match!");
 
         // Test for correct nsIDOMWindow retrieval.
         var domWindow = null;
         try {
-          domWindow = docAcc.window.QueryInterface(nsIDOMWindow);
+          domWindow = docAcc.window;
         } catch (e) {}
         ok(domWindow, "no nsIDOMWindow for this doc accessible!");
         is(domWindow, window, "Window nodes do not match!");
       }
 
       SimpleTest.finish();
     }
 
--- a/dom/xul/test/test_bug757137.xul
+++ b/dom/xul/test/test_bug757137.xul
@@ -7,45 +7,32 @@
 
 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
 <body xmlns="http://www.w3.org/1999/xhtml">
   <div id="content" style="display: none"/>
 </body>
 
 <script>
-var chromeWindowInterface = Ci.nsIDOMChromeWindow;
-
 SimpleTest.waitForExplicitFinish();
 
 // Force off out-of-process mozbrowser because we need to grab its
 // |window| synchronously from here.  Out-of-process docshell creation
 // for mozbrowser haves entirely differently.
 // XXX why doesn't pushPrefEnv() work here?
 var otherWindow = window.open("window_bug757137.xul", "", "chrome");
-ok(chromeWindowInterface !== null, 'nsIDOMChromeWindow interface is defined');
-var otherChromeWindow = null;
-try {
-  otherChromeWindow = otherWindow.QueryInterface(chromeWindowInterface);
-} catch(e) {
-  ok(false, 'exception when QI to ChromeWindow');
-}
-ok(otherChromeWindow !== null, 'XUL window should QI to ChromeWindow');
+ok(otherWindow.isChromeWindow, 'XUL window should be a ChromeWindow');
 
 SpecialPowers.pushPrefEnv({"set":[["dom.ipc.tabs.disabled", true]]}, startTest);
 
 function startTest() {
   otherWindow.onload = function () {
     var w = otherWindow.document.getElementById('f').contentWindow;
     ok(w !== null, 'got the |window| for a mozbrowser iframe');
-    var chromeWindow = null;
-    try {
-      var chromeWindow = w.QueryInterface(chromeWindowInterface);
-    } catch(e) { }
-      ok(chromeWindow === null, 'mozbrowser iframe should not get ChromeWindow');
+    ok(!w.isChromeWindow, 'mozbrowser iframe should not be a ChromeWindow');
 
     otherWindow.close();
     SimpleTest.waitForFocus(SimpleTest.finish);
  };
 }
 </script>
 
 </window>
--- a/extensions/spellcheck/tests/mochitest/helper_bug1170484.js
+++ b/extensions/spellcheck/tests/mochitest/helper_bug1170484.js
@@ -1,12 +1,12 @@
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 // Chrome scripts are run with synchronous messages, so make sure we're completely
 // decoupled from the content process before doing this work.
 Cu.dispatch(function() {
-  let chromeWin = Services.ww.activeWindow.QueryInterface(Ci.nsIDOMChromeWindow);
+  let chromeWin = Services.ww.activeWindow;
   contextMenu = chromeWin.document.getElementById("contentAreaContextMenu");
   var suggestion = contextMenu.querySelector(".spell-suggestion");
   suggestion.doCommand();
   contextMenu.hidePopup();
   sendAsyncMessage("spellingCorrected");
 });
--- a/extensions/spellcheck/tests/mochitest/test_bug1272623.html
+++ b/extensions/spellcheck/tests/mochitest/test_bug1272623.html
@@ -33,17 +33,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
     // Perform the spelling correction
     let mm = SpecialPowers.loadChromeScript(function() {
       ChromeUtils.import("resource://gre/modules/Services.jsm");
 
       // Chrome scripts are run with synchronous messages, so make sure we're completely
       // decoupled from the content process before doing this work.
       Cu.dispatch(function() {
-        let chromeWin = Services.ww.activeWindow.QueryInterface(Ci.nsIDOMChromeWindow);
+        let chromeWin = Services.ww.activeWindow;
         contextMenu = chromeWin.document.getElementById("contentAreaContextMenu");
         let suggestion = contextMenu.querySelector(".spell-suggestion");
         suggestion.doCommand();
         contextMenu.hidePopup();
         sendAsyncMessage("spellingCorrected");
       });
     });
     info("Loaded chrome script");
deleted file mode 100644
--- a/js/xpconnect/crashtests/705875.html
+++ /dev/null
@@ -1,7 +0,0 @@
-<!DOCTYPE html>
-<script>
-
-window.QueryInterface(Ci.nsIInterfaceRequestor);
-window.getInterface(null);
-
-</script>
--- a/js/xpconnect/crashtests/crashtests.list
+++ b/js/xpconnect/crashtests/crashtests.list
@@ -29,17 +29,16 @@ load 601284-1.html
 load 603146-1.html
 load 603858-1.html
 load 608963.html
 load 616930-1.html
 # This test has jit-related infinite recursion, which is slow enough to cause
 # timeouts on mac. See bug 908895.
 skip-if(cocoaWidget&&isDebugBuild) load 639737-1.html
 load 648206-1.html
-load 705875.html
 load 720305-1.html
 load 721910.html
 load 723465.html
 load 732870.html
 load 751995.html
 load 761831.html
 asserts(0-1) load 752038.html # We may hit bug 645229 here.
 asserts(1) load 753162.html # We hit bug 675518 or bug 680086 here.
--- a/layout/tools/reftest/reftest-content.js
+++ b/layout/tools/reftest/reftest-content.js
@@ -260,18 +260,17 @@ function printToPdf(callback) {
         ps.printRange = Ci.nsIPrintSettings.kRangeSelection;
     } else if (printRange) {
         ps.printRange = Ci.nsIPrintSettings.kRangeSpecifiedPageRange;
         let range = printRange.split('-');
         ps.startPageRange = +range[0] || 1;
         ps.endPageRange = +range[1] || 1;
     }
 
-    let webBrowserPrint = content.QueryInterface(Ci.nsIInterfaceRequestor)
-                                 .getInterface(Ci.nsIWebBrowserPrint);
+    let webBrowserPrint = content.getInterface(Ci.nsIWebBrowserPrint);
     webBrowserPrint.print(ps, {
         onStateChange: function(webProgress, request, stateFlags, status) {
             if (stateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
                 stateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) {
                 callback(status, file.path);
             }
         },
         onProgressChange: function () {},
--- a/testing/mochitest/tests/SimpleTest/ChromePowers.js
+++ b/testing/mochitest/tests/SimpleTest/ChromePowers.js
@@ -1,17 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 function ChromePowers(window) {
   this.window = Cu.getWeakReference(window);
 
-  // In the case of browser-chrome tests, we are running as a [ChromeWindow]
-  // and we have no window.QueryInterface available, content.window is what we need
   if (typeof(window) == "ChromeWindow" && typeof(content.window) == "Window") {
     this.DOMWindowUtils = bindDOMWindowUtils(content.window);
     this.window = Cu.getWeakReference(content.window);
   } else {
     this.DOMWindowUtils = bindDOMWindowUtils(window);
   }
 
   this.spObserver = new SpecialPowersObserverAPI();