From 7939b69ffc2880ff4590d1c8dcfd5eb7492200fd Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Tue, 20 Jan 2015 10:24:45 +0000 Subject: Rework focus input so it can be better included in tests. focusInput was getting its focus events from the handler stack. When the handler stack was reset during tests, we lost focusInput's handler. So we couldn't test the feature whereby focusInput has a memory (#1438). Instead, here focusInput adds its listener directly to the window, and we add the approriate test. --- content_scripts/vimium_frontend.coffee | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'content_scripts') diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 729a21bd..5d56ad5b 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -337,11 +337,9 @@ extend window, focusInput: do -> # Track the most recently focused input element. recentlyFocusedElement = null - handlerStack.push - _name: "focus-input-tracker" - focus: (event) -> - recentlyFocusedElement = event.target if DomUtils.isEditable event.target - true + window.addEventListener "focus", + (event) -> recentlyFocusedElement = event.target if DomUtils.isEditable event.target + , true (count) -> # Focus the first input element on the page, and create overlays to highlight all the input elements, with -- cgit v1.2.3