diff options
Diffstat (limited to 'content_scripts/vimium_frontend.coffee')
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 21 | 
1 files changed, 15 insertions, 6 deletions
| diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index d9fc363e..58cf6115 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -239,12 +239,21 @@ Frame =      @port.onMessage.addListener (request) =>        (@listeners[request.handler] ? this[request.handler]) request -    @port.onDisconnect.addListener -> -      # We disable the content scripts when we lose contact with the background page. -      isEnabledForUrl = false -      window.removeEventListener "focus", onFocus - -    window.addEventListener "unload", => @postMessage "unregsterFrame" +    # We disable the content scripts when we lose contact with the background page, or on unload. +    @port.onDisconnect.addListener disconnect = Utils.makeIdempotent => @disconnect() +    window.addEventListener "unload", disconnect + +  disconnect: -> +    try @postMessage "unregisterFrame" +    try @port.disconnect() +    @postMessage = @disconnect = -> +    @port = null +    @listeners = {} +    HintCoordinator.exit isSuccess: false +    handlerStack.reset() +    isEnabledForUrl = false +    window.removeEventListener "focus", onFocus +    window.removeEventListener "hashchange", onFocus  setScrollPosition = ({ scrollX, scrollY }) ->    if DomUtils.isTopFrame() | 
