 Frames =
   onConnect: (sender, port) ->
     [tabId, frameId] = [sender.tab.id, sender.frameId]
-    topFramePortForTab[tabId] = port if frameId == 0
     frameIdsForTab[tabId] ?= []
     frameIdsForTab[tabId].push frameId unless frameId in frameIdsForTab[tabId]
     portsForTab[tabId] ?= {}

      delete tabLoadedHandlers[tabId]

  initializeTopFrameUIComponents: ({tabId}) ->
    topFramePortForTab[tabId].postMessage handler: "initializeTopFrameUIComponents"

handleFrameFocused = ({tabId, frameId}) ->
  frameIdsForTab[tabId] ?= []

frameIdsForTab = {}
portsForTab = {}
root.urlForTab = {}

# This is exported for use by "marks.coffee".
root.tabLoadedHandlers = {} # tabId -> function()
