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
c959bbfe
...
c959bbfeee8cfe6269d1a4ba0cf13a5c417219e8
authored
2011-12-25 09:28:53 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
s/lib/modules
1 parent
301d6345
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
14 additions
and
41 deletions
bin/casperjs
lib/casper.js → modules/casper.js
lib/clientutils.js → modules/clientutils.js
lib/colorizer.js → modules/colorizer.js
lib/injector.js → modules/injector.js
lib/tester.js → modules/tester.js
lib/utils.js → modules/utils.js
lib/vendors/esprima.js → modules/vendors/esprima.js
lib/xunit.js → modules/xunit.js
bin/casperjs
deleted
100755 → 0
View file @
301d634
#!/usr/bin/env python
import
os
import
subprocess
import
sys
def
resolve
(
path
):
if
os
.
path
.
islink
(
path
):
return
resolve
(
os
.
readlink
(
path
))
return
path
CASPER_PATH
=
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
resolve
(
__file__
)),
'..'
))
CASPER_ARGS
=
[
'phantomjs'
,
os
.
path
.
join
(
CASPER_PATH
,
'casper.js'
),
'--casper-path=
%
s'
%
CASPER_PATH
,
'--cli'
]
CASPER_ARGS
.
extend
(
sys
.
argv
[
1
:])
try
:
subprocess
.
call
(
CASPER_ARGS
)
except
KeyboardInterrupt
:
print
'
\n
CasperJS interrupted, exiting.'
sys
.
exit
()
lib
/casper.js
→
modules
/casper.js
View file @
c959bbf
...
...
@@ -26,7 +26,8 @@
*
*/
var
utils
=
require
(
'./lib/utils'
);
var
fs
=
require
(
'fs'
);
var
utils
=
require
(
'utils'
);
exports
.
create
=
function
(
options
)
{
return
new
Casper
(
options
);
...
...
@@ -72,7 +73,7 @@ var Casper = function(options) {
// properties
this
.
checker
=
null
;
this
.
cli
=
phantom
.
casperArgs
;
this
.
colorizer
=
require
(
'
./lib/
colorizer'
).
create
();
this
.
colorizer
=
require
(
'colorizer'
).
create
();
this
.
currentUrl
=
'about:blank'
;
this
.
currentHTTPStatus
=
200
;
this
.
defaultWaitTimeout
=
5000
;
...
...
@@ -99,7 +100,7 @@ var Casper = function(options) {
this
.
started
=
false
;
this
.
step
=
-
1
;
this
.
steps
=
[];
this
.
test
=
require
(
'
./lib/
tester'
).
create
(
this
);
this
.
test
=
require
(
'tester'
).
create
(
this
);
};
/**
...
...
@@ -306,9 +307,9 @@ Casper.prototype = {
* @return Casper
*/
download
:
function
(
url
,
targetPath
)
{
var
cu
=
require
(
'
./lib/
clientutils'
).
create
();
var
cu
=
require
(
'clientutils'
).
create
();
try
{
require
(
'fs'
)
.
write
(
targetPath
,
cu
.
decode
(
this
.
base64encode
(
url
)),
'w'
);
fs
.
write
(
targetPath
,
cu
.
decode
(
this
.
base64encode
(
url
)),
'w'
);
}
catch
(
e
)
{
this
.
log
(
"Error while downloading "
+
url
+
" to "
+
targetPath
+
": "
+
e
,
"error"
);
}
...
...
@@ -372,7 +373,7 @@ Casper.prototype = {
*/
evaluate
:
function
(
fn
,
context
)
{
context
=
utils
.
isType
(
context
,
"object"
)
?
context
:
{};
var
newFn
=
require
(
'
./lib/
injector'
).
create
(
fn
).
process
(
context
);
var
newFn
=
require
(
'injector'
).
create
(
fn
).
process
(
context
);
return
this
.
page
.
evaluate
(
newFn
);
},
...
...
@@ -1122,7 +1123,7 @@ function createPage(casper) {
}
}
if
(
casper
.
options
.
clientScripts
)
{
if
(
betterTypeOf
(
casper
.
options
.
clientScripts
)
!==
"array"
)
{
if
(
!
utils
.
isType
(
casper
.
options
.
clientScripts
,
"array"
)
)
{
casper
.
log
(
"The clientScripts option must be an array"
,
"error"
);
}
else
{
for
(
var
i
=
0
;
i
<
casper
.
options
.
clientScripts
.
length
;
i
++
)
{
...
...
@@ -1136,14 +1137,7 @@ function createPage(casper) {
}
}
// Client-side utils injection
var
injected
=
page
.
evaluate
(
replaceFunctionPlaceholders
(
function
()
{
eval
(
"var ClientUtils = "
+
decodeURIComponent
(
"%utils%"
));
__utils__
=
new
ClientUtils
();
return
__utils__
instanceof
ClientUtils
;
},
{
utils
:
encodeURIComponent
(
require
(
'./lib/clientutils'
).
ClientUtils
.
toString
())
}));
if
(
!
injected
)
{
if
(
!
casper
.
page
.
injectJs
(
fs
.
pathJoin
(
phantom
.
casperPath
,
'lib'
,
'clientutils.js'
)))
{
casper
.
log
(
"Failed to inject Casper client-side utilities!"
,
"warning"
);
}
else
{
casper
.
log
(
"Successfully injected Casper client-side utilities"
,
"debug"
);
...
...
lib
/clientutils.js
→
modules
/clientutils.js
View file @
c959bbf
...
...
@@ -34,7 +34,7 @@
/**
* Casper client-side helpers.
*/
var
ClientUtils
=
function
()
{
exports
.
ClientUtils
=
function
()
{
var
BASE64_ENCODE_CHARS
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
;
var
BASE64_DECODE_CHARS
=
new
Array
(
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
...
...
@@ -442,4 +442,4 @@
return
out
;
};
};
})(
exports
||
{});
})(
exports
||
window
||
{});
...
...
lib
/colorizer.js
→
modules
/colorizer.js
View file @
c959bbf
File moved
lib
/injector.js
→
modules
/injector.js
View file @
c959bbf
File moved
lib
/tester.js
→
modules
/tester.js
View file @
c959bbf
...
...
@@ -27,7 +27,7 @@
*/
var
fs
=
require
(
'fs'
);
var
utils
=
require
(
'
./lib/
utils'
);
var
utils
=
require
(
'utils'
);
exports
.
create
=
function
(
casper
,
options
)
{
return
new
Tester
(
casper
,
options
);
...
...
@@ -47,7 +47,7 @@ var Tester = function(casper, options) {
}
// locals
var
exporter
=
require
(
'
./lib/
xunit'
).
create
();
var
exporter
=
require
(
'xunit'
).
create
();
var
PASS
=
this
.
options
.
PASS
||
"PASS"
;
var
FAIL
=
this
.
options
.
FAIL
||
"FAIL"
;
...
...
lib
/utils.js
→
modules
/utils.js
View file @
c959bbf
...
...
@@ -92,7 +92,7 @@ exports.fillBlanks = fillBlanks;
* @return Boolean
*/
function
isCasperObject
(
value
)
{
return
value
instanceof
require
(
'
./lib/
casper'
).
Casper
;
return
value
instanceof
require
(
'casper'
).
Casper
;
}
exports
.
isCasperObject
=
isCasperObject
;
...
...
lib
/vendors/esprima.js
→
modules
/vendors/esprima.js
View file @
c959bbf
File moved
lib
/xunit.js
→
modules
/xunit.js
View file @
c959bbf
File moved
Please
register
or
sign in
to post a comment