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) { ...@@ -1988,7 +1988,8 @@ function createPage(casper) {
1988 } 1988 }
1989 }; 1989 };
1990 page.onConfirm = function onConfirm(message) { 1990 page.onConfirm = function onConfirm(message) {
1991 return casper.filter('page.confirm', message) || true; 1991 var listener_exists = typeof casper._filters['page.confirm'] !== 'undefined';
1992 return listener_exists ? casper.filter('page.confirm', message) : true;
1992 }; 1993 };
1993 page.onConsoleMessage = function onConsoleMessage(msg) { 1994 page.onConsoleMessage = function onConsoleMessage(msg) {
1994 // client utils casper console message 1995 // client utils casper console message
......
...@@ -8,10 +8,22 @@ casper.setFilter('page.confirm', function(message) { ...@@ -8,10 +8,22 @@ casper.setFilter('page.confirm', function(message) {
8 }); 8 });
9 9
10 casper.start('tests/site/confirm.html', function() { 10 casper.start('tests/site/confirm.html', function() {
11 this.test.assert(this.getGlobal('confirmed'), 'confirmation received'); 11 this.test.assert(this.getGlobal('confirmed'), 'confirmation dialog accepted');
12 });
13
14 casper.then(function() {
15 //remove the page.confirm event filter so we can add a new one
16 delete casper._filters['page.confirm'];
17 casper.setFilter('page.confirm', function(message) {
18 return false;
19 });
20 });
21
22 casper.thenOpen('/tests/site/confirm.html', function() {
23 this.test.assertNot(this.getGlobal('confirmed'), 'confirmation dialog canceled');
12 }); 24 });
13 25
14 casper.run(function() { 26 casper.run(function() {
15 this.test.assertEquals(received, 'are you sure?', 'confirmation message is ok'); 27 this.test.assertEquals(received, 'are you sure?', 'confirmation message is ok');
16 this.test.done(2); 28 this.test.done(3);
17 }); 29 });
......