From 4009213f0dbe1326263535e0a50a165d179ae47d Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Tue, 15 Mar 2016 12:38:39 +0000 Subject: Open frames port pre documentReady. The intention is to move checkIfEnabledForUrl to the frames port. That needs to run pre domReady, so first -- here -- we separate the two ports. --- content_scripts/vimium_frontend.coffee | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'content_scripts') diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index ce01695a..4b461847 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -136,6 +136,7 @@ window.initializeModes = -> # Complete initialization work that sould be done prior to DOMReady. # initializePreDomReady = -> + Frame.init() checkIfEnabledForUrl() requestHandlers = @@ -207,18 +208,20 @@ onFocus = (event) -> window.addEventListener "focus", onFocus window.addEventListener "hashchange", onFocus +DomUtils.documentReady -> + # Tell the background page we're in the domReady state. + chrome.runtime.connect({name: "domReady"}).onDisconnect.addListener -> + # We disable content scripts when we lose contact with the background page. + isEnabledForUrl = false + chrome.runtime.sendMessage = -> + window.removeEventListener "focus", onFocus + Frame = port: null init: -> - # Tell the background page we're in the domReady state. - @port = chrome.runtime.connect name: "domReady" + @port = chrome.runtime.connect name: "frames" @port.onMessage.addListener (request) => this[request.name] request - @port.onDisconnect.addListener -> - # We disable content scripts when we lose contact with the background page. - isEnabledForUrl = false - chrome.runtime.sendMessage = -> - window.removeEventListener "focus", onFocus registerFrameId: ({chromeFrameId}) -> frameId = window.frameId = chromeFrameId @@ -649,7 +652,6 @@ window.HelpDialog ?= if @showing then @hide() else @show html initializePreDomReady() -DomUtils.documentReady Frame.init.bind Frame root = exports ? window root.handlerStack = handlerStack -- cgit v1.2.3