Bug 1449631 part 1. Remove JS uses of nsIDOMEventTarget. r=smaug

MozReview-Commit-ID: CCHCZjMgInu
This commit is contained in:
Boris Zbarsky 2018-04-05 13:42:40 -04:00
Родитель 25b7539ba9
Коммит a4c5e65aa3
12 изменённых файлов: 15 добавлений и 14 удалений

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

@ -23,7 +23,7 @@ function test() {
observe(aSubject, aTopic, aData) { observe(aSubject, aTopic, aData) {
if (aTopic == "domwindowopened") { if (aTopic == "domwindowopened") {
ok(false, "Alert window opened"); ok(false, "Alert window opened");
let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget); let win = aSubject;
win.addEventListener("load", function() { win.addEventListener("load", function() {
win.close(); win.close();
}, {once: true}); }, {once: true});

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

@ -98,7 +98,7 @@ var windowObserver = {
return; return;
} }
let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget); let win = aSubject;
win.addEventListener("load", function(event) { win.addEventListener("load", function(event) {
if (win.location == UCT_URI) { if (win.location == UCT_URI) {

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

@ -46,7 +46,7 @@ interface nsIScriptContext;
interface nsIDOMEventListener; interface nsIDOMEventListener;
interface nsIDOMEvent; interface nsIDOMEvent;
[scriptable, builtinclass, uuid(9a78ac3c-9507-4d00-b2d6-10b508d2ec31)] [uuid(9a78ac3c-9507-4d00-b2d6-10b508d2ec31)]
interface nsIDOMEventTarget : nsISupports interface nsIDOMEventTarget : nsISupports
{ {
/** /**

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

@ -31,7 +31,7 @@ SpecialPowers.pushPrefEnv({'set':[
is(result.processType, SpecialPowers.Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT, is(result.processType, SpecialPowers.Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT,
"The frame script is running in a real distinct child process"); "The frame script is running in a real distinct child process");
ok(result.hasCorrectInterface, ok(result.hasCorrectInterface,
"docshell.chromeEventHandler has nsIDOMEventTarget interface"); "docshell.chromeEventHandler has EventTarget interface");
}); });
@ -52,7 +52,8 @@ SpecialPowers.pushPrefEnv({'set':[
var chromeEventHandler = docShell.chromeEventHandler; var chromeEventHandler = docShell.chromeEventHandler;
sendAsyncMessage("chromeEventHandler", { sendAsyncMessage("chromeEventHandler", {
processType: Services.appinfo.processType, processType: Services.appinfo.processType,
hasCorrectInterface: chromeEventHandler instanceof Ci.nsIDOMEventTarget hasCorrectInterface: chromeEventHandler &&
EventTarget.isInstance(chromeEventHandler),
}); });
/* /*

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

@ -426,7 +426,9 @@ class FilteringMessageManagerMap extends Map {
broker = new this._constructor(this.messageName, this.callback, target); broker = new this._constructor(this.messageName, this.callback, target);
this.set(target, broker); this.set(target, broker);
if (target instanceof Ci.nsIDOMEventTarget) { // XXXbz if target is really known to be a MessageListenerManager,
// do we need this isInstance check?
if (EventTarget.isInstance(target)) {
let onUnload = event => { let onUnload = event => {
target.removeEventListener("unload", onUnload); target.removeEventListener("unload", onUnload);
this.delete(target); this.delete(target);

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

@ -89,7 +89,7 @@ add_task(async function test_setup() {
Services.ww.registerNotification(function notification(aSubject, aTopic, aData) { Services.ww.registerNotification(function notification(aSubject, aTopic, aData) {
if (aTopic == "domwindowopened") { if (aTopic == "domwindowopened") {
let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget); let win = aSubject;
SimpleTest.waitForFocus(function() { SimpleTest.waitForFocus(function() {
EventUtils.sendKey("RETURN", win); EventUtils.sendKey("RETURN", win);
}, win); }, win);

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

@ -75,7 +75,7 @@ add_task(async function test() {
if (aTopic == "domwindowclosed") if (aTopic == "domwindowclosed")
Services.ww.unregisterNotification(notification); Services.ww.unregisterNotification(notification);
else if (aTopic == "domwindowopened") { else if (aTopic == "domwindowopened") {
let targetWin = aSubject.QueryInterface(Ci.nsIDOMEventTarget); let targetWin = aSubject;
SimpleTest.waitForFocus(function() { SimpleTest.waitForFocus(function() {
EventUtils.sendKey("RETURN", targetWin); EventUtils.sendKey("RETURN", targetWin);
}, targetWin); }, targetWin);

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

@ -86,7 +86,7 @@ add_task(async function test() {
if (aTopic == "domwindowclosed") if (aTopic == "domwindowclosed")
Services.ww.unregisterNotification(notification); Services.ww.unregisterNotification(notification);
else if (aTopic == "domwindowopened") { else if (aTopic == "domwindowopened") {
let targetWin = aSubject.QueryInterface(Ci.nsIDOMEventTarget); let targetWin = aSubject;
SimpleTest.waitForFocus(function() { SimpleTest.waitForFocus(function() {
EventUtils.sendKey("RETURN", targetWin); EventUtils.sendKey("RETURN", targetWin);
}, targetWin); }, targetWin);

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

@ -366,7 +366,6 @@ function openTabPrompt(domWin, tabPrompt, args) {
let frameMM = docShell.QueryInterface(Ci.nsIInterfaceRequestor) let frameMM = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager); .getInterface(Ci.nsIContentFrameMessageManager);
frameMM.QueryInterface(Ci.nsIDOMEventTarget);
// We provide a callback so the prompt can close itself. We don't want to // We provide a callback so the prompt can close itself. We don't want to
// wait for this event loop to return... Otherwise the presence of other // wait for this event loop to return... Otherwise the presence of other
@ -447,7 +446,6 @@ function openRemotePrompt(domWin, args, tabPrompt) {
let closed = false; let closed = false;
let frameMM = docShell.getInterface(Ci.nsIContentFrameMessageManager); let frameMM = docShell.getInterface(Ci.nsIContentFrameMessageManager);
frameMM.QueryInterface(Ci.nsIDOMEventTarget);
// It should be hard or impossible to cause a window to create multiple // It should be hard or impossible to cause a window to create multiple
// prompts, but just in case, give our prompt an ID. // prompts, but just in case, give our prompt an ID.

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

@ -14,7 +14,7 @@ let UCTObserver = {
closed: PromiseUtils.defer(), closed: PromiseUtils.defer(),
observe(aSubject, aTopic, aData) { observe(aSubject, aTopic, aData) {
let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget); let win = aSubject;
switch (aTopic) { switch (aTopic) {
case "domwindowopened": case "domwindowopened":

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

@ -34,7 +34,7 @@ add_task(async function test_unknownContentType_dialog_layout() {
closed: PromiseUtils.defer(), closed: PromiseUtils.defer(),
observe(aSubject, aTopic, aData) { observe(aSubject, aTopic, aData) {
let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget); let win = aSubject;
switch (aTopic) { switch (aTopic) {
case "domwindowopened": case "domwindowopened":

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

@ -168,7 +168,7 @@ this.__defineGetter__("gCallback", function() {
*/ */
const gWindowObserver = { const gWindowObserver = {
observe: function WO_observe(aSubject, aTopic, aData) { observe: function WO_observe(aSubject, aTopic, aData) {
let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget); let win = aSubject;
if (aTopic == "domwindowclosed") { if (aTopic == "domwindowclosed") {
if (win.location != URI_UPDATE_PROMPT_DIALOG) { if (win.location != URI_UPDATE_PROMPT_DIALOG) {