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 --- src/scenario/Scenario.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/scenario/Scenario.js') diff --git a/src/scenario/Scenario.js b/src/scenario/Scenario.js index 149a0f09..420345f6 100644 --- a/src/scenario/Scenario.js +++ b/src/scenario/Scenario.js @@ -298,9 +298,14 @@ function browserTrigger(element, type) { var parentTrigger = fn.trigger; fn.trigger = function(type) { if (/(click|change|keydown)/.test(type)) { - return this.each(function(index, node) { - browserTrigger(node, type); + var processDefaults = []; + this.each(function(index, node) { + processDefaults.push(browserTrigger(node, type)); }); + + // this is not compatible with jQuery - we return an array of returned values, + // so that scenario runner know whether JS code has preventDefault() of the event or not... + return processDefaults; } return parentTrigger.apply(this, arguments); }; -- cgit v1.2.3