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
6407ef35
...
6407ef350468b9210bc15e88f5b0e18c2b8a7363
authored
2011-11-09 11:55:18 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
better usability of Casper.viewport()
1 parent
8168fe03
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
7 deletions
casper.js
tests/run.js
casper.js
View file @
6407ef3
...
...
@@ -675,11 +675,18 @@
/**
* Changes the current viewport size.
*
* @param Object viewportSize An objet with two props: width and height
* @param Number width The viewport width, in pixels
* @param Number height The viewport height, in pixels
* @return Casper
*/
viewport
:
function
(
viewportSize
)
{
this
.
page
.
viewportSize
=
viewportSize
;
viewport
:
function
(
width
,
height
)
{
if
(
typeof
width
!==
"number"
||
typeof
height
!==
"number"
||
width
<=
0
||
height
<=
0
)
{
throw
new
Error
(
"Invalid viewport width/height set: "
+
width
+
'x'
+
height
);
}
this
.
page
.
viewportSize
=
{
width
:
width
,
height
:
height
};
return
this
;
},
...
...
tests/run.js
View file @
6407ef3
...
...
@@ -51,10 +51,10 @@ casper.test.assert(casper.steps.length === 1, 'start() can add a new navigation
// Casper.viewport()
casper
.
test
.
comment
(
'viewport'
);
casper
.
viewport
(
{
width
:
1337
,
height
:
999
}
);
casper
.
test
.
assertEquals
(
casper
.
page
.
viewportSize
.
width
,
1337
,
'Casper.viewport() can change the width of
th
e viewport'
);
casper
.
test
.
assertEquals
(
casper
.
page
.
viewportSize
.
height
,
999
,
'Casper.viewport() can change the height of
th
e viewport'
);
casper
.
test
.
assertRaises
(
casper
.
viewport
,
'booh'
,
'Casper.viewport() validates viewport size data'
);
casper
.
viewport
(
1337
,
999
);
casper
.
test
.
assertEquals
(
casper
.
page
.
viewportSize
.
width
,
1337
,
'Casper.viewport() can change the width of
pag
e viewport'
);
casper
.
test
.
assertEquals
(
casper
.
page
.
viewportSize
.
height
,
999
,
'Casper.viewport() can change the height of
pag
e viewport'
);
casper
.
test
.
assertRaises
(
casper
.
viewport
,
[
'a'
,
'b'
]
,
'Casper.viewport() validates viewport size data'
);
// Casper#then()
casper
.
test
.
comment
(
'then'
);
...
...
Please
register
or
sign in
to post a comment