Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
f8517450
...
f8517450ce108387e4dd65c1603fc71ba13f5f52
authored
2012-12-21 21:03:54 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
sync with master
2 parents
75a5d399
8fa8d23a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
3 deletions
.travis.yml
modules/casper.js
modules/events.js
tests/suites/casper/confirm.js
.travis.yml
View file @
f851745
branches
:
only
:
-
master
-
testcase
before_script
:
-
"
npm
install
-g
jshint"
-
"
phantomjs
--version"
...
...
modules/casper.js
View file @
f851745
...
...
@@ -2001,7 +2001,10 @@ function createPage(casper) {
}
};
page
.
onConfirm
=
function
onConfirm
(
message
)
{
return
casper
.
filter
(
'page.confirm'
,
message
)
||
true
;
if
(
'page.confirm'
in
casper
.
_filters
)
{
return
casper
.
filter
(
'page.confirm'
,
message
);
}
return
true
;
};
page
.
onConsoleMessage
=
function
onConsoleMessage
(
msg
)
{
// client utils casper console message
...
...
modules/events.js
View file @
f851745
...
...
@@ -19,6 +19,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
/*global CasperError*/
var
isArray
=
Array
.
isArray
;
function
EventEmitter
()
{
...
...
@@ -230,6 +232,17 @@ EventEmitter.prototype.filter = function() {
return
filter
.
apply
(
this
,
Array
.
prototype
.
splice
.
call
(
arguments
,
1
));
};
EventEmitter
.
prototype
.
removeAllFilters
=
function
(
type
)
{
if
(
arguments
.
length
===
0
)
{
this
.
_filters
=
{};
return
this
;
}
if
(
type
&&
this
.
_filters
&&
this
.
_filters
[
type
])
{
this
.
_filters
[
type
]
=
null
;
}
return
this
;
};
EventEmitter
.
prototype
.
setFilter
=
function
(
type
,
filterFn
)
{
if
(
!
this
.
_filters
)
{
this
.
_filters
=
{};
...
...
tests/suites/casper/confirm.js
View file @
f851745
...
...
@@ -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
casper
.
removeAllFilters
(
'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
);
});
...
...
Please
register
or
sign in
to post a comment