Commit ea6b83e3 ea6b83e3d08dab0c7f479b2321bc9b98af46aed8 by Nicolas Perriault

Merge pull request #708 from laurentj/geckofix1

Some bug fixes for SlimerJS
2 parents 9c546d59 6b64fbf7
......@@ -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;
};
......
......@@ -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);
......
......@@ -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,
......
......@@ -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},
......