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
25ad1e79
...
25ad1e791868d82a6c9e67176f8cdae085cfd336
authored
2013-04-12 04:45:18 -0500
by
Sean Massa
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
allow uppercase http methods
1 parent
80f55a14
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
1 deletions
modules/casper.js
tests/suites/casper/open.js
modules/casper.js
View file @
25ad1e7
...
...
@@ -1357,7 +1357,8 @@ Casper.prototype.open = function open(location, settings) {
// http method
// taken from https://github.com/ariya/phantomjs/blob/master/src/webpage.cpp#L302
var
methods
=
[
"get"
,
"head"
,
"put"
,
"post"
,
"delete"
];
if
(
settings
.
method
&&
(
!
utils
.
isString
(
settings
.
method
)
||
methods
.
indexOf
(
settings
.
method
)
===
-
1
))
{
var
lowerCaseMethod
=
settings
.
method
.
toLowerCase
();
if
(
settings
.
method
&&
(
!
utils
.
isString
(
settings
.
method
)
||
methods
.
indexOf
(
lowerCaseMethod
)
===
-
1
))
{
throw
new
CasperError
(
"open(): settings.method must be part of "
+
methods
.
join
(
', '
));
}
// http data
...
...
tests/suites/casper/open.js
View file @
25ad1e7
...
...
@@ -32,6 +32,25 @@ casper.test.begin('open() GET tests', 2, {
}
});
casper
.
test
.
begin
(
'open() GET casing tests'
,
2
,
{
setUp
:
setUp
,
tearDown
:
tearDown
,
test
:
function
(
test
)
{
casper
.
open
(
'tests/site/index.html'
,
{
method
:
'GET'
}).
then
(
function
()
{
test
.
pass
(
"Casper.open() can open and load a location using GET"
);
test
.
assertEquals
(
usedSettings
,
{
method
:
"GET"
},
"Casper.open() used the expected GET settings"
);
});
casper
.
run
(
function
()
{
test
.
done
();
});
}
});
casper
.
test
.
begin
(
'open() POST tests'
,
2
,
{
setUp
:
setUp
,
tearDown
:
tearDown
,
...
...
@@ -56,6 +75,30 @@ casper.test.begin('open() POST tests', 2, {
}
});
casper
.
test
.
begin
(
'open() POST casing tests'
,
2
,
{
setUp
:
setUp
,
tearDown
:
tearDown
,
test
:
function
(
test
)
{
casper
.
open
(
'tests/site/index.html'
,
{
method
:
'POST'
,
data
:
{
plop
:
42
,
chuck
:
'norris'
}
}).
then
(
function
()
{
test
.
pass
(
"Casper.open() can open and load a location using POST"
);
test
.
assertEquals
(
usedSettings
,
{
method
:
"POST"
,
data
:
"plop=42&chuck=norris"
},
"Casper.open() used the expected POST settings"
);
});
casper
.
run
(
function
()
{
test
.
done
();
});
}
});
casper
.
test
.
begin
(
'open() PUT tests'
,
2
,
{
setUp
:
setUp
,
tearDown
:
tearDown
,
...
...
@@ -80,6 +123,30 @@ casper.test.begin('open() PUT tests', 2, {
}
});
casper
.
test
.
begin
(
'open() PUT casing tests'
,
2
,
{
setUp
:
setUp
,
tearDown
:
tearDown
,
test
:
function
(
test
)
{
casper
.
thenOpen
(
'tests/site/index.html'
,
{
method
:
'PUT'
,
data
:
{
plop
:
42
,
chuck
:
'norris'
}
}).
then
(
function
()
{
test
.
pass
(
"Casper.open() can open and load a location using PUT"
);
test
.
assertEquals
(
usedSettings
,
{
method
:
"PUT"
,
data
:
"plop=42&chuck=norris"
},
"Casper.open() used the expected PUT settings"
);
});
casper
.
run
(
function
()
{
test
.
done
();
});
}
});
casper
.
test
.
begin
(
'open() PUT tests'
,
2
,
{
setUp
:
setUp
,
tearDown
:
tearDown
,
...
...
Please
register
or
sign in
to post a comment