Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit ea3228e

Browse files
committed
fix(scenario): workaround for FF6 dispatchEvent issue #684208
1 parent 2eb4914 commit ea3228e

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/scenario/Scenario.js

+21-2
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,28 @@ function browserTrigger(element, type) {
279279
}
280280
return ret;
281281
} else {
282-
var evnt = document.createEvent('MouseEvents');
282+
var evnt = document.createEvent('MouseEvents'),
283+
originalPreventDefault = evnt.preventDefault,
284+
iframe = _jQuery('#application iframe')[0],
285+
appWindow = iframe ? iframe.contentWindow : window,
286+
fakeProcessDefault = true,
287+
finalProcessDefault;
288+
289+
// igor: temporary fix for https://bugzilla.mozilla.org/show_bug.cgi?id=684208
290+
appWindow.angular['ff-684208-preventDefault'] = false;
291+
evnt.preventDefault = function() {
292+
fakeProcessDefault = false;
293+
return originalPreventDefault.apply(evnt, arguments);
294+
};
295+
283296
evnt.initMouseEvent(type, true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, element);
284-
return element.dispatchEvent(evnt);
297+
298+
element.dispatchEvent(evnt);
299+
finalProcessDefault = !(appWindow.angular['ff-684208-preventDefault'] || !fakeProcessDefault)
300+
301+
delete appWindow.angular['ff-684208-preventDefault'];
302+
303+
return finalProcessDefault;
285304
}
286305
}
287306

src/service/location.js

+2
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,8 @@ angularServiceInject('$location', function($browser, $sniffer, $config, $documen
461461
currentUrl.url(href);
462462
scope.$apply();
463463
event.preventDefault();
464+
// hack to work around FF6 bug 684208 when scenario runner clicks on links
465+
window.angular['ff-684208-preventDefault'] = true;
464466
});
465467
} else {
466468
currentUrl = new LocationHashbangUrl(initUrl, hashPrefix);

0 commit comments

Comments
 (0)