aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts/mode.coffee
diff options
context:
space:
mode:
authorStephen Blott2015-01-19 05:39:24 +0000
committerStephen Blott2015-01-20 06:50:08 +0000
commit97e61e29d59b9557fe1fb8d7ae1a34be1d47fcc1 (patch)
treeb989b02071fc736a798cf472287a8a1c40b7dfff /content_scripts/mode.coffee
parent9fa664167b5aaf99069ba9298646a39853eeb067 (diff)
downloadvimium-97e61e29d59b9557fe1fb8d7ae1a34be1d47fcc1.tar.bz2
Rework DOM tests.
- Set up modes such that they can be re-initialised. - Move initialisation of BadgeMode to general initialisation function. - Add reset() method for handlerStack. - Consistently use initializeModeState() in all tests' setup(). - Refactor focusInput tests. - Add some more tests. - Simplify some other tests. Note: Clean-up of the inputFocus overlay now happens when the exit() method is called in Mode.reset(). This eliminates most needs to artificially bubble a keyboard event to clear the overlay.
Diffstat (limited to 'content_scripts/mode.coffee')
-rw-r--r--content_scripts/mode.coffee12
1 files changed, 9 insertions, 3 deletions
diff --git a/content_scripts/mode.coffee b/content_scripts/mode.coffee
index acc3978e..42ea9930 100644
--- a/content_scripts/mode.coffee
+++ b/content_scripts/mode.coffee
@@ -169,14 +169,19 @@ class Mode
log: (args...) ->
console.log args... if @debug
- # Return the must-recently activated mode (only used in tests).
+ # For tests only.
@top: ->
@modes[@modes.length-1]
+ # For tests only.
+ @reset: ->
+ mode.exit() for mode in @modes
+ @modes = []
+
# BadgeMode is a pseudo mode for triggering badge updates on focus changes and state updates. It sits at the
# bottom of the handler stack, and so it receives state changes *after* all other modes, and can override the
-# badge choice of the other modes. We create the the one-and-only instance here.
-new class BadgeMode extends Mode
+# badge choice of the other modes.
+class BadgeMode extends Mode
constructor: () ->
super
name: "badge"
@@ -200,3 +205,4 @@ new class BadgeMode extends Mode
root = exports ? window
root.Mode = Mode
+root.BadgeMode = BadgeMode