Commit 51ded333 51ded333c2358bca29795340fa60a614c88243e1 by Nicolas Perriault

Merge remote-tracking branch 'tylerritchie/iss327' into pr-328

2 parents c881a1a1 d7a36e9e
......@@ -1988,7 +1988,8 @@ function createPage(casper) {
}
};
page.onConfirm = function onConfirm(message) {
return casper.filter('page.confirm', message) || true;
var listener_exists = typeof casper._filters['page.confirm'] !== 'undefined';
return listener_exists ? casper.filter('page.confirm', message) : true;
};
page.onConsoleMessage = function onConsoleMessage(msg) {
// client utils casper console message
......
......@@ -8,10 +8,22 @@ casper.setFilter('page.confirm', function(message) {
});
casper.start('tests/site/confirm.html', function() {
this.test.assert(this.getGlobal('confirmed'), 'confirmation received');
this.test.assert(this.getGlobal('confirmed'), 'confirmation dialog accepted');
});
casper.then(function() {
//remove the page.confirm event filter so we can add a new one
delete casper._filters['page.confirm'];
casper.setFilter('page.confirm', function(message) {
return false;
});
});
casper.thenOpen('/tests/site/confirm.html', function() {
this.test.assertNot(this.getGlobal('confirmed'), 'confirmation dialog canceled');
});
casper.run(function() {
this.test.assertEquals(received, 'are you sure?', 'confirmation message is ok');
this.test.done(2);
this.test.done(3);
});
......