Bug 1463016: Part 7 - Update remaining getInterface(nsIDOMWindow) callers to use Window. r?nika
MozReview-Commit-ID: 6LmrNMf2h7G
--- a/accessible/tests/mochitest/common.js
+++ b/accessible/tests/mochitest/common.js
@@ -41,17 +41,16 @@ const nsIAccessibleTable = Ci.nsIAccessi
const nsIAccessibleTableCell = Ci.nsIAccessibleTableCell;
const nsIAccessibleTraversalRule = Ci.nsIAccessibleTraversalRule;
const nsIAccessibleValue = Ci.nsIAccessibleValue;
const nsIObserverService = Ci.nsIObserverService;
const nsIDOMDocument = Ci.nsIDOMDocument;
const nsIDOMNode = Ci.nsIDOMNode;
-const nsIDOMWindow = Ci.nsIDOMWindow;
const nsIPropertyElement = Ci.nsIPropertyElement;
// //////////////////////////////////////////////////////////////////////////////
// OS detect
const MAC = (navigator.platform.includes("Mac"));
const LINUX = (navigator.platform.includes("Linux"));
--- a/browser/extensions/pdfjs/content/PdfStreamConverter.jsm
+++ b/browser/extensions/pdfjs/content/PdfStreamConverter.jsm
@@ -37,17 +37,17 @@ ChromeUtils.defineModuleGetter(this, "Pr
"resource://gre/modules/PrivateBrowsingUtils.jsm");
ChromeUtils.defineModuleGetter(this, "PdfJsTelemetry",
"resource://pdf.js/PdfJsTelemetry.jsm");
ChromeUtils.defineModuleGetter(this, "PdfjsContentUtils",
"resource://pdf.js/PdfjsContentUtils.jsm");
-Cu.importGlobalProperties(["XMLHttpRequest"]);
+Cu.importGlobalProperties(["Window", "XMLHttpRequest"]);
var Svc = {};
XPCOMUtils.defineLazyServiceGetter(Svc, "mime",
"@mozilla.org/mime;1",
"nsIMIMEService");
function getBoolPref(pref, def) {
try {
@@ -81,17 +81,17 @@ function log(aMsg) {
Services.console.logStringMessage(msg);
dump(msg + "\n");
}
function getDOMWindow(aChannel, aPrincipal) {
var requestor = aChannel.notificationCallbacks ?
aChannel.notificationCallbacks :
aChannel.loadGroup.notificationCallbacks;
- var win = requestor.getInterface(Ci.nsIDOMWindow);
+ var win = requestor.getInterface(Window);
// Ensure the window wasn't navigated to something that is not PDF.js.
if (!win.document.nodePrincipal.equals(aPrincipal)) {
return null;
}
return win;
}
function getLocalizedStrings(path) {
--- a/dom/base/nsGlobalWindowInner.cpp
+++ b/dom/base/nsGlobalWindowInner.cpp
@@ -357,18 +357,23 @@ public:
{
if (!mWindow)
return NS_OK;
return mWindow->Observe(aSubject, aTopic, aData);
}
void Forget() { mWindow = nullptr; }
NS_IMETHOD GetInterface(const nsIID& aIID, void** aResult) override
{
- if (mWindow && aIID.Equals(NS_GET_IID(nsIDOMWindow)) && mWindow) {
- return mWindow->QueryInterface(aIID, aResult);
+ if (mWindow) {
+ if (aIID.Equals(NS_GET_IID(nsIDOMWindow))) {
+ return mWindow->QueryInterface(aIID, aResult);
+ }
+ if (aIID.Equals(NS_GET_IID(nsPIDOMWindowOuter))) {
+ return mWindow->GetOuterWindow()->QueryInterface(aIID, aResult);
+ }
}
return NS_NOINTERFACE;
}
void
ObserveStorageNotification(StorageEvent* aEvent,
const char16_t* aStorageType,
bool aPrivateBrowsing) override
--- a/dom/base/test/chrome/test_bug1339722.html
+++ b/dom/base/test/chrome/test_bug1339722.html
@@ -25,17 +25,17 @@ https://bugzilla.mozilla.org/show_bug.cg
const TOPIC = 'http-on-useragent-request';
Services.obs.addObserver({
observe(subject, topic, data) {
info('Got ' + topic);
Services.obs.removeObserver(this, TOPIC);
// Query window proxy so it triggers DOMWindowCreated.
let channel = subject.QueryInterface(Ci.nsIHttpChannel);
- let win = channel.notificationCallbacks.getInterface(Ci.nsIDOMWindow);
+ let win = channel.notificationCallbacks.getInterface(Window);
}
}, TOPIC);
let docShell = SpecialPowers.wrap(window)
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDocShell);
docShell.chromeEventHandler.addEventListener('DOMWindowCreated', function handler(e) {
docShell.chromeEventHandler.removeEventListener('DOMWindowCreated', handler);
--- a/dom/base/test/test_bug715041.xul
+++ b/dom/base/test/test_bug715041.xul
@@ -48,17 +48,17 @@ target="_blank">Mozilla Bug 715041</a>
set idleTime(timeInMS) {
this.idleTimeInMS = timeInMS;
},
getWindowFromObserver: function(observer) {
try {
var interfaceRequestor = observer.QueryInterface(Ci.nsIInterfaceRequestor);
- var window = interfaceRequestor.getInterface(Ci.nsIDOMWindow);
+ var window = interfaceRequestor.getInterface(Window);
return window;
}
catch (e) {}
return null;
},
testIdleBackService: function(observer, topic) {
--- a/dom/base/test/test_bug715041_removal.xul
+++ b/dom/base/test/test_bug715041_removal.xul
@@ -57,17 +57,17 @@ target="_blank">Mozilla Bug 715041</a>
set idleTime(timeInMS) {
this.idleTimeInMS = timeInMS;
},
getWindowFromObserver: function(observer) {
try {
var interfaceRequestor = observer.QueryInterface(Ci.nsIInterfaceRequestor);
- var window = interfaceRequestor.getInterface(Ci.nsIDOMWindow);
+ var window = interfaceRequestor.getInterface(Window);
return window;
}
catch (e) {}
return null;
},
testIdleBackService: function(observer, topic) {
--- a/mobile/android/components/ContentDispatchChooser.js
+++ b/mobile/android/components/ContentDispatchChooser.js
@@ -1,16 +1,18 @@
/* 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/. */
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/Messaging.jsm");
+Cu.importGlobalProperties(["Window"]);
+
function ContentDispatchChooser() {}
ContentDispatchChooser.prototype =
{
classID: Components.ID("5a072a22-1e66-4100-afc1-07aed8b62fc5"),
QueryInterface: ChromeUtils.generateQI([Ci.nsIContentDispatchChooser]),
@@ -37,17 +39,17 @@ ContentDispatchChooser.prototype =
aWindow.close();
}
},
ask: function ask(aHandler, aWindowContext, aURI, aReason) {
let window = null;
try {
if (aWindowContext)
- window = aWindowContext.getInterface(Ci.nsIDOMWindow);
+ window = aWindowContext.getInterface(Window);
} catch (e) { /* it's OK to not have a window */ }
// The current list is based purely on the scheme. Redo the query using the url to get more
// specific results.
aHandler = this.protoSvc.getProtocolHandlerInfoFromOS(aURI.spec, {});
// The first handler in the set is the Android Application Chooser (which will fall back to a default if one is set)
// If we have more than one option, let the OS handle showing a list (if needed).
--- a/mobile/android/components/NSSDialogService.js
+++ b/mobile/android/components/NSSDialogService.js
@@ -3,16 +3,18 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.defineModuleGetter(this, "Prompt",
"resource://gre/modules/Prompt.jsm");
+Cu.importGlobalProperties(["Window"]);
+
// -----------------------------------------------------------------------
// NSS Dialog Service
// -----------------------------------------------------------------------
function NSSDialogs() { }
NSSDialogs.prototype = {
classID: Components.ID("{cbc08081-49b6-4561-9c18-a7707a50bda1}"),
@@ -50,17 +52,17 @@ NSSDialogs.prototype = {
let escapedArgList = Array.from(argList, x => this.escapeHTML(x));
return this.bundle.formatStringFromName(aName, escapedArgList,
escapedArgList.length);
},
getPrompt: function(aTitle, aText, aButtons, aCtx) {
let win = null;
try {
- win = aCtx.getInterface(Ci.nsIDOMWindow);
+ win = aCtx.getInterface(Window);
} catch (e) {
}
return new Prompt({
window: win,
title: aTitle,
text: aText,
buttons: aButtons,
});
--- a/toolkit/mozapps/downloads/nsHelperAppDlg.js
+++ b/toolkit/mozapps/downloads/nsHelperAppDlg.js
@@ -98,16 +98,18 @@ const nsITimer = Ci.nsITimer;
var downloadModule = {};
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("resource://gre/modules/DownloadLastDir.jsm", downloadModule);
ChromeUtils.import("resource://gre/modules/DownloadPaths.jsm");
ChromeUtils.import("resource://gre/modules/DownloadUtils.jsm");
ChromeUtils.import("resource://gre/modules/Downloads.jsm");
ChromeUtils.import("resource://gre/modules/FileUtils.jsm");
+Cu.importGlobalProperties(["Window"]);
+
/* ctor
*/
function nsUnknownContentTypeDialog() {
// Initialize data properties.
this.mLauncher = null;
this.mContext = null;
this.mReason = null;
this.chosenApp = null;
@@ -131,17 +133,17 @@ nsUnknownContentTypeDialog.prototype = {
// one of those is via that route).
show(aLauncher, aContext, aReason) {
this.mLauncher = aLauncher;
this.mContext = aContext;
this.mReason = aReason;
// Cache some information in case this context goes away:
try {
- let parent = aContext.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);
+ let parent = aContext.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Window);
this._mDownloadDir = new downloadModule.DownloadLastDir(parent);
} catch (ex) {
Cu.reportError("Missing window information when showing nsIHelperAppLauncherDialog: " + ex);
}
const nsITimer = Ci.nsITimer;
this._showTimer = Cc["@mozilla.org/timer;1"]
.createInstance(nsITimer);
@@ -202,17 +204,17 @@ nsUnknownContentTypeDialog.prototype = {
let bundle =
Services.strings
.createBundle("chrome://mozapps/locale/downloads/unknownContentType.properties");
let parent;
let gDownloadLastDir;
try {
- parent = aContext.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);
+ parent = aContext.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Window);
} catch (ex) {}
if (parent) {
gDownloadLastDir = new downloadModule.DownloadLastDir(parent);
} else {
// Use the cached download info, but pick an arbitrary parent window
// because the original one is definitely gone (and nsIFilePicker doesn't like
// a null parent):
--- a/toolkit/mozapps/extensions/amContentHandler.js
+++ b/toolkit/mozapps/extensions/amContentHandler.js
@@ -5,16 +5,18 @@
"use strict";
const XPI_CONTENT_TYPE = "application/x-xpinstall";
const MSG_INSTALL_ADDON = "WebInstallerInstallAddonFromWebpage";
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
+Cu.importGlobalProperties(["Window"]);
+
function amContentHandler() {
}
amContentHandler.prototype = {
/**
* Handles a new request for an application/x-xpinstall file.
*
* @param aMimetype
@@ -33,17 +35,17 @@ amContentHandler.prototype = {
let uri = aRequest.URI;
let window = null;
let callbacks = aRequest.notificationCallbacks ?
aRequest.notificationCallbacks :
aRequest.loadGroup.notificationCallbacks;
if (callbacks)
- window = callbacks.getInterface(Ci.nsIDOMWindow);
+ window = callbacks.getInterface(Window);
aRequest.cancel(Cr.NS_BINDING_ABORTED);
let install = {
uri: uri.spec,
hash: null,
name: null,
icon: null,
--- a/toolkit/mozapps/handling/nsContentDispatchChooser.js
+++ b/toolkit/mozapps/handling/nsContentDispatchChooser.js
@@ -5,32 +5,34 @@
// Constants
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
const CONTENT_HANDLING_URL = "chrome://mozapps/content/handling/dialog.xul";
const STRINGBUNDLE_URL = "chrome://mozapps/locale/handling/handling.properties";
+Cu.importGlobalProperties(["Window"]);
+
// nsContentDispatchChooser class
function nsContentDispatchChooser() {
}
nsContentDispatchChooser.prototype =
{
classID: Components.ID("e35d5067-95bc-4029-8432-e8f1e431148d"),
// nsIContentDispatchChooser
ask: function ask(aHandler, aWindowContext, aURI, aReason) {
var window = null;
try {
if (aWindowContext)
- window = aWindowContext.getInterface(Ci.nsIDOMWindow);
+ window = aWindowContext.getInterface(Window);
} catch (e) { /* it's OK to not have a window */ }
var bundle = Services.strings.createBundle(STRINGBUNDLE_URL);
// TODO when this is hooked up for content, we will need different strings
// for most of these
var arr = [bundle.GetStringFromName("protocol.title"),
"",
--- a/toolkit/mozapps/update/tests/unit_aus_update/uiAutoPref.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/uiAutoPref.js
@@ -8,17 +8,17 @@ const WindowWatcher = {
},
QueryInterface: ChromeUtils.generateQI([Ci.nsIWindowWatcher])
};
const WindowMediator = {
getMostRecentWindow(aWindowType) {
executeSoon(check_status);
- return { getInterface: ChromeUtils.generateQI([Ci.nsIDOMWindow]) };
+ return { getInterface: ChromeUtils.generateQI([]) };
},
QueryInterface: ChromeUtils.generateQI([Ci.nsIWindowMediator])
};
function run_test() {
setupTestCommon();
// Calling do_get_profile prevents an error from being logged