diff --git a/background/background.js b/background/background.js index 6d15e8d4..94da67a7 100644 --- a/background/background.js +++ b/background/background.js @@ -147,11 +147,18 @@ prefs.initializing.then(() => { refreshAllIcons(); }); -navigatorUtil.onUrlChange(({tabId, frameId}, type) => { +navigatorUtil.onUrlChange(({tabId, frameId, transitionQualifiers}, type) => { if (type === 'committed' && !frameId) { - // it seems that the tab icon would be reset when pressing F5. We - // invalidate the cache here so it would be refreshed. + // it seems that the tab icon would be reset by navigation. We + // invalidate the cache here so it would be refreshed by `apply.js`. tabIcons.delete(tabId); + + // however, if the tab was swapped in by forward/backward buttons, + // `apply.js` doesn't notify the background to update the icon, + // so we have to refresh it manually. + if (transitionQualifiers.includes('forward_back')) { + msg.sendTab(tabId, {method: 'updateCount'}).catch(msg.broadcastError); + } } }); diff --git a/background/navigator-util.js b/background/navigator-util.js index fb91d65c..ab08dffa 100644 --- a/background/navigator-util.js +++ b/background/navigator-util.js @@ -23,16 +23,19 @@ const navigatorUtil = (() => { chrome.webNavigation.onCommitted.addListener(data => fixNTPUrl(data) .then(() => executeCallbacks(handler.urlChange, data, 'committed')) + .catch(console.error) ); chrome.webNavigation.onHistoryStateUpdated.addListener(data => fixNTPUrl(data) .then(() => executeCallbacks(handler.urlChange, data, 'historyStateUpdated')) + .catch(console.error) ); chrome.webNavigation.onReferenceFragmentUpdated.addListener(data => fixNTPUrl(data) .then(() => executeCallbacks(handler.urlChange, data, 'referenceFragmentUpdated')) + .catch(console.error) ); } diff --git a/content/apply.js b/content/apply.js index 51df8ab7..e8d780b0 100644 --- a/content/apply.js +++ b/content/apply.js @@ -219,6 +219,10 @@ const APPLY = (() => { } }); break; + + case 'updateCount': + updateCount(); + break; } } @@ -336,11 +340,6 @@ const APPLY = (() => { } docRootObserver.firstStart(); - // FIXME - // if (FF_BUG461 && (gotNewStyles || styles.needTransitionPatch)) { - // setContentsInPageContext(); - // } - if (!isOwnPage && !docRewriteObserver && styleElements.size) { initDocRewriteObserver(); }