aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2015-05-26 10:07:48 +0100
committerStephen Blott2015-05-26 10:07:48 +0100
commita9f8798f8379a6db5f57eb9bdca9be0f35fae162 (patch)
tree0d260e5fd525a2323d40bc6559f8037d78dc662f
parent6b49dd27cb20ef5f830b1107b39480201796885d (diff)
downloadvimium-a9f8798f8379a6db5f57eb9bdca9be0f35fae162.tar.bz2
Refactor to avoid potential race condition (cont).
-rw-r--r--content_scripts/ui_component.coffee7
1 files changed, 4 insertions, 3 deletions
diff --git a/content_scripts/ui_component.coffee b/content_scripts/ui_component.coffee
index 4e26f26a..ba141b23 100644
--- a/content_scripts/ui_component.coffee
+++ b/content_scripts/ui_component.coffee
@@ -20,7 +20,6 @@ class UIComponent
@shadowDOM = shadowWrapper.createShadowRoot?() ? shadowWrapper
@shadowDOM.appendChild styleSheet
@shadowDOM.appendChild @iframeElement
- document.documentElement.appendChild shadowWrapper
@showing = true # The iframe is visible now.
# Hide the iframe, but don't interfere with the focus.
@@ -30,9 +29,11 @@ class UIComponent
# requests which arrive before the iframe (and its message handlers) have completed initialization. See
# #1679.
@iframePort = new AsyncDataFetcher (setIframePort) =>
- # We set the iframe source here (and not above) to avoid a potential race condition vis-a-vis the "load"
- # event (because this callback runs on "nextTick").
+ # We set the iframe source and append the new element here (as opposed to above) to avoid a potential
+ # race condition vis-a-vis the "load" event (because this callback runs on "nextTick").
@iframeElement.src = chrome.runtime.getURL iframeUrl
+ document.documentElement.appendChild shadowWrapper
+
@iframeElement.addEventListener "load", =>
# Get vimiumSecret so the iframe can determine that our message isn't the page impersonating us.
chrome.storage.local.get "vimiumSecret", ({ vimiumSecret }) =>