 
 currentVersion = Utils.getCurrentVersion()
 frameIdsForTab = {}
+portsForTab = {}
 root.urlForTab = {}
 topFramePortForTab = {}
 

    topFramePortForTab[tabId] = port if frameId == 0
    frameIdsForTab[tabId] ?= []
    frameIdsForTab[tabId].push frameId unless frameId in frameIdsForTab[tabId]
    port.postMessage handler: "registerFrameId", chromeFrameId: frameId

    port.onDisconnect.addListener listener = ->

      # events happen (e.g. on navigation, a new top frame registers before the old one unregisters).
      if tabId of frameIdsForTab and frameId != 0
        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) =>
