diff options
| author | Stephen Blott | 2015-01-18 17:32:31 +0000 |
|---|---|---|
| committer | Stephen Blott | 2015-01-18 17:32:31 +0000 |
| commit | 7ed25b7a757a0b3d8d8cf14c60fd8e0e0d237835 (patch) | |
| tree | 8f3121b3e93f831037833a7d80dd925fc96fca22 | |
| parent | d8f2446261887cb9affc50caf27b5793f0339edc (diff) | |
| parent | ed06688979cbed11ce1fd388acb042d30598036b (diff) | |
| download | vimium-7ed25b7a757a0b3d8d8cf14c60fd8e0e0d237835.tar.bz2 | |
Merge branch 'master' into focus-input-with-memory
| -rw-r--r-- | content_scripts/mode_insert.coffee | 12 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 2 | ||||
| -rw-r--r-- | tests/dom_tests/dom_tests.coffee | 6 |
3 files changed, 9 insertions, 11 deletions
diff --git a/content_scripts/mode_insert.coffee b/content_scripts/mode_insert.coffee index 91103a55..eac4a3d0 100644 --- a/content_scripts/mode_insert.coffee +++ b/content_scripts/mode_insert.coffee @@ -1,12 +1,9 @@ class InsertMode extends Mode - # There is one permanently-installed instance of InsertMode. It tracks focus changes and - # activates/deactivates itself (by setting @insertModeLock) accordingly. - @permanentInstance: null - constructor: (options = {}) -> - InsertMode.permanentInstance ||= @ - @permanent = (@ == InsertMode.permanentInstance) + # There is one permanently-installed instance of InsertMode. It tracks focus changes and + # activates/deactivates itself (by setting @insertModeLock) accordingly. + @permanent = options.permanent # If truthy, then we were activated by the user (with "i"). @global = options.global @@ -51,6 +48,9 @@ class InsertMode extends Mode if @insertModeLock != event.target and DomUtils.isFocusable event.target @activateOnElement event.target + # Only for tests. This gives us a hook to test the status of the permanent instance. + InsertMode.permanentInstance = @ if @permanent + isActive: (event) -> return false if event == InsertMode.suppressedEvent return true if @insertModeLock or @global diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 8b73c766..27e813c9 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -124,7 +124,7 @@ initializePreDomReady = -> # activates/deactivates itself accordingly. new NormalMode new PassKeysMode - new InsertMode + new InsertMode permanent: true checkIfEnabledForUrl() diff --git a/tests/dom_tests/dom_tests.coffee b/tests/dom_tests/dom_tests.coffee index 8cb0c41a..f67ebc88 100644 --- a/tests/dom_tests/dom_tests.coffee +++ b/tests/dom_tests/dom_tests.coffee @@ -194,8 +194,6 @@ context "Input focus", should "focus the right element", -> focusInput 1 assert.equal "first", document.activeElement.id - # deactivate the tabbing mode and its overlays - handlerStack.bubbleEvent 'keydown', mockKeyboardEvent("A") focusInput 100 assert.equal "third", document.activeElement.id @@ -204,13 +202,13 @@ context "Input focus", # This is the same as above, but also verifies that focusInput activates insert mode. should "activate insert mode", -> focusInput 1 - handlerStack.bubbleEvent 'focus', { target: document.activeElement } + handlerStack.bubbleEvent 'focus', target: document.activeElement assert.isTrue InsertMode.permanentInstance.isActive() # deactivate the tabbing mode and its overlays handlerStack.bubbleEvent 'keydown', mockKeyboardEvent("A") focusInput 100 - handlerStack.bubbleEvent 'focus', { target: document. activeElement } + handlerStack.bubbleEvent 'focus', target: document. activeElement assert.isTrue InsertMode.permanentInstance.isActive() # deactivate the tabbing mode and its overlays handlerStack.bubbleEvent 'keydown', mockKeyboardEvent("A") |
