   selectSpecificTab: selectSpecificTab,
   refreshCompleter: refreshCompleter
 
-init = ->
-  Commands.clearKeyMappingsAndSetDefaults()
-
-  if Settings.has("keyMappings")
-    Commands.parseCustomKeyMappings(Settings.get("keyMappings"))
-
-  populateValidFirstKeys()
-  populateSingleKeyCommands()
-  if shouldShowUpgradeMessage()
-    sendRequestToAllTabs({ name: "showUpgradeNotification", version: currentVersion })
-
-  # Ensure that openTabs is populated when Vimium is installed.
-  chrome.windows.getAll({ populate: true }, (windows) ->
-    for window in windows
-      for tab in window.tabs
-        updateOpenTabs(tab)
-        createScrollPositionHandler = ->
-          (response) -> updateScrollPosition(tab, response.scrollX, response.scrollY) if response?
-        chrome.tabs.sendRequest(tab.id, { name: "getScrollPosition" }, createScrollPositionHandler()))
-
-
-init()
-
 # Convenience function for development use.
-runTests = -> open(chrome.extension.getURL('test_harnesses/automated.html'))
+window.runTests = -> open(chrome.extension.getURL('test_harnesses/automated.html'))
+
+#
+# Begin initialization.
+#
+Commands.clearKeyMappingsAndSetDefaults()
+
+if Settings.has("keyMappings")
+  Commands.parseCustomKeyMappings(Settings.get("keyMappings"))
+
+populateValidFirstKeys()
+populateSingleKeyCommands()
+if shouldShowUpgradeMessage()
+  sendRequestToAllTabs({ name: "showUpgradeNotification", version: currentVersion })
+
+# Ensure that openTabs is populated when Vimium is installed.
+chrome.windows.getAll({ populate: true }, (windows) ->
+  for window in windows
+    for tab in window.tabs
+      updateOpenTabs(tab)
+      createScrollPositionHandler = ->
+        (response) -> updateScrollPosition(tab, response.scrollX, response.scrollY) if response?
+      chrome.tabs.sendRequest(tab.id, { name: "getScrollPosition" }, createScrollPositionHandler()))

filterCompleter = (args, port) ->
  queryTerms = if (args.query == "") then [] else args.query.split(" ")
  completers[args.name].filter(queryTerms, (results) -> port.postMessage({ id: args.id, results: results }))

#
# Used by everyone to get settings from local storage.
#
getSettingFromLocalStorage = (setting) ->
  if (localStorage[setting] != "" && !localStorage[setting])
    defaultSettings[setting]
  else
    localStorage[setting]

getCurrentTimeInSeconds = -> Math.floor((new Date()).getTime() / 1000)



  framesForTab[sender.tab.id].frames.push({ id: request.frameId, area: request.area })

handleFrameFocused = (request, sender) -> focusedFrame = request.frameId

getCurrFrameIndex = (frames) ->
  for i in [0...frames.length]
