Bug 1568420 - Remove QI to nsIDOMChromeWindow, nsIDOMWindow and nsIImageLoadingContent. r=? draft
authorJorg K <jorgk@jorgk.com>
Thu, 25 Jul 2019 11:11:18 +0200
changeset 76440 cbb06824faa38c59a0a30a837e93b72ae00458b7
parent 76439 33aa95186ee7d2c81dc6d17c44160b10db97ecbd
child 76441 7fb000ba4c63a3877a369769b532d3d7f2d91817
push id8892
push usermozilla@jorgk.com
push dateThu, 25 Jul 2019 09:38:50 +0000
treeherdertry-comm-central@7fb000ba4c63 [default view] [failures only]
bugs1568420
Bug 1568420 - Remove QI to nsIDOMChromeWindow, nsIDOMWindow and nsIImageLoadingContent. r=?
calendar/base/content/calendar-chrome-startup.js
calendar/base/modules/utils/calViewUtils.jsm
common/src/ExtensionSupport.jsm
mail/base/content/macMessengerMenu.js
mail/base/content/mailWindow.js
mail/components/nsMailDefaultHandler.js
mail/test/mozmill/content-policy/test-compose-mailto.js
mail/test/mozmill/content-policy/test-general-content-policy.js
mail/test/mozmill/shared-modules/test-window-helpers.js
mailnews/extensions/newsblog/content/FeedUtils.jsm
mailnews/extensions/smime/content/certFetchingStatus.js
--- a/calendar/base/content/calendar-chrome-startup.js
+++ b/calendar/base/content/calendar-chrome-startup.js
@@ -149,17 +149,17 @@ var calendarWindowPrefs = {
                     let attributeValue = Services.prefs.getBoolPref("calendar.view.useSystemColors", false) && "true";
                     for (let win of fixIterator(Services.ww.getWindowEnumerator())) {
                         setElementValue(win.document.documentElement, attributeValue, "systemcolors");
                     }
                     break;
                 }
             }
         } else if (aTopic == "domwindowopened") {
-            let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
+            let win = aSubject;
             win.addEventListener("load", () => {
                 let attributeValue = Services.prefs.getBoolPref("calendar.view.useSystemColors", false) && "true";
                 setElementValue(win.document.documentElement, attributeValue, "systemcolors");
             });
         }
     }
 };
 
--- a/calendar/base/modules/utils/calViewUtils.jsm
+++ b/calendar/base/modules/utils/calViewUtils.jsm
@@ -157,18 +157,17 @@ var calview = {
         if (typeof aWindow._compositeCalendar == "undefined") {
             let comp = aWindow._compositeCalendar = Cc["@mozilla.org/calendar/calendar;1?type=composite"]
                                                       .createInstance(Ci.calICompositeCalendar);
             comp.prefPrefix = "calendar-main";
 
             if (typeof aWindow.gCalendarStatusFeedback != "undefined") {
                 // If we are in a window that has calendar status feedback, set
                 // up our status observer.
-                let chromeWindow = aWindow.QueryInterface(Ci.nsIDOMChromeWindow);
-                comp.setStatusObserver(aWindow.gCalendarStatusFeedback, chromeWindow);
+                comp.setStatusObserver(aWindow.gCalendarStatusFeedback, aWindow);
             }
         }
         return aWindow._compositeCalendar;
     },
 
     /**
      * Hash the given string into a color from the color palette of the standard
      * color picker.
--- a/common/src/ExtensionSupport.jsm
+++ b/common/src/ExtensionSupport.jsm
@@ -220,17 +220,17 @@ var ExtensionSupport = {
       // We already have a list of open windows, notify the caller about them.
       openWindowList.forEach(domWindow =>
         ExtensionSupport._checkAndRunMatchingExtensions(domWindow, "load", aID));
     } else {
       openWindowList = new Set();
       // Get the list of windows already open.
       let windows = Services.wm.getEnumerator(null);
       while (windows.hasMoreElements()) {
-        let domWindow = windows.getNext().QueryInterface(Ci.nsIDOMWindow);
+        let domWindow = windows.getNext();
         if (domWindow.document.location.href === "about:blank") {
           ExtensionSupport._waitForLoad(domWindow, aID);
         } else {
           ExtensionSupport._addToListAndNotify(domWindow, aID);
         }
       }
     }
 
--- a/mail/base/content/macMessengerMenu.js
+++ b/mail/base/content/macMessengerMenu.js
@@ -34,18 +34,17 @@ function loadListener(event) {
 
 /**
  * When the Preferences window is opened/closed, this observer will be called.
  * This is done so subdialog opens as a child of it.
  */
 function PrefWindowObserver() {
   this.observe = function(aSubject, aTopic, aData) {
     if (aTopic == "domwindowopened") {
-      let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
-      win.addEventListener("load", loadListener, {capture: false, once: true});
+      aSubject.addEventListener("load", loadListener, {capture: false, once: true});
     }
     Services.ww.unregisterNotification(this);
   };
 }
 
 /**
  * Show the Dock Options sub-dialog hanging from the Preferences window.
  * If Preference window was already opened, this will select General pane before
--- a/mail/base/content/mailWindow.js
+++ b/mail/base/content/mailWindow.js
@@ -47,18 +47,17 @@ function OnMailWindowUnload() {
 
   // all dbview closing is handled by OnUnloadMessenger for the 3-pane (it closes
   //  the tabs which close their views) and OnUnloadMessageWindow for the
   //  standalone message window.
 
   MailServices.mailSession.RemoveMsgWindow(msgWindow);
   // the tabs have the FolderDisplayWidget close their 'messenger' instances for us
 
-  window.QueryInterface(Ci.nsIDOMChromeWindow)
-        .browserDOMWindow = null;
+  window.browserDOMWindow = null;
 
   msgWindow.closeWindow();
 
   msgWindow.msgHeaderSink = null;
   msgWindow.notificationCallbacks = null;
   gDBView = null;
   window.MsgStatusFeedback.unload();
   Cc["@mozilla.org/activity-manager;1"]
@@ -171,18 +170,17 @@ function CreateMailWindowGlobals() {
   // double register the status feedback object as the xul browser window implementation
   window.QueryInterface(Ci.nsIInterfaceRequestor)
         .getInterface(Ci.nsIWebNavigation)
         .QueryInterface(Ci.nsIDocShellTreeItem).treeOwner
         .QueryInterface(Ci.nsIInterfaceRequestor)
         .getInterface(Ci.nsIXULWindow)
         .XULBrowserWindow = window.MsgStatusFeedback;
 
-  window.QueryInterface(Ci.nsIDOMChromeWindow)
-        .browserDOMWindow = new nsBrowserAccess();
+  window.browserDOMWindow = new nsBrowserAccess();
 
   statusFeedback = Cc["@mozilla.org/messenger/statusfeedback;1"]
                      .createInstance(Ci.nsIMsgStatusFeedback);
   statusFeedback.setWrappedStatusFeedback(window.MsgStatusFeedback);
 
   Cc["@mozilla.org/activity-manager;1"]
     .getService(Ci.nsIActivityManager)
     .addListener(window.MsgStatusFeedback);
--- a/mail/components/nsMailDefaultHandler.js
+++ b/mail/components/nsMailDefaultHandler.js
@@ -276,17 +276,17 @@ var nsMailDefaultHandler = {
 
     if (!uri && cmdLine.preventDefault)
       return;
 
     if (!uri && cmdLine.state != Ci.nsICommandLine.STATE_INITIAL_LAUNCH) {
       try {
         var wlist = Services.wm.getEnumerator("mail:3pane");
         if (wlist.hasMoreElements()) {
-          var window = wlist.getNext().QueryInterface(Ci.nsIDOMWindow);
+          var window = wlist.getNext();
           window.focus();
           return;
         }
       } catch (e) {
         dump(e);
       }
     }
 
--- a/mail/test/mozmill/content-policy/test-compose-mailto.js
+++ b/mail/test/mozmill/content-policy/test-compose-mailto.js
@@ -84,18 +84,17 @@ function test_checkInsertImage() {
 
   // Test that the image load has not been denied
   let childImages = gComposeWin.e("content-frame").contentDocument.getElementsByTagName("img");
 
   if (childImages.length != 1)
     throw new Error("Expecting one image in document, actually have " + childImages.length);
 
   // Should be the only image, so just check the first.
-  if (childImages[0].QueryInterface(Ci.nsIImageLoadingContent)
-                    .imageBlockingStatus != Ci.nsIContentPolicy.ACCEPT)
+  if (childImages[0].imageBlockingStatus != Ci.nsIContentPolicy.ACCEPT)
     throw new Error("Loading of image has been unexpectedly blocked in a mailto compose window");
 }
 
 function test_closeComposeWindowAndTab() {
   composeHelper.close_compose_window(gComposeWin);
 
   mc.tabmail.closeTab(gNewTab);
 
--- a/mail/test/mozmill/content-policy/test-general-content-policy.js
+++ b/mail/test/mozmill/content-policy/test-general-content-policy.js
@@ -66,18 +66,17 @@ var url = collector.addHttpResource("../
  */
 var TESTS = [
   {
     type: "Image",
     checkDenied: true,
     body: '<img id="testelement" src="' + url + 'pass.png"/>\n',
     webPage: "remoteimage.html",
     checkForAllowed: function img_checkAllowed(element) {
-      return element.QueryInterface(Ci.nsIImageLoadingContent)
-                    .imageBlockingStatus == Ci.nsIContentPolicy.ACCEPT;
+      return element.imageBlockingStatus == Ci.nsIContentPolicy.ACCEPT;
     },
   },
   {
     type: "Video",
     checkDenied: true,
     body: '<video id="testelement" src="' + url + 'video.ogv"/>\n',
     webPage: "remotevideo.html",
     checkForAllowed: function video_checkAllowed(element) {
@@ -85,18 +84,17 @@ var TESTS = [
     },
   },
   {
     type: "Image-Data",
     checkDenied: false,
     body: '<img id="testelement" src="data:image/png,%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%0A%AD%B3n%0D%FB%E9%17%1Ad0f%D70%E1%25%96%02%04%D2I%B7%F6%EE%A2%2BL%D8%3D%F3A%96%ED%26%A6%0F_%13M%2B%AC%D8%9A%22D%7C%F8%AC%0AZ%91%5Dv%85%F2%C8%7B%E7%FD%AF%9D%FB%C4%D34%D3%D6%E5%18a%C4%3D%93%A0%B7%9C%B6%C9%A6S%BA%D3w%D8%F9d%E1%11GB%15T%B8g%BE%F0%F1%99%D3%9C!cO%7Bg%3A%B3%7DHC%F1%F71%C6JT%22%E9U%AF_%60%5C%9E%D6%0B%2F%19d%D4P%13%13%BF%E1%C6%C4%CC%22%CB%AA%EC%2F~%5Dq%15%C3%AC%B0b%BD%EA%AC%A1%1B%C6%AD%ACE%16%85%A6%98%8A%9F%AA%A7%5Eh%95U%3BO)%A5%BD%F4%0E3%3C%CAh\'%9D)%A4d%91u%CD%B5s%AF%CF%19%B7%B2ZhI%22%E9%8E%BB%F8%A9Yf%85%3A%E8%006%D8%18%60%A0%8A*%2F%5E%0F%1E%133%9F%FC%5EzC%84l%DE%0Dc%FC%FC%9D~%C1~%03%97%96%03%F2QP%E0%18%00%00%00%00IEND%AEB%60%82"/>\n',
     webPage: "remoteimagedata.html",
     checkForAllowed: function img_checkAllowed(element) {
-      return element.QueryInterface(Ci.nsIImageLoadingContent)
-                    .imageBlockingStatus == Ci.nsIContentPolicy.ACCEPT;
+      return element.imageBlockingStatus == Ci.nsIContentPolicy.ACCEPT;
     },
   },
 ];
 
 // These two constants are used to build the message body.
 var msgBodyStart = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\n' +
 "<html>\n" +
 "<head>\n" +
@@ -532,21 +530,19 @@ function subtest_insertImageIntoReplyFor
 
   // Test that the image load has not been denied
   let childImages = replyWindow.e("content-frame").contentDocument.getElementsByTagName("img");
 
   if (childImages.length != 2)
     throw new Error("Expecting one image in document, actually have " + childImages.length);
 
   // Check both images.
-  if (childImages[0].QueryInterface(Ci.nsIImageLoadingContent)
-                    .imageBlockingStatus != Ci.nsIContentPolicy.ACCEPT)
+  if (childImages[0].imageBlockingStatus != Ci.nsIContentPolicy.ACCEPT)
     throw new Error("Loading of image has been unexpectedly blocked (1)");
-  if (childImages[1].QueryInterface(Ci.nsIImageLoadingContent)
-                    .imageBlockingStatus != Ci.nsIContentPolicy.ACCEPT)
+  if (childImages[1].imageBlockingStatus != Ci.nsIContentPolicy.ACCEPT)
     throw new Error("Loading of image has been unexpectedly blocked (2)");
 
   close_compose_window(replyWindow);
 }
 
 function test_insertImageIntoReply() {
   subtest_insertImageIntoReplyForward(true);
 }
--- a/mail/test/mozmill/shared-modules/test-window-helpers.js
+++ b/mail/test/mozmill/shared-modules/test-window-helpers.js
@@ -1923,17 +1923,17 @@ function screenshotToBase64(aWindow) {
  */
 function captureWindowStatesForErrorReporting(normalizeForJsonFunc) {
   let info = {};
   let windows = info.windows = [];
 
   let enumerator = Services.wm.getEnumerator(null);
   let iWin = 0;
   while (enumerator.hasMoreElements()) {
-    let win = enumerator.getNext().QueryInterface(Ci.nsIDOMWindow);
+    let win = enumerator.getNext();
 
     let winId = getWindowTypeOrId(win.document.documentElement) ||
                 ("unnamed:" + iWin);
 
     let openPopups =
       Array.from(win.document.documentElement.getElementsByTagName("menupopup"))
            .filter(x => x.state != "closed")
            .map(x => normalizeForJsonFunc(x));
--- a/mailnews/extensions/newsblog/content/FeedUtils.jsm
+++ b/mailnews/extensions/newsblog/content/FeedUtils.jsm
@@ -436,17 +436,17 @@ var FeedUtils = {
     // If the user has no Feeds account yet, create one.
     if (!aFolder) {
       aFolder = FeedUtils.createRssAccount().incomingServer.rootFolder;
     }
 
     if (!aMsgWindow) {
       let wlist = Services.wm.getEnumerator("mail:3pane");
       if (wlist.hasMoreElements()) {
-        let win = wlist.getNext().QueryInterface(Ci.nsIDOMWindow);
+        let win = wlist.getNext();
         win.focus();
         aMsgWindow = win.msgWindow;
       } else {
         // If there are no open windows, open one, pass it the URL, and
         // during opening it will subscribe to the feed.
         let arg = Cc["@mozilla.org/supports-string;1"].
                   createInstance(Ci.nsISupportsString);
         arg.data = aUrl;
--- a/mailnews/extensions/smime/content/certFetchingStatus.js
+++ b/mailnews/extensions/smime/content/certFetchingStatus.js
@@ -96,17 +96,17 @@ function getLDAPOperation() {
   gLdapOperation.init(gLdapConnection,
                       new ldapMessageListener(),
                       null);
 }
 
 function getPassword() {
   // we only need a password if we are using credentials
   if (gLogin) {
-    let authPrompter = Services.ww.getNewAuthPrompter(window.QueryInterface(Ci.nsIDOMWindow));
+    let authPrompter = Services.ww.getNewAuthPrompter(window);
     let strBundle = document.getElementById("bundle_ldap");
     let password = { value: "" };
 
     // nsLDAPAutocompleteSession uses asciiHost instead of host for the prompt text, I think we should be
     // consistent.
     if (authPrompter.promptPassword(strBundle.getString("authPromptTitle"),
                                      strBundle.getFormattedString("authPromptText", [gLdapServerURL.asciiHost]),
                                      gLdapServerURL.spec,