aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2016-03-05 07:53:24 +0000
committerStephen Blott2016-03-06 11:27:45 +0000
commitbde730eb473982203f9db9813aebd5657beeebf9 (patch)
treee108de572dbfb385997a5b548b8d533ebbcd4821
parent0822f8244d328233752c7f986a70e805ee238979 (diff)
downloadvimium-bde730eb473982203f9db9813aebd5657beeebf9.tar.bz2
Address possible race condition in Vomnibar initialization.
This addresses the potential race condition mentioned in this commit record (3542db7b6c322d803c263db641ae0b02327447ca) and in #2033. In non-top frames, wait until documentReady before sending the message to initialise the Vomnibar. This cannot be before preDomReady in the main frame, right?
-rw-r--r--content_scripts/vimium_frontend.coffee8
1 files changed, 5 insertions, 3 deletions
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index 5acabcfc..92cfea58 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -440,10 +440,12 @@ initializeTopFrame = (request = null) ->
if DomUtils.isTopFrame()
Vomnibar.init()
else
- # Ignore requests from other frames (if we're not the top frame).
+ # Ignore requests from other frames (we're not the top frame).
unless request?
- # Tell the top frame to initialize the Vomnibar.
- chrome.runtime.sendMessage handler: "sendMessageToFrames", message: name: "initializeTopFrame"
+ # Tell the top frame to initialize the Vomnibar. We wait until "DOMContentLoaded" to ensure that the
+ # listener in the main/top frame (which are installed pre-DomReady) is already installed.
+ DomUtils.documentReady ->
+ chrome.runtime.sendMessage handler: "sendMessageToFrames", message: name: "initializeTopFrame"
# Checks if Vimium should be enabled or not in this frame. As a side effect, it also informs the background
# page whether this frame has the focus, allowing the background page to track the active frame's URL.