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
b00b295f
...
b00b295fe9c8292d5a87912b60c0e35405d078ae
authored
2014-03-08 19:05:06 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge pull request #850 from tohann/master
Add an event emit for clicking
2 parents
89cfda79
d306b927
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
1 deletions
modules/casper.js
tests/site/click.html
tests/suites/casper/click.js
modules/casper.js
View file @
b00b295
...
...
@@ -467,6 +467,7 @@ Casper.prototype.click = function click(selector) {
element
.
focus
();
}
},
selector
);
this
.
emit
(
'click'
,
selector
);
return
success
;
};
...
...
tests/site/click.html
View file @
b00b295
...
...
@@ -32,6 +32,9 @@
results
.
test4
=
true
;
event
.
preventDefault
();
};
document
.
querySelector
(
'#test5'
).
onclick
=
function
(
event
)
{
results
.
testclick
=
[
event
.
clientX
,
event
.
clientY
];
};
window
.
onmousedown
=
function
(
event
)
{
results
.
testdown
=
[
event
.
clientX
,
event
.
clientY
];
};
...
...
@@ -51,6 +54,9 @@
test5elem
.
addEventListener
(
'mouseup'
,
function
(
event
)
{
results
.
test5
.
push
(
'mouseup'
);
});
test5elem
.
addEventListener
(
'click'
,
function
(
event
)
{
results
.
test5
.
push
(
'click'
);
});
document
.
querySelector
(
'#test6'
).
onclick
=
function
(
event
)
{
results
.
test6
=
true
;
event
.
preventDefault
();
...
...
tests/suites/casper/click.js
View file @
b00b295
...
...
@@ -111,7 +111,7 @@ casper.test.begin('element focus on click', 1, function(test) {
});
});
casper
.
test
.
begin
(
'mouse events on click'
,
2
,
function
(
test
)
{
casper
.
test
.
begin
(
'mouse events on click'
,
3
,
function
(
test
)
{
casper
.
start
(
'tests/site/click.html'
,
function
()
{
this
.
click
(
'#test5'
);
}).
then
(
function
()
{
...
...
@@ -120,6 +120,8 @@ casper.test.begin('mouse events on click', 2, function(test) {
'Casper.click() triggers mousedown event'
);
test
.
assert
(
results
.
test5
.
indexOf
(
'mouseup'
)
!==
-
1
,
'Casper.click() triggers mouseup event'
);
test
.
assert
(
results
.
test5
.
indexOf
(
'click'
)
!==
-
1
,
'Casper.click() triggers click event'
);
}).
run
(
function
()
{
test
.
done
();
});
...
...
Please
register
or
sign in
to post a comment