fixed tests for phantomjs < 1.6
Showing
3 changed files
with
15 additions
and
3 deletions
... | @@ -221,6 +221,9 @@ Casper.prototype.base64encode = function base64encode(url, method, data) { | ... | @@ -221,6 +221,9 @@ Casper.prototype.base64encode = function base64encode(url, method, data) { |
221 | */ | 221 | */ |
222 | Casper.prototype.capture = function capture(targetFile, clipRect) { | 222 | Casper.prototype.capture = function capture(targetFile, clipRect) { |
223 | "use strict"; | 223 | "use strict"; |
224 | if (!this.started) { | ||
225 | throw new CasperError("Casper not started, can't capture()"); | ||
226 | } | ||
224 | var previousClipRect; | 227 | var previousClipRect; |
225 | targetFile = fs.absolute(targetFile); | 228 | targetFile = fs.absolute(targetFile); |
226 | if (clipRect) { | 229 | if (clipRect) { |
... | @@ -258,6 +261,13 @@ Casper.prototype.capture = function capture(targetFile, clipRect) { | ... | @@ -258,6 +261,13 @@ Casper.prototype.capture = function capture(targetFile, clipRect) { |
258 | */ | 261 | */ |
259 | Casper.prototype.captureBase64 = function captureBase64(format, area) { | 262 | Casper.prototype.captureBase64 = function captureBase64(format, area) { |
260 | "use strict"; | 263 | "use strict"; |
264 | if (!this.started) { | ||
265 | throw new CasperError("Casper not started, can't captureBase64()"); | ||
266 | } | ||
267 | if (!('renderBase64' in this.page)) { | ||
268 | this.warn('captureBase64() requires PhantomJS >= 1.6'); | ||
269 | return; | ||
270 | } | ||
261 | var base64; | 271 | var base64; |
262 | var previousClipRect; | 272 | var previousClipRect; |
263 | var formats = ['bmp', 'jpg', 'jpeg', 'png', 'ppm', 'tiff', 'xbm', 'xpm']; | 273 | var formats = ['bmp', 'jpg', 'jpeg', 'png', 'ppm', 'tiff', 'xbm', 'xpm']; | ... | ... |
... | @@ -11,7 +11,8 @@ casper.start('tests/site/index.html', function() { | ... | @@ -11,7 +11,8 @@ casper.start('tests/site/index.html', function() { |
11 | this.test.assert(fs.isFile(testFile), 'Casper.capture() captured a screenshot'); | 11 | this.test.assert(fs.isFile(testFile), 'Casper.capture() captured a screenshot'); |
12 | }); | 12 | }); |
13 | 13 | ||
14 | casper.thenOpen('tests/site/index.html', function() { | 14 | if (phantom.version.major === 1 && phantom.version.minor >= 6) { |
15 | casper.thenOpen('tests/site/index.html', function() { | ||
15 | this.test.comment('Casper.captureBase64()'); | 16 | this.test.comment('Casper.captureBase64()'); |
16 | this.test.assert(this.captureBase64('png').length > 0, | 17 | this.test.assert(this.captureBase64('png').length > 0, |
17 | 'Casper.captureBase64() rendered a page capture as base64'); | 18 | 'Casper.captureBase64() rendered a page capture as base64'); |
... | @@ -19,7 +20,8 @@ casper.thenOpen('tests/site/index.html', function() { | ... | @@ -19,7 +20,8 @@ casper.thenOpen('tests/site/index.html', function() { |
19 | 'Casper.captureBase64() rendered a capture from a selector as base64'); | 20 | 'Casper.captureBase64() rendered a capture from a selector as base64'); |
20 | this.test.assert(this.captureBase64('png', {top: 0, left: 0, width: 30, height: 30}).length > 0, | 21 | this.test.assert(this.captureBase64('png', {top: 0, left: 0, width: 30, height: 30}).length > 0, |
21 | 'Casper.captureBase64() rendered a capture from a clipRect as base64'); | 22 | 'Casper.captureBase64() rendered a capture from a clipRect as base64'); |
22 | }); | 23 | }); |
24 | } | ||
23 | 25 | ||
24 | casper.run(function() { | 26 | casper.run(function() { |
25 | try { | 27 | try { | ... | ... |
-
Please register or sign in to post a comment