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
3a4ed2c8
...
3a4ed2c834295de2d13d40022f834de09a4b72f7
authored
2013-03-11 21:43:11 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fixes #410 - click() triggers mousedown and mousedown events
1 parent
0522099e
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
3 deletions
CHANGELOG.md
modules/casper.js
tests/site/click.html
tests/suites/casper/click.js
CHANGELOG.md
View file @
3a4ed2c
...
...
@@ -103,11 +103,12 @@ Last, all the casper test suites have been upgraded to use the new testing featu
### Bugfixes & enhancements
-
heavy lif
int
of casperjs bootstrap script
-
heavy lif
ting
of casperjs bootstrap script
-
closed
[
#392
](
https://github.com/n1k0/casperjs/issues/392
)
-
`--direct`
&
`--log-level`
options available for the
`casperjs`
executable
-
closed
[
#350
](
https://github.com/n1k0/casperjs/issues/350
)
- Add a
[
`Casper#waitForSelectorTextChange()`
](
http://docs.casperjs.org/en/latest/modules/casper.html#waitforselectortextchange
)
method
-
fixed
[
#387
](
https://github.com/n1k0/casperjs/issues/387
)
- Setting viewport isn't quite synchronous
-
Added
[
`Casper#bypass`
](
http://docs.casperjs.org/en/latest/modules/casper.html#bypass
)
,
[
`Casper#thenBypass`
](
http://docs.casperjs.org/en/latest/modules/casper.html#thenbypass
)
,
[
`Casper#thenBypassIf`
](
http://docs.casperjs.org/en/latest/modules/casper.html#thenbypassif
)
,
[
`Casper#thenBypassUnless`
](
http://docs.casperjs.org/en/latest/modules/casper.html#thenbypassunless
)
methods
-
fixes
[
#410
](
https://github.com/n1k0/casperjs/issues/410
)
- trigger
`mousedown`
and
`mousedown`
events on click
-
Added
[
`Tester#skip`
](
http://docs.casperjs.org/en/latest/modules/tester.html#skip
)
method
2013-02-08, v1.0.2
...
...
modules/casper.js
View file @
3a4ed2c
...
...
@@ -420,14 +420,15 @@ Casper.prototype.clear = function clear() {
Casper
.
prototype
.
click
=
function
click
(
selector
)
{
"use strict"
;
this
.
checkStarted
();
var
success
=
this
.
mouseEvent
(
'click'
,
selector
);
var
success
=
this
.
mouseEvent
(
'mousedown'
,
selector
);
success
=
success
&&
this
.
mouseEvent
(
'click'
,
selector
);
this
.
evaluate
(
function
(
selector
)
{
var
element
=
__utils__
.
findOne
(
selector
);
if
(
element
)
{
element
.
focus
();
}
},
selector
);
return
success
;
return
success
&&
this
.
mouseEvent
(
'mouseup'
,
selector
)
;
};
/**
...
...
tests/site/click.html
View file @
3a4ed2c
...
...
@@ -9,6 +9,7 @@
<a
id=
"test2"
href=
"#"
onclick=
"results.test2 = true;"
>
test2
</a>
<a
id=
"test3"
href=
"page1.html"
onclick=
"results.test3 = true; return false"
>
test3
</a>
<a
id=
"test4"
href=
"http://www.google.com/"
>
test4
</a>
<a
id=
"test5"
href=
"#"
>
test5
</a>
<script>
(
function
(
window
)
{
window
.
results
=
{
...
...
@@ -16,6 +17,7 @@
test2
:
false
,
test3
:
false
,
test4
:
false
,
test5
:
[],
testdown
:
[],
testup
:
[],
testmove
:
[],
...
...
@@ -38,6 +40,13 @@
window
.
ondblclick
=
function
(
event
)
{
results
.
testdoubleclick
=
[
event
.
x
,
event
.
y
];
};
var
test5elem
=
document
.
querySelector
(
'#test5'
);
test5elem
.
addEventListener
(
'mousedown'
,
function
(
event
)
{
results
.
test5
.
push
(
'mousedown'
);
});
test5elem
.
addEventListener
(
'mouseup'
,
function
(
event
)
{
results
.
test5
.
push
(
'mouseup'
);
});
})(
window
);
</script>
</body>
...
...
tests/suites/casper/click.js
View file @
3a4ed2c
...
...
@@ -92,3 +92,17 @@ casper.test.begin('element focus on click', 1, function(test) {
test
.
done
();
});
});
casper
.
test
.
begin
(
'mouse events on click'
,
2
,
function
(
test
)
{
casper
.
start
(
'tests/site/click.html'
,
function
()
{
this
.
click
(
'#test5'
);
}).
then
(
function
()
{
var
results
=
this
.
getGlobal
(
'results'
);
test
.
assert
(
results
.
test5
.
indexOf
(
'mousedown'
)
!==
-
1
,
'Casper.click() triggers mousedown event'
);
test
.
assert
(
results
.
test5
.
indexOf
(
'mouseup'
)
!==
-
1
,
'Casper.click() triggers mouseup event'
);
}).
run
(
function
()
{
test
.
done
();
});
});
...
...
Please
register
or
sign in
to post a comment