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
ea6b83e3
...
ea6b83e3d08dab0c7f479b2321bc9b98af46aed8
authored
2013-11-26 14:16:31 -0800
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge pull request #708 from laurentj/geckofix1
Some bug fixes for SlimerJS
2 parents
9c546d59
6b64fbf7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
7 deletions
modules/casper.js
modules/clientutils.js
tests/suites/http_status.js
tests/suites/utils.js
modules/casper.js
View file @
ea6b83e
...
...
@@ -934,17 +934,31 @@ Casper.prototype.getPageContent = function getPageContent() {
if
(
!
utils
.
isString
(
contentType
))
{
return
this
.
page
.
frameContent
;
}
// for some reason (qt)webkit will always enclose non text/html body contents within an html
// for some reason (qt)webkit
/Gecko
will always enclose non text/html body contents within an html
// structure like this:
// <html><head></head><body><pre style="(...)">content</pre></body></html>
// webkit: <html><head></head><body><pre style="(...)">content</pre></body></html>
// gecko: <html><head><link rel="alternate stylesheet" type="text/css" href="resource://gre-resources/plaintext.css" title="..."></head><body><pre>document.write('foo');\n</pre></body></html>
var
sanitizedHtml
=
this
.
evaluate
(
function
checkHtml
()
{
var
head
=
__utils__
.
findOne
(
'head'
),
body
=
__utils__
.
findOne
(
'body'
);
if
(
head
&&
head
.
childNodes
.
length
===
0
&&
body
&&
body
.
childNodes
.
length
===
1
&&
if
(
!
head
||
!
body
)
{
return
null
;
}
// for content in Webkit
if
(
head
.
childNodes
.
length
===
0
&&
body
.
childNodes
.
length
===
1
&&
__utils__
.
findOne
(
'body pre[style]'
))
{
return
__utils__
.
findOne
(
'body pre'
).
textContent
.
trim
();
}
// for content in Gecko
if
(
head
.
childNodes
.
length
===
1
&&
body
.
childNodes
.
length
===
1
&&
head
.
childNodes
[
0
].
localName
===
'link'
&&
head
.
childNodes
[
0
].
getAttribute
(
'href'
)
===
'resource://gre-resources/plaintext.css'
&&
body
.
childNodes
[
0
].
localName
===
'pre'
)
{
return
body
.
childNodes
[
0
].
textContent
.
trim
();
}
return
null
;
});
return
sanitizedHtml
?
sanitizedHtml
:
this
.
page
.
frameContent
;
};
...
...
modules/clientutils.js
View file @
ea6b83e
...
...
@@ -653,7 +653,7 @@
var
center_x
=
1
,
center_y
=
1
;
try
{
var
pos
=
elem
.
getBoundingClientRect
();
center_x
=
Math
.
floor
((
pos
.
left
+
pos
.
right
)
/
2
)
,
center_x
=
Math
.
floor
((
pos
.
left
+
pos
.
right
)
/
2
)
;
center_y
=
Math
.
floor
((
pos
.
top
+
pos
.
bottom
)
/
2
);
}
catch
(
e
)
{}
evt
.
initMouseEvent
(
type
,
true
,
true
,
window
,
1
,
1
,
1
,
center_x
,
center_y
,
false
,
false
,
false
,
false
,
0
,
elem
);
...
...
tests/suites/http_status.js
View file @
ea6b83e
...
...
@@ -27,7 +27,9 @@ casper.test.begin("HTTP status code handling", 163, {
this
.
testCodes
.
push
(
118
);
}
if
(
utils
.
ltVersion
(
phantom
.
version
,
'1.9.0'
)
||
isGecko
)
{
if
(
utils
.
ltVersion
(
phantom
.
version
,
'1.9.0'
)
||
utils
.
gteVersion
(
phantom
.
version
,
'1.9.2'
)
||
isGecko
)
{
// https://github.com/ariya/phantomjs/issues/11163
this
.
testCodes
=
this
.
testCodes
.
concat
([
400
,
401
,
402
,
403
,
404
,
405
,
406
,
407
,
409
,
410
,
411
,
412
,
413
,
...
...
tests/suites/utils.js
View file @
ea6b83e
...
...
@@ -29,7 +29,7 @@ casper.test.begin('utils.betterInstanceOf() tests', 13, function(test) {
// need two objects to test inheritance
function
Cow
(){}
var
daisy
=
new
Cow
();
function
SuperCow
(){}
SuperCow
.
prototype
=
new
Cow
();
var
superDaisy
=
new
SuperCow
();
var
date
=
new
Date
();
var
regex
=
new
RegExp
();
var
xmlDoc
=
document
.
implementation
.
createDocument
(
"<y>"
,
"x"
);
var
date
=
new
Date
();
var
regex
=
new
RegExp
();
var
xmlDoc
=
document
.
implementation
.
createDocument
(
"<y>"
,
"x"
,
null
);
var
testCases
=
[
{
subject
:
1
,
fn
:
Number
,
expected
:
true
},
{
subject
:
'1'
,
fn
:
String
,
expected
:
true
},
...
...
Please
register
or
sign in
to post a comment