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
8c6dd1f3
...
8c6dd1f368aac0f5ab153af3238a7bcaf8d7fd9a
authored
2013-01-05 12:16:04 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Added `casper.mouse.doubleclick()`
1 parent
cd44ddab
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
10 deletions
CHANGELOG.md
modules/mouse.js
tests/site/click.html
tests/suites/casper/click.js
CHANGELOG.md
View file @
8c6dd1f
...
...
@@ -70,6 +70,7 @@ XXXX-XX-XX, v1.0.1
------------------
-
fixed
[
#336
](
https://github.com/n1k0/casperjs/issues/336
)
- Test result duration may have an exotic value
-
Added
`casper.mouse.doubleclick()`
2012-12-24, v1.0.0
------------------
...
...
modules/mouse.js
View file @
8c6dd1f
...
...
@@ -43,11 +43,13 @@ var Mouse = function Mouse(casper) {
throw
new
CasperError
(
'Mouse() needs a Casper instance'
);
}
var
slice
=
Array
.
prototype
.
slice
;
var
nativeEvents
=
[
'mouseup'
,
'mousedown'
,
'click'
,
'mousemove'
];
var
emulatedEvents
=
[
'mouseover'
,
'mouseout'
];
var
supportedEvents
=
nativeEvents
.
concat
(
emulatedEvents
);
var
slice
=
Array
.
prototype
.
slice
,
nativeEvents
=
[
'mouseup'
,
'mousedown'
,
'click'
,
'mousemove'
];
if
(
phantom
.
version
.
major
>=
1
&&
phantom
.
version
.
minor
>=
8
)
{
nativeEvents
.
push
(
'doubleclick'
);
}
var
emulatedEvents
=
[
'mouseover'
,
'mouseout'
],
supportedEvents
=
nativeEvents
.
concat
(
emulatedEvents
);
function
computeCenter
(
selector
)
{
var
bounds
=
casper
.
getElementBounds
(
selector
);
...
...
@@ -94,6 +96,10 @@ var Mouse = function Mouse(casper) {
processEvent
(
'click'
,
arguments
);
};
this
.
doubleclick
=
function
doubleclick
()
{
processEvent
(
'doubleclick'
,
arguments
);
};
this
.
down
=
function
down
()
{
processEvent
(
'mousedown'
,
arguments
);
};
...
...
tests/site/click.html
View file @
8c6dd1f
...
...
@@ -16,10 +16,11 @@
test2
:
false
,
test3
:
false
,
test4
:
false
,
testdown
:
[],
testup
:
[],
testmove
:
[],
testclick
:
[]
testdown
:
[],
testup
:
[],
testmove
:
[],
testclick
:
[],
testdoubleclick
:
[]
};
document
.
querySelector
(
'#test4'
).
onclick
=
function
(
event
)
{
results
.
test4
=
true
;
...
...
@@ -34,6 +35,9 @@
window
.
onmousemove
=
function
(
event
)
{
results
.
testmove
=
[
event
.
x
,
event
.
y
];
};
window
.
ondblclick
=
function
(
event
)
{
results
.
testdoubleclick
=
[
event
.
x
,
event
.
y
];
};
})(
window
);
</script>
</body>
...
...
tests/suites/casper/click.js
View file @
8c6dd1f
...
...
@@ -52,7 +52,7 @@ casper.test.begin('clickLabel tests tests', 8, function(test) {
});
});
casper
.
test
.
begin
(
'casper.mouse tests'
,
3
,
function
(
test
)
{
casper
.
test
.
begin
(
'casper.mouse tests'
,
4
,
function
(
test
)
{
casper
.
start
(
'tests/site/click.html'
,
function
()
{
this
.
mouse
.
down
(
200
,
100
);
var
results
=
this
.
getGlobal
(
'results'
);
...
...
@@ -66,6 +66,14 @@ casper.test.begin('casper.mouse tests', 3, function(test) {
results
=
this
.
getGlobal
(
'results'
);
test
.
assertEquals
(
results
.
testmove
,
[
200
,
100
],
'Mouse.move() has moved to the specified position'
);
if
(
phantom
.
version
.
major
>=
1
&&
phantom
.
version
.
minor
>=
8
)
{
this
.
mouse
.
doubleclick
(
200
,
100
);
results
=
this
.
getGlobal
(
'results'
);
this
.
test
.
assertEquals
(
results
.
testdoubleclick
,
[
200
,
100
],
'Mouse.doubleclick() double-clicked the specified position'
);
}
else
{
this
.
test
.
pass
(
"Mouse.doubleclick() requires PhantomJS >= 1.8"
);
}
}).
run
(
function
()
{
test
.
done
();
});
...
...
Please
register
or
sign in
to post a comment