Backed out changeset ae8bd889b02d (bug 1385090) for eslint failures in AboutNewTab.jsm and RemotePageManager.jsm. r=backout on a CLOSED TREE

This commit is contained in:
Sebastian Hengst 2017-08-01 20:55:03 +02:00
Родитель b18ff3f722
Коммит 6c737f2554
3 изменённых файлов: 19 добавлений и 41 удалений

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

@ -126,9 +126,11 @@ this.ActivityStreamMessageChannel = class ActivityStreamMessageChannel {
* between the main process and child pages
*/
createChannel() {
// Receive AboutNewTab's Remote Pages instance, if it exists, on override
const channel = this.pageURL === ABOUT_NEW_TAB_URL && AboutNewTab.override(true);
this.channel = channel || new RemotePages(this.pageURL);
// RemotePageManager must be disabled for about:newtab, since only one can exist at once
if (this.pageURL === ABOUT_NEW_TAB_URL) {
AboutNewTab.override();
}
this.channel = new RemotePages(this.pageURL);
this.channel.addMessageListener("RemotePage:Init", this.onNewTabInit);
this.channel.addMessageListener("RemotePage:Load", this.onNewTabLoad);
this.channel.addMessageListener("RemotePage:Unload", this.onNewTabUnload);
@ -139,16 +141,11 @@ this.ActivityStreamMessageChannel = class ActivityStreamMessageChannel {
* destroyChannel - Destroys the RemotePages channel
*/
destroyChannel() {
this.channel.removeMessageListener("RemotePage:Init", this.onNewTabInit);
this.channel.removeMessageListener("RemotePage:Load", this.onNewTabLoad);
this.channel.removeMessageListener("RemotePage:Unload", this.onNewTabUnload);
this.channel.removeMessageListener(this.incomingMessageName, this.onMessage);
if (this.pageURL === ABOUT_NEW_TAB_URL) {
AboutNewTab.reset(this.channel);
} else {
this.channel.destroy();
}
this.channel.destroy();
this.channel = null;
if (this.pageURL === ABOUT_NEW_TAB_URL) {
AboutNewTab.reset();
}
}
/**

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

@ -26,14 +26,14 @@ var AboutNewTab = {
isOverridden: false,
init(pageListener) {
init() {
if (this.isOverridden) {
return;
}
this.pageListener = pageListener || new RemotePages("about:newtab");
this.pageListener.addMessageListener("NewTab:Customize", this.customize);
this.pageListener = new RemotePages("about:newtab");
this.pageListener.addMessageListener("NewTab:Customize", this.customize.bind(this));
this.pageListener.addMessageListener("NewTab:MaybeShowMigrateMessage",
this.maybeShowMigrateMessage);
this.maybeShowMigrateMessage.bind(this));
},
maybeShowMigrateMessage({ target }) {
@ -56,24 +56,13 @@ var AboutNewTab = {
}
},
override(shouldPassPageListener) {
this.isOverridden = true;
const pageListener = this.pageListener;
if (!pageListener) {
return;
}
if (shouldPassPageListener) {
this.pageListener = null;
pageListener.removeMessageListener("NewTab:Customize", this.customize);
pageListener.removeMessageListener("NewTab:MaybeShowMigrateMessage",
this.maybeShowMigrateMessage);
return pageListener;
}
override() {
this.uninit();
this.isOverridden = true;
},
reset(pageListener) {
reset() {
this.isOverridden = false;
this.init(pageListener);
this.init();
}
};

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

@ -6,7 +6,7 @@
this.EXPORTED_SYMBOLS = ["RemotePages", "RemotePageManager", "PageListener"];
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
@ -127,15 +127,7 @@ RemotePages.prototype = {
// Sends a message to all known pages
sendAsyncMessage(name, data = null) {
for (let port of this.messagePorts.values()) {
try {
port.sendAsyncMessage(name, data);
}
catch (e) {
// Unless the port is in the process of unloading, something strange
// happened but allow other ports to receive the message
if (e.result !== Cr.NS_ERROR_NOT_INITIALIZED)
Cu.reportError(e);
}
port.sendAsyncMessage(name, data);
}
},