aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content_scripts/mode.coffee8
-rw-r--r--content_scripts/vimium_frontend.coffee11
-rw-r--r--tests/dom_tests/dom_tests.coffee11
3 files changed, 6 insertions, 24 deletions
diff --git a/content_scripts/mode.coffee b/content_scripts/mode.coffee
index 3327b58f..205b8288 100644
--- a/content_scripts/mode.coffee
+++ b/content_scripts/mode.coffee
@@ -119,14 +119,6 @@ class Mode
@deactivateSingleton @options.singleton
singletons[key] = this
- # If @options.trackState is truthy, then the mode mainatins the current state in @enabled and @passKeys.
- if @options.trackState
- @enabled = false
- @passKeys = ""
- @push
- _name: "mode-#{@id}/registerStateChange"
- registerStateChange: ({ enabled: @enabled, passKeys: @passKeys }) => @continueBubbling
-
# If @options.passInitialKeyupEvents is set, then we pass initial non-printable keyup events to the page
# or to other extensions (because the corresponding keydown events were passed). This is used when
# activating link hints, see #1522.
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index a4dd6986..5401cf22 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -94,11 +94,12 @@ handlerStack.push
true
class NormalMode extends KeyHandlerMode
+ setPassKeys: (@passKeys) ->
+
constructor: (options = {}) ->
super extend options,
name: "normal"
indicator: false # There is no mode indicator in normal mode.
- trackState: true # Maintain @passKeys.
commandHandler: @commandHandler.bind this
chrome.storage.local.get "normalModeKeyStateMapping", (items) =>
@@ -127,8 +128,8 @@ class NormalMode extends KeyHandlerMode
# Only exported for tests; also, "args..." is only for the tests.
window.initializeModes = (args...) ->
# Install the permanent modes. The permanently-installed insert mode tracks focus/blur events, and
- # activates/deactivates itself accordingly.
- new NormalMode args...
+ # activates/deactivates itself accordingly. normalMode is exported only for the tests.
+ window.normalMode = new NormalMode args...
new InsertMode permanent: true
Scroller.init()
@@ -440,9 +441,7 @@ checkIfEnabledForUrl = (frameIsFocused = windowIsFocused()) ->
if HUD.isReady() and not isEnabledForUrl
# Quickly hide any HUD we might already be showing, e.g. if we entered insert mode on page load.
HUD.hide()
- handlerStack.bubbleEvent "registerStateChange",
- enabled: isEnabledForUrl
- passKeys: passKeys
+ normalMode?.setPassKeys passKeys
# Update the page icon, if necessary.
if windowIsFocused()
chrome.runtime.sendMessage
diff --git a/tests/dom_tests/dom_tests.coffee b/tests/dom_tests/dom_tests.coffee
index ee61aba9..b5b91f42 100644
--- a/tests/dom_tests/dom_tests.coffee
+++ b/tests/dom_tests/dom_tests.coffee
@@ -25,9 +25,7 @@ initializeModeState = ->
Mode.reset()
handlerStack.reset()
initializeModes keyMapping: {m: {}, p: {}, z: {p: {}}}
- handlerStack.bubbleEvent "registerStateChange",
- enabled: true
- passKeys: "p"
+ normalMode.setPassKeys "p"
# Tell Settings that it's been loaded.
Settings.isLoaded = true
@@ -494,13 +492,6 @@ context "Mode utilities",
element.blur()
assert.isTrue test.modeIsActive
- should "register state change", ->
- test = new Mode trackState: true
- handlerStack.bubbleEvent "registerStateChange", { enabled: "one", passKeys: "two" }
-
- assert.isTrue test.enabled == "one"
- assert.isTrue test.passKeys == "two"
-
context "PostFindMode",
setup ->
initializeModeState()