From 0822f8244d328233752c7f986a70e805ee238979 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 5 Mar 2016 06:36:16 +0000 Subject: Initialize UI components only when they're needed. HUD: Initialize only when the frame receives the focus and Vimium is enabled. Vomnibar: Initialize in the top frame when Vimium is enabled in *any* frame. Warning: There may be a race condition here. Specifically, if Vimium is disabled in the main/top frame (T) but enabled in another frame (A), then the initialisation could happen in frame A before frame T is listening, so frame T would miss the initialization message (which is only sent once). Message listeners are installed early (and probably installed first in the main/top frame), and the `isEnabledForUrl` messaging takes some time, so perhaps it's OK. But it *is* a race condition. Fixes #1838. --- tests/dom_tests/dom_tests.coffee | 1 + tests/dom_tests/vomnibar_test.coffee | 1 + 2 files changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/dom_tests/dom_tests.coffee b/tests/dom_tests/dom_tests.coffee index 0745e5b2..3797a37b 100644 --- a/tests/dom_tests/dom_tests.coffee +++ b/tests/dom_tests/dom_tests.coffee @@ -1,6 +1,7 @@ # Install frontend event handlers. installListeners() +HUD.init() installListener = (element, event, callback) -> element.addEventListener event, (-> callback.apply(this, arguments)), true diff --git a/tests/dom_tests/vomnibar_test.coffee b/tests/dom_tests/vomnibar_test.coffee index 3eda6234..0898e33a 100644 --- a/tests/dom_tests/vomnibar_test.coffee +++ b/tests/dom_tests/vomnibar_test.coffee @@ -1,5 +1,6 @@ vomnibarFrame = null SearchEngines.refresh "" +Vomnibar.init() context "Keep selection within bounds", -- cgit v1.2.3