diff options
| author | mrmr1993 | 2017-12-02 18:38:53 +0000 | 
|---|---|---|
| committer | mrmr1993 | 2017-12-02 18:38:53 +0000 | 
| commit | ff615efa9a41f1de5df1a6eea0e8a3c809f91b4b (patch) | |
| tree | 8ed10d8074e47d1b1dfb37a45f5625a7b0c1eecb | |
| parent | b3fae0963056c085630c52609d11a048c5901bad (diff) | |
| download | vimium-ff615efa9a41f1de5df1a6eea0e8a3c809f91b4b.tar.bz2 | |
Ensure that a port can only unregister its frameId if it's associated
This is a more complete fix for issue #2125.
| -rw-r--r-- | background_scripts/main.coffee | 12 | 
1 files changed, 6 insertions, 6 deletions
| diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 2c7b13ba..d87109f4 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -301,7 +301,7 @@ for icon in [ENABLED_ICON, DISABLED_ICON, PARTIAL_ICON]  Frames =    onConnect: (sender, port) ->      [tabId, frameId] = [sender.tab.id, sender.frameId] -    port.onDisconnect.addListener -> Frames.unregisterFrame {tabId, frameId} +    port.onDisconnect.addListener -> Frames.unregisterFrame {tabId, frameId, port}      port.postMessage handler: "registerFrameId", chromeFrameId: frameId      (portsForTab[tabId] ?= {})[frameId] = port @@ -312,11 +312,11 @@ Frames =    registerFrame: ({tabId, frameId, port}) ->      frameIdsForTab[tabId].push frameId unless frameId in frameIdsForTab[tabId] ?= [] -  unregisterFrame: ({tabId, frameId}) -> -    # FrameId 0 is the top/main frame.  We never unregister that frame.  If the tab is closing, then we tidy -    # up elsewhere.  If the tab is navigating to a new page, then a new top frame will be along soon. -    # This mitigates against the unregister and register messages arriving out of order. See #2125. -    if 0 < frameId +  unregisterFrame: ({tabId, frameId, port}) -> +    # Check that the port trying to unregister the frame hasn't already been replaced by a new frame +    # registering. See #2125. +    registeredPort = portsForTab[tabId]?[frameId] +    if registeredPort == port or not registeredPort        if tabId of frameIdsForTab          frameIdsForTab[tabId] = (fId for fId in frameIdsForTab[tabId] when fId != frameId)        if tabId of portsForTab | 
