diff options
| author | Stephen Blott | 2016-03-30 11:39:58 +0100 |
|---|---|---|
| committer | Stephen Blott | 2016-03-30 11:40:01 +0100 |
| commit | 8fc46ff8b00ae82b574e3314ebc8ae6046c3215f (patch) | |
| tree | a26f80160b36da83cb00a08b0018fbc2c57ea5b3 | |
| parent | 39adee9090fc5aadfd5dd681f91b80025084858a (diff) | |
| download | vimium-8fc46ff8b00ae82b574e3314ebc8ae6046c3215f.tar.bz2 | |
Add test for SuppressAllKeyboardEvents.
Which:
- uncovered a typo in 39adee9090fc5aadfd5dd681f91b80025084858a.
Also:
- make Mode.debug a class variable, which is more helpful while trying
to debug. Specifically, you can turn debugging on or off from
within the tests, for example.
| -rw-r--r-- | content_scripts/mode.coffee | 8 | ||||
| -rw-r--r-- | tests/dom_tests/dom_tests.coffee | 12 |
2 files changed, 16 insertions, 4 deletions
diff --git a/content_scripts/mode.coffee b/content_scripts/mode.coffee index 07307d0d..317fbc86 100644 --- a/content_scripts/mode.coffee +++ b/content_scripts/mode.coffee @@ -27,7 +27,7 @@ count = 0 class Mode # If Mode.debug is true, then we generate a trace of modes being activated and deactivated on the console. - debug: false + @debug: false @modes: [] # Constants; short, readable names for the return values expected by handlerStack.bubbleEvent. @@ -195,12 +195,12 @@ class Mode # Debugging routines. logModes: -> - if @debug + if Mode.debug @log "active modes (top to bottom):" @log " ", mode.id for mode in Mode.modes[..].reverse() log: (args...) -> - console.log args... if @debug + console.log args... if Mode.debug # For tests only. @top: -> @@ -215,7 +215,7 @@ class SuppressAllKeyboardEvents extends Mode constructor: (options = {}) -> defaults = name: "suppressAllKeyboardEvents" - suppressallkeyboardevents: true + suppressAllKeyboardEvents: true super extend defaults, options root = exports ? window diff --git a/tests/dom_tests/dom_tests.coffee b/tests/dom_tests/dom_tests.coffee index 84942908..158112b3 100644 --- a/tests/dom_tests/dom_tests.coffee +++ b/tests/dom_tests/dom_tests.coffee @@ -1022,3 +1022,15 @@ context "WaitForEnter", sendKeyboardEvents "abc" assert.isTrue @waitForEnter.modeIsActive assert.isFalse @isSuccess? + +context "SuppressAllKeyboardEvents", + setup -> + initializeModeState() + + should "supress keyboard events", -> + sendKeyboardEvent "a" + assert.equal 3, pageKeyboardEventCount + new SuppressAllKeyboardEvents + sendKeyboardEvent "a" + assert.equal 0, pageKeyboardEventCount + |
