From f63b90e6a7da726d415feac594f4da325797e544 Mon Sep 17 00:00:00 2001 From: Jared Hirsch Date: Wed, 3 May 2017 12:09:49 -0700 Subject: [PATCH] Do not update toolbar button state inside tab 'activated' event handler According to kmag, webextension buttons have per-tab state, so setting the button enabled or disabled on update should be enough. Updating the icon on tab activated may be causing performance issues. See https://bugzilla.mozilla.org/show_bug.cgi?id=1361792 for details. Also remove tab.active check, so that non-active tabs can catch button updates (https://bugzilla.mozilla.org/show_bug.cgi?id=1362234#c2) --- addon/webextension/background/main.js | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/addon/webextension/background/main.js b/addon/webextension/background/main.js index 38fda6aef6..e44367c364 100644 --- a/addon/webextension/background/main.js +++ b/addon/webextension/background/main.js @@ -199,7 +199,7 @@ this.main = (function() { } browser.tabs.onUpdated.addListener(catcher.watchFunction((id, info, tab) => { - if (info.url && tab.active) { + if (info.url) { if (urlEnabled(info.url)) { enableButton(tab.id); } else if (hasSeenOnboarding) { @@ -208,20 +208,6 @@ this.main = (function() { } }, true)); - browser.tabs.onActivated.addListener(catcher.watchFunction(({tabId, windowId}) => { - catcher.watchPromise(browser.tabs.get(tabId).then((tab) => { - // onActivated may fire before the url is set - if (!tab.url) { - return; - } - if (urlEnabled(tab.url)) { - enableButton(tabId); - } else if (hasSeenOnboarding) { - disableButton(tabId); - } - }), true); - }, true)); - communication.register("sendEvent", (sender, ...args) => { catcher.watchPromise(sendEvent(...args)); // We don't wait for it to complete: