diff options
| author | Stephen Blott | 2015-01-18 10:39:09 +0000 |
|---|---|---|
| committer | Stephen Blott | 2015-01-18 10:39:09 +0000 |
| commit | a1edae57e2847c2b6ffcae60ea8c9c16216e4692 (patch) | |
| tree | 30ff186038028f9d0c0d5cc08d572ca56dda8819 /tests/unit_tests/handler_stack_test.coffee | |
| parent | 8c9e429074580ea20aba662ee430d87bd73ebc4b (diff) | |
| parent | 5d087c89917e21872711b7b908fcdd3c7e9e7f17 (diff) | |
| download | vimium-a1edae57e2847c2b6ffcae60ea8c9c16216e4692.tar.bz2 | |
Merge pull request #1413 from smblott-github/modes
A modal-browsing framework
Diffstat (limited to 'tests/unit_tests/handler_stack_test.coffee')
| -rw-r--r-- | tests/unit_tests/handler_stack_test.coffee | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/unit_tests/handler_stack_test.coffee b/tests/unit_tests/handler_stack_test.coffee index 0ed8f4c0..0ed85e63 100644 --- a/tests/unit_tests/handler_stack_test.coffee +++ b/tests/unit_tests/handler_stack_test.coffee @@ -23,6 +23,29 @@ context "handlerStack", assert.isTrue @handler2Called assert.isFalse @handler1Called + should "terminate bubbling on stopBubblingAndTrue, and be true", -> + @handlerStack.push { keydown: => @handler1Called = true } + @handlerStack.push { keydown: => @handler2Called = true; @handlerStack.stopBubblingAndTrue } + assert.isTrue @handlerStack.bubbleEvent 'keydown', {} + assert.isTrue @handler2Called + assert.isFalse @handler1Called + + should "terminate bubbling on stopBubblingAndTrue, and be false", -> + @handlerStack.push { keydown: => @handler1Called = true } + @handlerStack.push { keydown: => @handler2Called = true; @handlerStack.stopBubblingAndFalse } + assert.isFalse @handlerStack.bubbleEvent 'keydown', {} + assert.isTrue @handler2Called + assert.isFalse @handler1Called + + should "restart bubbling on restartBubbling", -> + @handler1Called = 0 + @handler2Called = 0 + id = @handlerStack.push { keydown: => @handler1Called++; @handlerStack.remove(id); @handlerStack.restartBubbling } + @handlerStack.push { keydown: => @handler2Called++; true } + assert.isTrue @handlerStack.bubbleEvent 'keydown', {} + assert.isTrue @handler1Called == 1 + assert.isTrue @handler2Called == 2 + should "remove handlers correctly", -> @handlerStack.push { keydown: => @handler1Called = true } handlerId = @handlerStack.push { keydown: => @handler2Called = true } |
