diff options
| author | Stephen Blott | 2016-03-15 08:13:28 +0000 |
|---|---|---|
| committer | Stephen Blott | 2016-03-17 11:17:03 +0000 |
| commit | 5a6cb052b14fcaa11189b7760ebf480a38db682d (patch) | |
| tree | 15b61017183c62a07d613498b189f7f018faf135 | |
| parent | e5e55b4bac1d45dda0568d1b6cccb3387918573f (diff) | |
| download | vimium-5a6cb052b14fcaa11189b7760ebf480a38db682d.tar.bz2 | |
Add filter for top frame when registering a frame.
We treat the top frame specially (because it always has a frameId of 0).
See point "Two" in this comment:
- https://github.com/philc/vimium/pull/2053#issuecomment-196707223
| -rw-r--r-- | background_scripts/main.coffee | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 87426dc3..1aeef3a1 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -380,14 +380,17 @@ openOptionsPageInNewTab = -> Frames = onConnect: (sender, port) -> [tabId, frameId] = [sender.tab.id, sender.frameId] - (frameIdsForTab[tabId] ?= []).push frameId + # We always add frameId 0, the top frame, automatically, and never unregister it. + frameIdsForTab[tabId] ?= [0] + frameIdsForTab[tabId].push frameId unless frameId == 0 port.postMessage name: "registerFrameId", chromeFrameId: frameId port.onDisconnect.addListener listener = -> # 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. + # then we'll tidy up in the chrome.tabs.onRemoved listener, below. This approach avoids any dependency + # on the order in which register and unregister events happens (on navigation, a new top frame + # registering before the old one is deregistered). if tabId of frameIdsForTab and tabId != 0 frameIdsForTab[tabId] = frameIdsForTab[tabId].filter (fId) -> fId != frameId port.onDisconnect.removeListener listener |
