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
2ce1b83c
...
2ce1b83cb0df2125111412d123979862e802706f
authored
2011-12-25 11:06:36 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fixed remaining missing require() calls
1 parent
c959bbfe
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
17 deletions
modules/casper.js
modules/clientutils.js
modules/injector.js
modules/xunit.js
tests/run.js
modules/casper.js
View file @
2ce1b83
...
...
@@ -1137,10 +1137,23 @@ function createPage(casper) {
}
}
// Client-side utils injection
if
(
!
casper
.
page
.
injectJs
(
fs
.
pathJoin
(
phantom
.
casperPath
,
'
lib
'
,
'clientutils.js'
)))
{
if
(
!
casper
.
page
.
injectJs
(
fs
.
pathJoin
(
phantom
.
casperPath
,
'
modules
'
,
'clientutils.js'
)))
{
casper
.
log
(
"Failed to inject Casper client-side utilities!"
,
"warning"
);
}
else
{
casper
.
log
(
"Successfully injected Casper client-side utilities"
,
"debug"
);
var
injected
=
casper
.
evaluate
(
function
()
{
var
__utils__
;
try
{
__utils__
=
new
CasperUtils
();
return
true
;
}
catch
(
e
)
{
return
false
;
}
});
if
(
true
===
injected
)
{
casper
.
log
(
"Successfully injected Casper client-side utilities"
,
"debug"
);
}
else
{
casper
.
log
(
"Failed to instantiate Casper client-side utilities!"
,
"warning"
);
}
}
// history
casper
.
history
.
push
(
casper
.
getCurrentUrl
());
...
...
modules/clientutils.js
View file @
2ce1b83
...
...
@@ -338,10 +338,11 @@
};
/**
* Logs a message.
* Logs a message. Will format the message a way CasperJS will be able
* to log phantomjs side.
*
* @param String message
* @param String level
* @param String message
The message to log
* @param String level
The log level
*/
this
.
log
=
function
(
message
,
level
)
{
console
.
log
(
"[casper:"
+
(
level
||
"debug"
)
+
"] "
+
message
);
...
...
@@ -362,9 +363,9 @@
field
=
fields
[
0
];
}
if
(
!
field
instanceof
HTMLElement
)
{
this
.
log
(
"
i
nvalid field type; only HTMLElement and NodeList are supported"
,
"error"
);
this
.
log
(
"
I
nvalid field type; only HTMLElement and NodeList are supported"
,
"error"
);
}
this
.
log
(
'
s
et "'
+
field
.
getAttribute
(
'name'
)
+
'" field value to '
+
value
,
"debug"
);
this
.
log
(
'
S
et "'
+
field
.
getAttribute
(
'name'
)
+
'" field value to '
+
value
,
"debug"
);
try
{
field
.
focus
();
}
catch
(
e
)
{
...
...
@@ -409,7 +410,7 @@
case
"file"
:
throw
{
name
:
"FileUploadError"
,
message
:
"
f
ile field must be filled using page.uploadFile"
,
message
:
"
F
ile field must be filled using page.uploadFile"
,
path
:
value
};
case
"radio"
:
...
...
@@ -418,11 +419,11 @@
e
.
checked
=
(
e
.
value
===
value
);
});
}
else
{
out
=
'
p
rovided radio elements are empty'
;
out
=
'
U
rovided radio elements are empty'
;
}
break
;
default
:
out
=
"
u
nsupported input field type: "
+
type
;
out
=
"
U
nsupported input field type: "
+
type
;
break
;
}
break
;
...
...
@@ -431,7 +432,7 @@
field
.
value
=
value
;
break
;
default
:
out
=
'
u
nsupported field type: '
+
nodeName
;
out
=
'
U
nsupported field type: '
+
nodeName
;
break
;
}
try
{
...
...
@@ -442,4 +443,4 @@
return
out
;
};
};
})(
exports
||
window
||
{}
);
})(
typeof
exports
===
"object"
?
exports
:
window
);
...
...
modules/injector.js
View file @
2ce1b83
...
...
@@ -26,7 +26,7 @@
*
*/
exports
.
create
=
create
;
var
utils
=
require
(
'utils'
)
;
exports
.
create
=
function
(
fn
)
{
return
new
FunctionArgsInjector
(
fn
);
...
...
@@ -38,7 +38,7 @@ exports.create = function(fn) {
* FIXME: use new Function() instead of eval()
*/
var
FunctionArgsInjector
=
function
(
fn
)
{
if
(
!
isType
(
fn
,
"function"
))
{
if
(
!
utils
.
isType
(
fn
,
"function"
))
{
throw
new
Error
(
"FunctionArgsInjector() can only process functions"
);
}
this
.
fn
=
fn
;
...
...
@@ -61,7 +61,7 @@ var FunctionArgsInjector = function(fn) {
this
.
process
=
function
(
values
)
{
var
fnObj
=
this
.
extract
(
this
.
fn
);
if
(
!
isType
(
fnObj
,
"object"
))
{
if
(
!
utils
.
isType
(
fnObj
,
"object"
))
{
throw
new
Error
(
"Unable to process function "
+
this
.
fn
.
toString
());
}
var
inject
=
this
.
getArgsInjectionString
(
fnObj
.
args
,
values
);
...
...
modules/xunit.js
View file @
2ce1b83
...
...
@@ -26,6 +26,8 @@
*
*/
var
utils
=
require
(
'utils'
);
exports
.
create
=
function
()
{
return
new
XUnitExporter
();
};
...
...
@@ -39,7 +41,7 @@ XUnitExporter = function() {
var
node
=
document
.
createElement
(
name
);
for
(
var
attrName
in
attributes
)
{
var
value
=
attributes
[
attrName
];
if
(
attributes
.
hasOwnProperty
(
attrName
)
&&
isType
(
attrName
,
"string"
))
{
if
(
attributes
.
hasOwnProperty
(
attrName
)
&&
utils
.
isType
(
attrName
,
"string"
))
{
node
.
setAttribute
(
attrName
,
value
);
}
}
...
...
tests/run.js
View file @
2ce1b83
...
...
@@ -4,6 +4,7 @@ if (!phantom.casperLoaded) {
}
var
fs
=
require
(
'fs'
);
var
utils
=
require
(
'utils'
);
phantom
.
injectJs
(
fs
.
pathJoin
(
phantom
.
casperPath
,
'lib'
,
'vendors'
,
'esprima.js'
));
...
...
@@ -15,7 +16,7 @@ var casper = new phantom.Casper({
// Overriding Casper.open to prefix all test urls
phantom
.
Casper
.
extend
({
open
:
function
(
location
,
options
)
{
options
=
isType
(
options
,
"object"
)
?
options
:
{};
options
=
utils
.
isType
(
options
,
"object"
)
?
options
:
{};
this
.
requestUrl
=
location
;
var
url
=
'file://'
+
phantom
.
casperPath
+
'/'
+
location
;
this
.
page
.
open
(
url
);
...
...
Please
register
or
sign in
to post a comment