Commit 161d32ac 161d32ac24e850396d589be9057c32db0f5dae66 by Nicolas Perriault

fixed tests for phantomjs < 1.6

1 parent 9697410d
Subproject commit dd54a24e01c379ad5b34dfb2ec11323a95a7e25f
Subproject commit 8ef6a7b312c799466acf3691de0a59d7f48a4c29
......
......@@ -221,6 +221,9 @@ Casper.prototype.base64encode = function base64encode(url, method, data) {
*/
Casper.prototype.capture = function capture(targetFile, clipRect) {
"use strict";
if (!this.started) {
throw new CasperError("Casper not started, can't capture()");
}
var previousClipRect;
targetFile = fs.absolute(targetFile);
if (clipRect) {
......@@ -258,6 +261,13 @@ Casper.prototype.capture = function capture(targetFile, clipRect) {
*/
Casper.prototype.captureBase64 = function captureBase64(format, area) {
"use strict";
if (!this.started) {
throw new CasperError("Casper not started, can't captureBase64()");
}
if (!('renderBase64' in this.page)) {
this.warn('captureBase64() requires PhantomJS >= 1.6');
return;
}
var base64;
var previousClipRect;
var formats = ['bmp', 'jpg', 'jpeg', 'png', 'ppm', 'tiff', 'xbm', 'xpm'];
......
......@@ -11,15 +11,17 @@ casper.start('tests/site/index.html', function() {
this.test.assert(fs.isFile(testFile), 'Casper.capture() captured a screenshot');
});
casper.thenOpen('tests/site/index.html', function() {
this.test.comment('Casper.captureBase64()');
this.test.assert(this.captureBase64('png').length > 0,
'Casper.captureBase64() rendered a page capture as base64');
this.test.assert(this.captureBase64('png', 'ul').length > 0,
'Casper.captureBase64() rendered a capture from a selector as base64');
this.test.assert(this.captureBase64('png', {top: 0, left: 0, width: 30, height: 30}).length > 0,
'Casper.captureBase64() rendered a capture from a clipRect as base64');
});
if (phantom.version.major === 1 && phantom.version.minor >= 6) {
casper.thenOpen('tests/site/index.html', function() {
this.test.comment('Casper.captureBase64()');
this.test.assert(this.captureBase64('png').length > 0,
'Casper.captureBase64() rendered a page capture as base64');
this.test.assert(this.captureBase64('png', 'ul').length > 0,
'Casper.captureBase64() rendered a capture from a selector as base64');
this.test.assert(this.captureBase64('png', {top: 0, left: 0, width: 30, height: 30}).length > 0,
'Casper.captureBase64() rendered a capture from a clipRect as base64');
});
}
casper.run(function() {
try {
......