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
2d4371b7
...
2d4371b7d6cf982a775b16a70105ee2a001bf51b
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
48802a01
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
11 deletions
CHANGELOG.md
modules/mouse.js
tests/site/click.html
tests/suites/casper/click.js
CHANGELOG.md
View file @
2d4371b
...
...
@@ -5,6 +5,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 @
2d4371b
...
...
@@ -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 @
2d4371b
...
...
@@ -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 @
2d4371b
/*global casper*/
/*jshint strict:false*/
/*jshint strict:false
maxstatements: 99
*/
casper
.
start
(
'tests/site/index.html'
,
function
()
{
this
.
click
(
'a[href="test.html"]'
);
});
...
...
@@ -56,6 +56,16 @@ casper.then(function() {
this
.
mouse
.
move
(
200
,
100
);
results
=
this
.
getGlobal
(
'results'
);
this
.
test
.
assertEquals
(
results
.
testmove
,
[
200
,
100
],
'Mouse.move() has moved to the specified position'
);
if
(
phantom
.
version
.
major
>=
1
&&
phantom
.
version
.
minor
>=
8
)
{
this
.
test
.
comment
(
'Mouse.doubleclick()'
);
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"
);
}
});
// element focus on click
...
...
@@ -67,5 +77,5 @@ casper.then(function() {
});
casper
.
run
(
function
()
{
this
.
test
.
done
(
2
2
);
this
.
test
.
done
(
2
3
);
});
...
...
Please
register
or
sign in
to post a comment