Bug 1185893 - abuse of bind(this) with add/removeEventListener r=gijs

This commit is contained in:
Nazim Can Altinova 2015-08-21 15:31:00 +01:00
parent a4e008a44f
commit 80221923ab
3 changed files with 9 additions and 6 deletions

View File

@ -332,7 +332,7 @@ WindowListener.prototype = {
let domwindow = aXULWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
domwindow.addEventListener("load", function onLoad(aEvent) {
let onLoad = aEvent => {
is(domwindow.document.location.href, this.test_url,
"Opened Window is expected: "+ this.test_title);
if (this.callback_onSuccess) {
@ -352,7 +352,8 @@ WindowListener.prototype = {
domwindow.close();
executeSoon(this.callBack_onFinalize);
}
}.bind(this), true);
};
domwindow.addEventListener("load", onLoad, true);
},
onCloseWindow: function(aXULWindow) {},
onWindowTitleChange: function(aXULWindow, aNewTitle) {},

View File

@ -898,7 +898,7 @@ let MozLoopServiceInternal = {
return;
}
chatbox.addEventListener("DOMContentLoaded", function loaded(event) {
let loaded = event => {
if (event.target != chatbox.contentDocument) {
return;
}
@ -987,7 +987,8 @@ let MozLoopServiceInternal = {
pc_static.registerPeerConnectionLifecycleCallback(onPCLifecycleChange);
UITour.notify("Loop:ChatWindowOpened");
}.bind(this), true);
};
chatbox.addEventListener("DOMContentLoaded", loaded, true);
};
let chatboxInstance = Chat.open(null, origin, "", url, undefined, undefined,

View File

@ -292,7 +292,7 @@ Cookies.prototype = {
_readCookieFile: function C__readCookieFile(aFile, aCallback) {
let fileReader = Cc["@mozilla.org/files/filereader;1"].
createInstance(Ci.nsIDOMFileReader);
fileReader.addEventListener("loadend", (function onLoadEnd() {
let onLoadEnd = () => {
fileReader.removeEventListener("loadend", onLoadEnd, false);
if (fileReader.readyState != fileReader.DONE) {
@ -310,7 +310,8 @@ Cookies.prototype = {
} finally {
aCallback(success);
}
}).bind(this), false);
};
fileReader.addEventListener("loadend", onLoadEnd, false);
fileReader.readAsText(new File(aFile));
},