From 17a24b4b3df24c5b3a354dd195e2f4fe3e4bfb54 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Tue, 5 Apr 2016 06:41:56 +0100 Subject: Unregister frame on "unload". It seems we cannot rely on the port being disconnected to unregister a frame. So we need to unregister it on "unload". --- background_scripts/main.coffee | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 8b1e61ce..6dd3906f 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -292,12 +292,6 @@ Frames = [tabId, frameId] = [sender.tab.id, sender.frameId] port.postMessage handler: "registerFrameId", chromeFrameId: frameId - port.onDisconnect.addListener listener = -> - if tabId of frameIdsForTab - frameIdsForTab[tabId] = (fId for fId in frameIdsForTab[tabId] when fId != frameId) - if tabId of portsForTab - delete portsForTab[tabId][frameId] - # Return our onMessage handler for this port. (request, port) => this[request.handler] {request, tabId, frameId, port} @@ -306,6 +300,12 @@ Frames = frameIdsForTab[tabId].push frameId unless frameId in frameIdsForTab[tabId] ?= [] (portsForTab[tabId] ?= {})[frameId] = port + unregsterFrame: ({tabId, frameId}) -> + if tabId of frameIdsForTab + frameIdsForTab[tabId] = (fId for fId in frameIdsForTab[tabId] when fId != frameId) + if tabId of portsForTab + delete portsForTab[tabId][frameId] + isEnabledForUrl: ({request, tabId, port}) -> urlForTab[tabId] = request.url if request.frameIsFocused enabledState = Exclusions.isEnabledForUrl request.url -- cgit v1.2.3