Bug 1568278. Remove various unnecessary QIs to nsIDOMWindow. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D39065

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Boris Zbarsky 2019-07-24 01:26:07 +00:00
Родитель 94926598b4
Коммит a818800ec5
26 изменённых файлов: 29 добавлений и 43 удалений

Просмотреть файл

@ -206,7 +206,7 @@ var AccessFu = {
observe: function observe(aSubject, aTopic, aData) {
switch (aTopic) {
case "domwindowopened": {
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
let win = aSubject;
win.addEventListener(
"load",
() => {

Просмотреть файл

@ -8156,8 +8156,7 @@ var CanvasPermissionPromptHelper = {
let browser;
if (aSubject instanceof Ci.nsIDOMWindow) {
let contentWindow = aSubject.QueryInterface(Ci.nsIDOMWindow);
browser = contentWindow.docShell.chromeEventHandler;
let browser = aSubject.docShell.chromeEventHandler;
} else {
browser = aSubject;
}
@ -8603,7 +8602,6 @@ function BrowserOpenAddonsMgr(aView) {
if (aView) {
aSubject.loadView(aView);
}
aSubject.QueryInterface(Ci.nsIDOMWindow);
aSubject.focus();
resolve(aSubject);
}, "EM-loaded");

Просмотреть файл

@ -19,10 +19,9 @@ const PAGE = `data:text/html,<a id="target" href="%23" onclick="window.open('htt
*/
function promiseNewWindow() {
return new Promise(resolve => {
let observer = (subject, topic, data) => {
let observer = (win, topic, data) => {
if (topic == "domwindowopened") {
Services.ww.unregisterNotification(observer);
let win = subject.QueryInterface(Ci.nsIDOMWindow);
win.addEventListener(
"load",
function() {

Просмотреть файл

@ -717,7 +717,7 @@ WindowHelper.prototype = {
open() {
let wh = this;
function windowObserver(aSubject, aTopic, aData) {
function windowObserver(win, aTopic, aData) {
if (aTopic != "domwindowopened") {
return;
}
@ -725,7 +725,6 @@ WindowHelper.prototype = {
Services.ww.unregisterNotification(windowObserver);
var loaded = false;
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
win.addEventListener(
"load",

Просмотреть файл

@ -23,7 +23,7 @@ add_task(async function() {
let observerWindowOpened = {
observe(aSubject, aTopic, aData) {
if (aTopic == "domwindowopened") {
privateWindow = aSubject.QueryInterface(Ci.nsIDOMWindow);
privateWindow = aSubject;
privateWindow.addEventListener(
"load",
function() {

Просмотреть файл

@ -23,7 +23,7 @@ add_task(async function() {
let observerWindowOpened = {
observe(aSubject, aTopic, aData) {
if (aTopic == "domwindowopened") {
newWindow = aSubject.QueryInterface(Ci.nsIDOMWindow);
newWindow = aSubject;
newWindow.addEventListener(
"load",
function() {

Просмотреть файл

@ -497,12 +497,11 @@ function open_properties_dialog(test) {
);
// Wait for the Properties dialog.
function windowObserver(aSubject, aTopic, aData) {
function windowObserver(observerWindow, aTopic, aData) {
if (aTopic != "domwindowopened") {
return;
}
Services.ww.unregisterNotification(windowObserver);
let observerWindow = aSubject.QueryInterface(Ci.nsIDOMWindow);
waitForFocus(async () => {
// Ensure overlay is loaded
await BrowserTestUtils.waitForCondition(

Просмотреть файл

@ -203,7 +203,7 @@ var withBookmarksDialog = async function(
data
) {
if (topic == "domwindowopened") {
let win = subject.QueryInterface(Ci.nsIDOMWindow);
let win = subject;
win.addEventListener(
"load",
function() {

Просмотреть файл

@ -255,7 +255,6 @@ var SaveToPocket = {
observe(subject, topic, data) {
if (topic == "browser-delayed-startup-finished") {
subject.QueryInterface(Ci.nsIDOMWindow);
// We only get here if pocket is disabled; the observer is removed when
// we're enabled.
this.updateElementsInWindow(subject, false);

Просмотреть файл

@ -190,7 +190,7 @@ add_task(async function test() {
// We also want to catch the extra windows (there should be 2), so we need to observe domwindowopened
Services.ww.registerNotification(function observer(aSubject, aTopic, aData) {
if (aTopic == "domwindowopened") {
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
let win = aSubject;
win.addEventListener(
"load",
function() {

Просмотреть файл

@ -93,7 +93,7 @@ add_task(async function test() {
// We also want to catch the 2nd window, so we need to observe domwindowopened
Services.ww.registerNotification(function observer(aSubject, aTopic, aData) {
if (aTopic == "domwindowopened") {
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
let win = aSubject;
win.addEventListener(
"load",
function() {

Просмотреть файл

@ -88,7 +88,7 @@ function test() {
if (aTopic == "domwindowopened") {
Services.ww.unregisterNotification(windowObserver);
newWindow = aSubject.QueryInterface(Ci.nsIDOMWindow);
newWindow = aSubject;
newWindow.addEventListener(
"load",
function() {

Просмотреть файл

@ -73,7 +73,7 @@ function test() {
function firstWindowObserver(aSubject, aTopic, aData) {
if (aTopic == "domwindowopened") {
newWindow = aSubject.QueryInterface(Ci.nsIDOMWindow);
newWindow = aSubject;
Services.ww.unregisterNotification(firstWindowObserver);
}
}

Просмотреть файл

@ -150,7 +150,7 @@ function waitForBrowserState(aState, aSetStateCallback) {
// coming from them when creating a multi-window state.
function windowObserver(aSubject, aTopic, aData) {
if (aTopic == "domwindowopened") {
let newWindow = aSubject.QueryInterface(Ci.nsIDOMWindow);
let newWindow = aSubject;
newWindow.addEventListener(
"load",
function() {

Просмотреть файл

@ -251,7 +251,7 @@ var ProcessHangMonitor = {
case "domwindowopened": {
// Install event listeners on the new window in case one of
// its tabs is already hung.
let win = subject.QueryInterface(Ci.nsIDOMWindow);
let win = subject;
let listener = ev => {
win.removeEventListener("load", listener, true);
this.updateWindows();
@ -261,7 +261,7 @@ var ProcessHangMonitor = {
}
case "domwindowclosed": {
let win = subject.QueryInterface(Ci.nsIDOMWindow);
let win = subject;
this.onWindowClosed(win);
break;
}

Просмотреть файл

@ -45,7 +45,7 @@ function test() {
function windowObserver(subject, topic, data) {
if (topic == "domwindowopened") {
const win = subject.QueryInterface(Ci.nsIDOMWindow);
const win = subject;
win.addEventListener(
"load",
function() {

Просмотреть файл

@ -42,7 +42,7 @@ function trackScratchpadWindows() {
return new Promise(resolve => {
Services.ww.registerNotification(function observer(subject, topic) {
if (topic == "domwindowopened") {
const win = subject.QueryInterface(Ci.nsIDOMWindow);
const win = subject;
win.addEventListener(
"load",
function() {

Просмотреть файл

@ -139,7 +139,7 @@
// this point, so ideally we would test for that. but i can't find a
// property that reflects whether or not UIReady has been fired, so
// for now just assume the window is ready
attachTo(enumerator.getNext().QueryInterface(Ci.nsIDOMWindow));
attachTo(enumerator.getNext());
}
Services.wm.addListener(browserListener);
}

Просмотреть файл

@ -765,7 +765,7 @@ var BrowserTestUtils = {
return new Promise(resolve => {
async function observer(subject, topic, data) {
if (topic == "domwindowopened" && (!win || subject === win)) {
let observedWindow = subject.QueryInterface(Ci.nsIDOMWindow);
let observedWindow = subject;
if (checkFn && !(await checkFn(observedWindow))) {
return;
}
@ -791,7 +791,7 @@ var BrowserTestUtils = {
function observer(subject, topic, data) {
if (topic == "domwindowclosed" && (!win || subject === win)) {
Services.ww.unregisterNotification(observer);
resolve(subject.QueryInterface(Ci.nsIDOMWindow));
resolve(subject);
}
}
Services.ww.registerNotification(observer);

Просмотреть файл

@ -23,12 +23,11 @@ const chromeScript = SpecialPowers.loadChromeScript(_ => {
sendAsyncMessage("waitForXULAlert", false);
}, 2000);
var windowObserver = function(aSubject, aTopic, aData) {
var windowObserver = function(win, aTopic, aData) {
if (aTopic != "domwindowopened") {
return;
}
var win = aSubject.QueryInterface(Ci.nsIDOMWindow);
win.addEventListener("load", function() {
let windowType = win.document.documentElement.getAttribute("windowtype");
if (windowType == "alert:alert") {

Просмотреть файл

@ -26,7 +26,7 @@ const chromeScript = SpecialPowers.loadChromeScript(_ => {
sendAsyncMessage("waitedForPosition", null);
}, 2000);
var windowObserver = function(aSubject, aTopic, aData) {
var windowObserver = function(win, aTopic, aData) {
if (aTopic != "domwindowopened") {
return;
}
@ -36,7 +36,6 @@ const chromeScript = SpecialPowers.loadChromeScript(_ => {
Services.ww.unregisterNotification(windowObserver);
var win = aSubject.QueryInterface(Ci.nsIDOMWindow);
win.addEventListener("pageshow", function() {
var x = win.screenX;
var y = win.screenY;

Просмотреть файл

@ -631,8 +631,7 @@ class _RFPHelper {
}
}
_handleDOMWindowOpened(aSubject) {
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
_handleDOMWindowOpened(win) {
let self = this;
win.addEventListener(

Просмотреть файл

@ -65,17 +65,14 @@ var gViewSourceUtils = {
}
// No browser window created yet, try to create one.
let utils = this;
Services.ww.registerNotification(function onOpen(subj, topic) {
Services.ww.registerNotification(function onOpen(win, topic) {
if (
subj.document.documentURI !== "about:blank" ||
win.document.documentURI !== "about:blank" ||
topic !== "domwindowopened"
) {
return;
}
Services.ww.unregisterNotification(onOpen);
let win = subj
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
win.addEventListener(
"load",
() => {

Просмотреть файл

@ -40,7 +40,7 @@ function promiseCaretPromptOpened() {
function observer(subject, topic, data) {
if (topic == "domwindowopened") {
Services.ww.unregisterNotification(observer);
let win = subject.QueryInterface(Ci.nsIDOMWindow);
let win = subject;
BrowserTestUtils.waitForEvent(
win,
"load",

Просмотреть файл

@ -24,14 +24,13 @@ var args = {
function test() {
waitForExplicitFinish();
let windowObserver = function(aSubject, aTopic, aData) {
let windowObserver = function(win, aTopic, aData) {
if (aTopic != "domwindowopened") {
return;
}
Services.ww.unregisterNotification(windowObserver);
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
win.addEventListener(
"load",
function() {
@ -92,13 +91,12 @@ function bug523784_test1(win) {
}
function bug523784_test2(win) {
let windowObserver = function(aSubject, aTopic, aData) {
let windowObserver = function(win, aTopic, aData) {
if (aTopic != "domwindowopened") {
return;
}
Services.ww.unregisterNotification(windowObserver);
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
win.addEventListener(
"load",
function() {

Просмотреть файл

@ -1279,7 +1279,7 @@ function runTestPasswordFieldOnDialog() {
observe(subject, topic, data) {
if (topic === "domwindowopened") {
ok(true, "dialog window is created");
dialog = subject.QueryInterface(Ci.nsIDOMWindow);
dialog = subject;
dialog.addEventListener("load", onPasswordDialogLoad);
}
},