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
0d0e9621
...
0d0e962148663dd34fc54a8b27d1b481bc3d4c62
authored
2012-01-02 19:06:16 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
added events where applicable in Casper methods
1 parent
582f1f9a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
13 deletions
bin/casperjs
modules/casper.js
modules/utils.js
bin/casperjs
View file @
0d0e962
...
...
@@ -11,7 +11,7 @@ def resolve(path):
return
path
CASPER_PATH
=
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
resolve
(
__file__
)),
'..'
))
CASPER_ARGS
=
[
'phantomjs'
,
os
.
path
.
join
(
CASPER_PATH
,
'bin'
,
'bootstrap.js'
),
'--casper-path=
%
s'
%
CASPER_PATH
,
'--cli'
]
CASPER_ARGS
=
[
'phantomjs
14
'
,
os
.
path
.
join
(
CASPER_PATH
,
'bin'
,
'bootstrap.js'
),
'--casper-path=
%
s'
%
CASPER_PATH
,
'--cli'
]
CASPER_ARGS
.
extend
(
sys
.
argv
[
1
:])
try
:
...
...
modules/casper.js
View file @
0d0e962
This diff is collapsed.
Click to expand it.
modules/utils.js
View file @
0d0e962
...
...
@@ -70,7 +70,7 @@ function fileExt(file) {
exports
.
fileExt
=
fileExt
;
/**
* Takes a string and append blank until the pad value is reached.
* Takes a string and append blank
s
until the pad value is reached.
*
* @param String text
* @param Number pad Pad value (optional; default: 80)
...
...
@@ -85,8 +85,14 @@ function fillBlanks(text, pad) {
}
exports
.
fillBlanks
=
fillBlanks
;
/**
* Checks if value is a javascript Array
*
* @param mixed value
* @return Boolean
*/
function
isArray
(
value
)
{
return
isType
(
value
,
"array"
);
return
Array
.
isArray
(
value
)
||
isType
(
value
,
"array"
);
}
exports
.
isArray
=
isArray
;
...
...
@@ -101,17 +107,27 @@ function isCasperObject(value) {
}
exports
.
isCasperObject
=
isCasperObject
;
/**
* Checks if value is a phantomjs clipRect-compatible object
*
* @param mixed value
* @return Boolean
*/
function
isClipRect
(
value
)
{
return
isType
(
value
,
"cliprect"
)
||
(
isType
(
value
,
"object"
)
&&
isType
(
value
.
top
,
"number"
)
&&
isType
(
value
.
left
,
"number"
)
&&
isType
(
value
.
width
,
"number"
)
&&
isType
(
value
.
height
,
"number"
)
isObject
(
value
)
&&
isNumber
(
value
.
top
)
&&
isNumber
(
value
.
left
)
&&
isNumber
(
value
.
width
)
&&
isNumber
(
value
.
height
)
);
}
exports
.
isClipRect
=
isClipRect
;
/**
* Checks if value is a javascript Function
*
* @param mixed value
* @return Boolean
*/
function
isFunction
(
value
)
{
return
isType
(
value
,
"function"
);
}
...
...
@@ -125,15 +141,38 @@ exports.isFunction = isFunction;
*/
function
isJsFile
(
file
)
{
var
ext
=
fileExt
(
file
);
return
is
Type
(
ext
,
"string"
)
&&
[
'js'
,
'coffee'
].
indexOf
(
ext
)
!==
-
1
;
return
is
String
(
ext
,
"string"
)
&&
[
'js'
,
'coffee'
].
indexOf
(
ext
)
!==
-
1
;
}
exports
.
isJsFile
=
isJsFile
;
/**
* Checks if value is a javascript Number
*
* @param mixed value
* @return Boolean
*/
function
isNumber
(
value
)
{
return
isType
(
value
,
"number"
);
}
exports
.
isNumber
=
isNumber
;
/**
* Checks if value is a javascript Object
*
* @param mixed value
* @return Boolean
*/
function
isObject
(
value
)
{
return
isType
(
value
,
"object"
);
}
exports
.
isObject
=
isObject
;
/**
* Checks if value is a javascript String
*
* @param mixed value
* @return Boolean
*/
function
isString
(
value
)
{
return
isType
(
value
,
"string"
);
}
...
...
@@ -148,7 +187,10 @@ exports.isString = isString;
* @return Boolean
*/
function
isType
(
what
,
typeName
)
{
return
betterTypeOf
(
what
)
===
typeName
;
if
(
typeof
typeName
!==
"string"
||
!
typeName
)
{
throw
new
Error
(
"You must pass isType() a typeName string"
);
}
return
betterTypeOf
(
what
).
toLowerCase
()
===
typeName
.
toLowerCase
();
}
exports
.
isType
=
isType
;
...
...
@@ -159,10 +201,10 @@ exports.isType = isType;
* @return Boolean
*/
function
isWebPage
(
what
)
{
if
(
!
what
||
!
is
Type
(
what
,
"object"
))
{
if
(
!
what
||
!
is
Object
(
what
))
{
return
false
;
}
if
(
phantom
.
version
.
major
<=
1
&&
phantom
.
version
.
minor
<
3
&&
is
Type
(
require
,
"function"
))
{
if
(
phantom
.
version
.
major
<=
1
&&
phantom
.
version
.
minor
<
3
&&
is
Function
(
require
))
{
return
what
instanceof
WebPage
;
}
else
{
return
what
.
toString
().
indexOf
(
'WebPage('
)
===
0
;
...
...
@@ -202,9 +244,34 @@ exports.mergeObjects = mergeObjects;
function
serialize
(
value
)
{
if
(
isType
(
value
,
"array"
))
{
value
=
value
.
map
(
function
(
prop
)
{
return
is
Type
(
prop
,
"function"
)
?
prop
.
toString
().
replace
(
/
\s{2,}
/
,
''
)
:
prop
;
return
is
Function
(
prop
)
?
prop
.
toString
().
replace
(
/
\s{2,}
/
,
''
)
:
prop
;
});
}
return
JSON
.
stringify
(
value
,
null
,
4
);
}
exports
.
serialize
=
serialize
;
/**
* Inherit the prototype methods from one constructor into another.
*
* The Function.prototype.inherits from lang.js rewritten as a standalone
* function (not on Function.prototype). NOTE: If this file is to be loaded
* during bootstrapping this function needs to be revritten using some native
* functions as prototype setup using normal JavaScript does not work as
* expected during bootstrapping (see mirror.js in r114903).
*
* @param {function} ctor Constructor function which needs to inherit the
* prototype.
* @param {function} superCtor Constructor function to inherit prototype from.
*/
exports
.
inherits
=
function
(
ctor
,
superCtor
)
{
ctor
.
super_
=
superCtor
;
ctor
.
prototype
=
Object
.
create
(
superCtor
.
prototype
,
{
constructor
:
{
value
:
ctor
,
enumerable
:
false
,
writable
:
true
,
configurable
:
true
}
});
};
...
...
Please
register
or
sign in
to post a comment