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
dc4eea0d
...
dc4eea0d1381b3deb0d4fa8b85c847e8a5f375d1
authored
2012-10-27 20:40:39 +0200
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
.jshintignore directives
1 parent
ad632762
Hide whitespace changes
Inline
Side-by-side
Showing
36 changed files
with
78 additions
and
13 deletions
.jshintignore
bin/bootstrap.js
modules/casper.js
tests/suites/casper/agent.js
tests/suites/casper/capture.js
tests/suites/casper/click.js
tests/suites/casper/confirm.js
tests/suites/casper/debug.js
tests/suites/casper/elementattribute.js
tests/suites/casper/encode.js
tests/suites/casper/evaluate.js
tests/suites/casper/events.js
tests/suites/casper/exists.js
tests/suites/casper/fetchtext.js
tests/suites/casper/flow.coffee
tests/suites/casper/formfill.js
tests/suites/casper/global.js
tests/suites/casper/headers.js
tests/suites/casper/history.js
tests/suites/casper/hooks.js
tests/suites/casper/mouseevents.js
tests/suites/casper/onerror.js
tests/suites/casper/open.js
tests/suites/casper/prompt.js
tests/suites/casper/start.js
tests/suites/casper/steps.js
tests/suites/casper/viewport.js
tests/suites/casper/visible.js
tests/suites/casper/xpath.js
tests/suites/cli.js
tests/suites/clientutils.js
tests/suites/fs.js
tests/suites/http_status.js
tests/suites/injector.js
tests/suites/utils.js
tests/suites/xunit.js
.jshintignore
View file @
dc4eea0
...
...
@@ -5,4 +5,3 @@ modules/querystring.js
samples
tests/site
tests/testdir
tests/suites
...
...
bin/bootstrap.js
View file @
dc4eea0
...
...
@@ -29,6 +29,7 @@
*/
/*global console phantom require*/
/*jshint maxstatements:30 maxcomplexity:10*/
if
(
!
phantom
)
{
console
.
error
(
'CasperJS needs to be executed in a PhantomJS environment http://phantomjs.org/'
);
...
...
modules/casper.js
View file @
dc4eea0
...
...
@@ -75,6 +75,7 @@ exports.selectXPath = selectXPath;
*/
var
Casper
=
function
Casper
(
options
)
{
"use strict"
;
/*jshint maxstatements:30*/
// init & checks
if
(
!
(
this
instanceof
Casper
))
{
return
new
Casper
(
options
);
...
...
tests/suites/casper/agent.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
function
testUA
(
ua
,
match
)
{
casper
.
test
.
assertMatch
(
ua
,
match
,
'Default user agent matches '
+
match
...
...
tests/suites/casper/capture.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
var
fs
=
require
(
'fs'
),
testFile
=
'/tmp/__casper_test_capture.png'
;
if
(
fs
.
exists
(
testFile
)
&&
fs
.
isFile
(
testFile
))
{
...
...
tests/suites/casper/click.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
casper
.
start
(
'tests/site/index.html'
,
function
()
{
this
.
click
(
'a[href="test.html"]'
);
});
...
...
tests/suites/casper/confirm.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
// skip this test for phantom versions < 1.5
if
(
phantom
.
version
.
major
===
1
&&
phantom
.
version
.
minor
<
6
)
{
casper
.
test
.
comment
(
'Skipped tests, PhantomJS 1.6 required'
);
...
...
tests/suites/casper/debug.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
casper
.
start
(
'tests/site/index.html'
,
function
()
{
this
.
test
.
assertEquals
(
this
.
getHTML
(
'ul li'
),
'one'
,
'Casper.getHTML() retrieves inner HTML by default'
);
this
.
test
.
assertEquals
(
this
.
getHTML
(
'ul li'
,
true
),
'<li>one</li>'
,
'Casper.getHTML() can retrieve outer HTML'
);
...
...
tests/suites/casper/elementattribute.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
casper
.
start
(
'tests/site/elementattribute.html'
,
function
()
{
this
.
test
.
comment
(
'Casper.getElementAttribute()'
);
this
.
test
.
assertEquals
(
this
.
getElementAttribute
(
'.testo'
,
'data-stuff'
),
'beautiful string'
,
'Casper.getElementAttribute() works as intended'
);
...
...
tests/suites/casper/encode.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
var
fs
=
require
(
'fs'
);
// FIXME: we're using local url scheme until https://github.com/ariya/phantomjs/pull/288 is
...
...
tests/suites/casper/evaluate.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
casper
.
test
.
comment
(
'Casper.evaluate()'
);
casper
.
start
();
...
...
tests/suites/casper/events.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
// events
casper
.
test
.
comment
(
"events"
);
...
...
tests/suites/casper/exists.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
casper
.
test
.
comment
(
'Casper.exists()'
);
casper
.
start
(
'tests/site/index.html'
,
function
()
{
...
...
tests/suites/casper/fetchtext.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
casper
.
test
.
comment
(
'Casper.fetchText()'
);
casper
.
start
(
'tests/site/index.html'
,
function
()
{
...
...
tests/suites/casper/flow.coffee
View file @
dc4eea0
...
...
@@ -35,4 +35,4 @@ casper.then ->
casper
.
then
->
@
test
.
assertEquals
++
step
,
13
,
"last step"
casper
.
run
(
->
@
test
.
done
())
\ No newline at end of file
casper
.
run
(
->
@
test
.
done
())
...
...
tests/suites/casper/formfill.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
casper
.
start
(
'tests/site/form.html'
,
function
()
{
this
.
test
.
comment
(
'Casper.fill()'
);
this
.
fill
(
'form[action="result.html"]'
,
{
...
...
tests/suites/casper/global.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
casper
.
start
(
'tests/site/global.html'
,
function
()
{
this
.
test
.
comment
(
'Casper.getGlobal()'
);
this
.
test
.
assertEquals
(
this
.
getGlobal
(
'myGlobal'
),
'awesome string'
,
'Casper.getGlobal() can retrieve a remote global variable'
);
...
...
tests/suites/casper/headers.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
casper
.
test
.
comment
(
'Casper.headers.get()'
);
var
server
=
require
(
'webserver'
).
create
();
...
...
tests/suites/casper/history.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
casper
.
start
(
'tests/site/page1.html'
);
casper
.
thenOpen
(
'tests/site/page2.html'
);
casper
.
thenOpen
(
'tests/site/page3.html'
);
...
...
tests/suites/casper/hooks.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
// Dear curious test reader,
// The on* family of methods is considered deprecated since 0.6.0; please use events instead
...
...
tests/suites/casper/mouseevents.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false maxstatements:99*/
casper
.
start
(
'tests/site/mouse-events.html'
);
casper
.
then
(
function
()
{
...
...
tests/suites/casper/onerror.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
casper
.
test
.
comment
(
"page.error event"
);
var
error
=
{};
...
...
tests/suites/casper/open.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
var
t
=
casper
.
test
,
current
=
0
,
tests
=
[
function
(
settings
)
{
t
.
assertEquals
(
settings
,
{
...
...
@@ -130,4 +132,4 @@ casper.thenOpen('tests/site/index.html', {
casper
.
run
(
function
()
{
this
.
removeAllListeners
(
'open'
);
t
.
done
();
});
\ No newline at end of file
});
...
...
tests/suites/casper/prompt.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
// skip this test for phantom versions < 1.5
if
(
phantom
.
version
.
major
===
1
&&
phantom
.
version
.
minor
<
6
)
{
casper
.
test
.
comment
(
'Skipped tests, PhantomJS 1.6 required'
);
...
...
tests/suites/casper/start.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
casper
.
test
.
comment
(
'Casper.start()'
);
casper
.
start
(
'tests/site/index.html'
,
function
()
{
...
...
tests/suites/casper/steps.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
casper
.
test
.
comment
(
'Casper.then()'
);
casper
.
start
(
'tests/site/index.html'
);
...
...
tests/suites/casper/viewport.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
casper
.
test
.
comment
(
'Casper.viewport()'
);
casper
.
start
();
...
...
tests/suites/casper/visible.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
casper
.
start
(
'tests/site/visible.html'
,
function
()
{
this
.
test
.
comment
(
'Casper.visible()'
);
this
.
test
.
assert
(
this
.
visible
(
'#img1'
),
'Casper.visible() can detect if an element is visible'
);
...
...
tests/suites/casper/xpath.js
View file @
dc4eea0
/*global casper __utils__*/
/*jshint strict:false*/
var
x
=
require
(
'casper'
).
selectXPath
;
casper
.
test
.
comment
(
'XPath'
);
...
...
tests/suites/cli.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
var
cli
=
require
(
'cli'
),
t
=
casper
.
test
;
t
.
comment
(
'parse(), get(), has()'
);
...
...
tests/suites/clientutils.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
var
fs
=
require
(
'fs'
);
var
x
=
require
(
'casper'
).
selectXPath
;
...
...
tests/suites/fs.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
var
fs
=
require
(
'fs'
),
t
=
casper
.
test
;
// Testing added methods
...
...
@@ -33,4 +35,4 @@ var fs = require('fs'), t = casper.test;
}
})();
t
.
done
();
\ No newline at end of file
t
.
done
();
...
...
tests/suites/http_status.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
/**
* Special test server to test for HTTP status codes
*
...
...
@@ -19,7 +21,7 @@ casper.thenOpen('file://' + phantom.casperPath + '/tests/site/index.html', funct
});
// http protocol
codes
=
[
100
,
101
,
102
,
118
,
200
,
201
,
202
,
203
,
204
,
205
,
206
,
207
,
210
,
var
codes
=
[
100
,
101
,
102
,
118
,
200
,
201
,
202
,
203
,
204
,
205
,
206
,
207
,
210
,
300
,
301
,
302
,
303
,
304
,
305
,
307
,
310
,
400
,
401
,
402
,
403
,
404
,
405
,
406
,
407
,
408
,
409
,
410
,
411
,
412
,
413
,
414
,
415
,
416
,
417
,
418
,
422
,
423
,
424
,
425
,
426
,
449
,
450
,
...
...
tests/suites/injector.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
var
t
=
casper
.
test
;
var
createInjector
=
function
(
fn
,
values
)
{
return
require
(
'injector'
).
create
(
fn
,
values
);
...
...
tests/suites/utils.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false maxstatements:99*/
var
utils
=
require
(
'utils'
),
t
=
casper
.
test
,
x
=
require
(
'casper'
).
selectXPath
;
...
...
@@ -66,7 +68,7 @@ t.comment('fileExt()');
t
.
comment
(
'fillBlanks()'
);
(
function
()
{
testCases
=
{
var
testCases
=
{
'foo'
:
'foo '
,
' foo bar '
:
' foo bar '
,
' foo bar '
:
' foo bar '
...
...
@@ -79,7 +81,7 @@ t.comment('fillBlanks()');
t
.
comment
(
'getPropertyPath()'
);
(
function
()
{
testCases
=
[
var
testCases
=
[
{
input
:
utils
.
getPropertyPath
({},
'a.b.c'
),
output
:
undefined
...
...
@@ -123,7 +125,7 @@ t.comment('isArray()');
t
.
comment
(
'isClipRect()'
);
(
function
()
{
testCases
=
[
var
testCases
=
[
[{},
false
],
[{
top
:
2
},
false
],
[{
top
:
2
,
left
:
2
,
width
:
2
,
height
:
2
},
true
],
...
...
@@ -138,7 +140,7 @@ t.comment('isClipRect()');
t
.
comment
(
'isHTTPResource()'
);
(
function
()
{
testCases
=
[
var
testCases
=
[
[{},
false
],
[{
url
:
'file:///var/www/i.html'
},
false
],
[{
url
:
'mailto:plop@plop.com'
},
false
],
...
...
@@ -201,7 +203,7 @@ t.comment('isWebPage()');
t
.
comment
(
'isJsFile()'
);
(
function
()
{
testCases
=
{
var
testCases
=
{
''
:
false
,
'toto.png'
:
false
,
'plop'
:
false
,
...
...
@@ -216,7 +218,7 @@ t.comment('isJsFile()');
t
.
comment
(
'mergeObjects()'
);
(
function
()
{
testCases
=
[
var
testCases
=
[
{
obj1
:
{
a
:
1
},
obj2
:
{
b
:
2
},
merged
:
{
a
:
1
,
b
:
2
}
},
...
...
@@ -247,7 +249,7 @@ t.comment('mergeObjects()');
t
.
comment
(
'unique()'
);
(
function
()
{
testCases
=
[
var
testCases
=
[
{
input
:
[
1
,
2
,
3
],
output
:
[
1
,
2
,
3
]
...
...
tests/suites/xunit.js
View file @
dc4eea0
/*global casper*/
/*jshint strict:false*/
casper
.
test
.
comment
(
'phantom.Casper.XUnitExporter'
);
xunit
=
require
(
'xunit'
).
create
();
var
xunit
=
require
(
'xunit'
).
create
();
xunit
.
addSuccess
(
'foo'
,
'bar'
);
casper
.
test
.
assertMatch
(
xunit
.
getXML
(),
/<testcase classname="foo" name="bar"/
,
'XUnitExporter.addSuccess() adds a successful testcase'
);
xunit
.
addFailure
(
'bar'
,
'baz'
,
'wrong'
,
'chucknorriz'
);
...
...
Please
register
or
sign in
to post a comment