From bde730eb473982203f9db9813aebd5657beeebf9 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 5 Mar 2016 07:53:24 +0000 Subject: 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? --- content_scripts/vimium_frontend.coffee | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'content_scripts') 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. -- cgit v1.2.3