 # For debugging only. This writes to the Vimium log page, the URL of whichis shown on the console on the
 # background page.
 bgLog = (args...) ->
-  args = (arg.toString() for arg in args)
+  args = args.map((a) => a.toString())
   Frame.postMessage "log", message: args.join " "
+  return
 
 # If an input grabs the focus before the user has interacted with the page, then grab it back (if the
 # grabBackFocus option is set).
 class GrabBackFocus extends Mode
-  # console.log when we grab focus back from the page, so web devs using Vimium don't get confused.
-  logged: false
-
   constructor: ->
     exitEventHandler = =>
       @alwaysContinueBubbling =>
         @exit()
         chrome.runtime.sendMessage handler: "sendMessageToFrames", message: name: "userIsInteractingWithThePage"
+        return
 
     super
       name: "grab-back-focus"
       keydown: exitEventHandler
+
+    # True after we've grabbed back focus to the page and logged it via console.log , so web devs using Vimium
+    # don't get confused.
+    @logged = false
 
     @push
       _name: "grab-back-focus-mousedown"

    # Some requests intended for the background page are delivered to the options page too; ignore them.
    unless request.handler and not request.name
      # Some request are handled elsewhere; ignore them too.
      unless request.name in ["userIsInteractingWithThePage"]
        if isEnabledForUrl or request.name in ["checkEnabledAfterURLChange", "runInTopFrame"]
          requestHandlers[request.name] request, sender, sendResponse
    false # Ensure that the sendResponse callback is freed.

# Wrapper to install event listeners.  Syntactic sugar.
installListener = (element, event, callback) ->
  element.addEventListener(event, forTrusted(->
    root.extend window, root unless extend? # See #2800.
    if isEnabledForUrl then callback.apply(this, arguments) else true
  ), true)


# correct enabled state (but only if this frame has the focus).
checkEnabledAfterURLChange = forTrusted ->
  Scroller.reset() # The URL changing feels like navigation to the user, so reset the scroller (see #3119).
  if windowIsFocused()
    checkIfEnabledForUrl()
  return

# If we are in the help dialog iframe, then HelpDialog is already defined with the necessary functions.
root.HelpDialog ?=
  helpUI: null
  isShowing: ->
    return @helpUI && @helpUI.showing
  abort: ->
    if @isShowing()
      @helpUI.hide false

  toggle: (request) ->
    DomUtils.documentComplete =>
