From 6c737f2554fdec0082cd9fc2fec421407dfafb49 Mon Sep 17 00:00:00 2001 From: Sebastian Hengst Date: Tue, 1 Aug 2017 20:55:03 +0200 Subject: [PATCH] Backed out changeset ae8bd889b02d (bug 1385090) for eslint failures in AboutNewTab.jsm and RemotePageManager.jsm. r=backout on a CLOSED TREE --- .../lib/ActivityStreamMessageChannel.jsm | 21 +++++++-------- browser/modules/AboutNewTab.jsm | 27 ++++++------------- toolkit/modules/RemotePageManager.jsm | 12 ++------- 3 files changed, 19 insertions(+), 41 deletions(-) diff --git a/browser/extensions/activity-stream/lib/ActivityStreamMessageChannel.jsm b/browser/extensions/activity-stream/lib/ActivityStreamMessageChannel.jsm index 6b44369ffe1b..a22fbf97434e 100644 --- a/browser/extensions/activity-stream/lib/ActivityStreamMessageChannel.jsm +++ b/browser/extensions/activity-stream/lib/ActivityStreamMessageChannel.jsm @@ -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(); + } } /** diff --git a/browser/modules/AboutNewTab.jsm b/browser/modules/AboutNewTab.jsm index 6ef41bf25f9f..574a4410670d 100644 --- a/browser/modules/AboutNewTab.jsm +++ b/browser/modules/AboutNewTab.jsm @@ -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(); } }; diff --git a/toolkit/modules/RemotePageManager.jsm b/toolkit/modules/RemotePageManager.jsm index 12878633dbc8..6d8249b4967e 100644 --- a/toolkit/modules/RemotePageManager.jsm +++ b/toolkit/modules/RemotePageManager.jsm @@ -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); } },