From 66dec7755573a1c07a1fe8e0dd9bc5fc51dbaac9 Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Tue, 30 Aug 2011 13:14:55 +0200 Subject: fix(scenario): do not navigate if click event was cancelled This is jQuery incompatible hack. But we were doing monkey patching there anyway... `$(...).trigger('click')` returns an array of return values, so that scenario runner knows, whether the event default action was cancelled. Without this fix, scenario runner was doing navigation even if JS code called `event.preventDefault()`. Note, this does not work in FF6 --- test/scenario/dslSpec.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test') diff --git a/test/scenario/dslSpec.js b/test/scenario/dslSpec.js index 5485fe52..8e22e469 100644 --- a/test/scenario/dslSpec.js +++ b/test/scenario/dslSpec.js @@ -250,6 +250,20 @@ describe("angular.scenario.dsl", function() { expect($window.location).toMatch(/#foo$/); }); + it('should not navigate if click event was cancelled', function() { + var initLocation = $window.location, + elm = jqLite(''); + + doc.append(elm); + elm.bind('click', function(event) { + event.preventDefault(); + }); + + $root.dsl.element('a').click(); + expect($window.location).toBe(initLocation); + dealoc(elm); + }); + it('should count matching elements', function() { doc.append(''); $root.dsl.element('span').count(); -- cgit v1.2.3