aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts
diff options
context:
space:
mode:
authorStephen Blott2016-03-14 14:06:22 +0000
committerStephen Blott2016-03-17 11:17:03 +0000
commita871ffd82b0e8b8ce10b6228819a4ff12ae952bb (patch)
treef8113f1d2bd969a41be637ce7f9a34ae51a2d1b6 /background_scripts
parent8be6acd660be212926bff495c8e8f83d3f5917be (diff)
downloadvimium-a871ffd82b0e8b8ce10b6228819a4ff12ae952bb.tar.bz2
Tweaks and fixes for #2053.
Tweaks, plus... Reinstate deletion of two cache entries on tab close.
Diffstat (limited to 'background_scripts')
-rw-r--r--background_scripts/main.coffee19
1 files changed, 10 insertions, 9 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee
index 6fddb6e3..2f6af0b9 100644
--- a/background_scripts/main.coffee
+++ b/background_scripts/main.coffee
@@ -383,14 +383,13 @@ Frames =
(frameIdsForTab[tabId] ?= []).push frameId
port.postMessage name: "registerFrameId", chromeFrameId: frameId
- port.onDisconnect.addListener ->
- if frameId == 0 # This is the top frame in the tab.
- delete frameIdsForTab[tabId]
- else
- if tabId of frameIdsForTab
+ port.onDisconnect.addListener listener = ->
+ if tabId of frameIdsForTab
+ if frameId == 0 # This is the top frame in the tab.
+ delete frameIdsForTab[tabId]
+ else
frameIdsForTab[tabId] = frameIdsForTab[tabId].filter (fId) -> fId != frameId
- # Sub-frames can connect before the top frame; so we can't rely on seeing the top frame at all.
- delete frameIdsForTab[tabId] if frameIdsForTab[tabId].length == 0
+ port.onDisconnect.removeListener listener
handleFrameFocused = (request, sender) ->
[tabId, frameId] = [sender.tab.id, sender.frameId]
@@ -445,9 +444,11 @@ sendRequestHandlers =
# We always remove chrome.storage.local/findModeRawQueryListIncognito on startup.
chrome.storage.local.remove "findModeRawQueryListIncognito"
-# Remove chrome.storage.local/findModeRawQueryListIncognito if there are no remaining incognito-mode windows.
-# Since the common case is that there are none to begin with, we first check whether the key is set at all.
+# Tidy up tab caches when tabs are removed. Also remove chrome.storage.local/findModeRawQueryListIncognito if
+# there are no remaining incognito-mode windows. Since the common case is that there are none to begin with,
+# we first check whether the key is set at all.
chrome.tabs.onRemoved.addListener (tabId) ->
+ delete cache[tabId] for cache in [frameIdsForTab, urlForTab]
chrome.storage.local.get "findModeRawQueryListIncognito", (items) ->
if items.findModeRawQueryListIncognito
chrome.windows.getAll null, (windows) ->