 #
 # Called from the backend in order to change frame focus.
 #
-window.focusThisFrame = do ->
+setTimeout (->
   # Create a shadow DOM wrapping the frame so the page's styles don't interfere with ours.
   highlightedFrameElement = DomUtils.createElement "div"
   # PhantomJS doesn't support createShadowRoot, so guard against its non-existance.

    if shouldHighlight
      document.documentElement.appendChild highlightedFrameElement
      setTimeout (-> highlightedFrameElement.remove()), 200

extend window,
  scrollToBottom: ->

  _frameEl.className = "vimiumReset vimiumHighlightedFrame"
  _shadowDOM.appendChild _frameEl

  window.focusThisFrame = (request) ->
    if window.innerWidth < 3 or window.innerHeight < 3
      # This frame is too small to focus. Cancel and tell the background frame to focus the next one instead.
      # This affects sites like Google Inbox, which have many tiny iframes. See #1317.
