diff options
| author | Stephen Blott | 2016-03-05 05:43:42 +0000 |
|---|---|---|
| committer | Stephen Blott | 2016-03-05 05:43:42 +0000 |
| commit | 62359adda7bc38917de38e3fc794d37817fa05ed (patch) | |
| tree | 816d696b785f8a58b06ddd01560fee05ca0299e7 /tests | |
| parent | 27d3d0087c86a6effd25049cbf0d9273eb0af9db (diff) | |
| parent | fb67cfdd2ca8c09453cc896fd02d08ed5a74a8a4 (diff) | |
| download | vimium-62359adda7bc38917de38e3fc794d37817fa05ed.tar.bz2 | |
Merge pull request #2022 from smblott-github/generalised-key-bindings
Key handling in content scripts.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/dom_tests/dom_tests.coffee | 33 | ||||
| -rw-r--r-- | tests/dom_tests/dom_tests.html | 2 | ||||
| -rw-r--r-- | tests/unit_tests/commands_test.coffee | 2 |
3 files changed, 11 insertions, 26 deletions
diff --git a/tests/dom_tests/dom_tests.coffee b/tests/dom_tests/dom_tests.coffee index 8a96913f..c2c34fa8 100644 --- a/tests/dom_tests/dom_tests.coffee +++ b/tests/dom_tests/dom_tests.coffee @@ -24,15 +24,8 @@ for type in [ "keydown", "keypress", "keyup" ] initializeModeState = -> Mode.reset() handlerStack.reset() - initializeModes() - # We use "m" as the only mapped key, "p" as a passkey, and "u" as an unmapped key. - refreshCompletionKeys - completionKeys: "mp" - handlerStack.bubbleEvent "registerStateChange", - enabled: true - passKeys: "p" - handlerStack.bubbleEvent "registerKeyQueue", - keyQueue: "" + initializeModes keyMapping: {m: {}, p: {}, z: {p: {}}} + normalMode.setPassKeys "p" # Tell Settings that it's been loaded. Settings.isLoaded = true @@ -375,8 +368,13 @@ context "Normal mode", sendKeyboardEvent "p" assert.equal pageKeyboardEventCount, 3 - should "suppress passKeys with a non-empty keyQueue", -> - handlerStack.bubbleEvent "registerKeyQueue", keyQueue: "p" + should "suppress passKeys with a non-empty key state (a count)", -> + sendKeyboardEvent "5" + sendKeyboardEvent "p" + assert.equal 0, pageKeyboardEventCount + + should "suppress passKeys with a non-empty key state (a key)", -> + sendKeyboardEvent "z" sendKeyboardEvent "p" assert.equal pageKeyboardEventCount, 0 @@ -495,19 +493,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" - - should "register the keyQueue", -> - test = new Mode trackState: true - handlerStack.bubbleEvent "registerKeyQueue", keyQueue: "hello" - - assert.isTrue test.keyQueue == "hello" - context "PostFindMode", setup -> initializeModeState() diff --git a/tests/dom_tests/dom_tests.html b/tests/dom_tests/dom_tests.html index 8d355c6d..9aa804d1 100644 --- a/tests/dom_tests/dom_tests.html +++ b/tests/dom_tests/dom_tests.html @@ -42,10 +42,10 @@ <script type="text/javascript" src="../../content_scripts/link_hints.js"></script> <script type="text/javascript" src="../../content_scripts/vomnibar.js"></script> <script type="text/javascript" src="../../content_scripts/scroller.js"></script> - <script type="text/javascript" src="../../content_scripts/mode_passkeys.js"></script> <script type="text/javascript" src="../../content_scripts/mode_insert.js"></script> <script type="text/javascript" src="../../content_scripts/mode_find.js"></script> <script type="text/javascript" src="../../content_scripts/mode_visual_edit.js"></script> + <script type="text/javascript" src="../../content_scripts/mode_key_handler.js"></script> <script type="text/javascript" src="../../content_scripts/hud.js"></script> <script type="text/javascript" src="../../content_scripts/vimium_frontend.js"></script> diff --git a/tests/unit_tests/commands_test.coffee b/tests/unit_tests/commands_test.coffee index 45cb4cf4..f501a960 100644 --- a/tests/unit_tests/commands_test.coffee +++ b/tests/unit_tests/commands_test.coffee @@ -1,6 +1,6 @@ require "./test_helper.js" extend global, require "./test_chrome_stubs.js" -global.Settings = {postUpdateHooks: {}} +global.Settings = {postUpdateHooks: {}, get: (-> ""), set: ->} {Commands} = require "../../background_scripts/commands.js" context "Key mappings", |
