From e5e55b4bac1d45dda0568d1b6cccb3387918573f Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Tue, 15 Mar 2016 07:50:17 +0000 Subject: Do not unregister the main/top frame. We never unregister the main/top frame. If the tab is navigating to another page, then there'll be a new top frame (with the same Id) along soon. If the tab is closing, then we'll tidy up in the chrome.tabs.onRemoved listener, below. This approach avoids a dependency on the order in which register and unregister events happens. See comment in #2053. --- background_scripts/main.coffee | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 2f6af0b9..87426dc3 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -384,11 +384,12 @@ Frames = port.postMessage name: "registerFrameId", chromeFrameId: frameId 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 + # Unregister the frame. However, we never unregister the main/top frame. If the tab is navigating to + # another page, then there'll be a new top frame (with the same Id) along soon. If the tab is closing, + # then we'll tidy up in the chrome.tabs.onRemoved listener, below. This approach avoids a dependency on + # the order in which register and unregister events happens. + if tabId of frameIdsForTab and tabId != 0 + frameIdsForTab[tabId] = frameIdsForTab[tabId].filter (fId) -> fId != frameId port.onDisconnect.removeListener listener handleFrameFocused = (request, sender) -> -- cgit v1.2.3