added moar events
Showing
1 changed file
with
10 additions
and
5 deletions
... | @@ -166,10 +166,12 @@ Casper.prototype.capture = function(targetFile, clipRect) { | ... | @@ -166,10 +166,12 @@ Casper.prototype.capture = function(targetFile, clipRect) { |
166 | this.page.clipRect = clipRect; | 166 | this.page.clipRect = clipRect; |
167 | this.log(f("Capturing page to %s with clipRect %s", targetFile, JSON.stringify(clipRect)), "debug"); | 167 | this.log(f("Capturing page to %s with clipRect %s", targetFile, JSON.stringify(clipRect)), "debug"); |
168 | } else { | 168 | } else { |
169 | this.log(f('Capturing page to %s', targetFile), "debug"); | 169 | this.log(f("Capturing page to %s", targetFile), "debug"); |
170 | } | 170 | } |
171 | if (!this.page.render(targetFile)) { | 171 | if (!this.page.render(this.filter('capture.target_filename', targetFile) || targetFile)) { |
172 | this.log(f("Failed to save screenshot to %s; please check permissions", targetFile), "error"); | 172 | this.log(f("Failed to save screenshot to %s; please check permissions", targetFile), "error"); |
173 | } else { | ||
174 | this.emit('capture.saved', targetFile); | ||
173 | } | 175 | } |
174 | if (previousClipRect) { | 176 | if (previousClipRect) { |
175 | this.page.clipRect = previousClipRect; | 177 | this.page.clipRect = previousClipRect; |
... | @@ -310,6 +312,7 @@ Casper.prototype.download = function(url, targetPath) { | ... | @@ -310,6 +312,7 @@ Casper.prototype.download = function(url, targetPath) { |
310 | var cu = require('clientutils').create(); | 312 | var cu = require('clientutils').create(); |
311 | try { | 313 | try { |
312 | fs.write(targetPath, cu.decode(this.base64encode(url)), 'w'); | 314 | fs.write(targetPath, cu.decode(this.base64encode(url)), 'w'); |
315 | this.emit('downloaded.file', targetPath); | ||
313 | } catch (e) { | 316 | } catch (e) { |
314 | this.log(f("Error while downloading %s to %s: %s", url, targetPath, e), "error"); | 317 | this.log(f("Error while downloading %s to %s: %s", url, targetPath, e), "error"); |
315 | } | 318 | } |
... | @@ -344,7 +347,8 @@ Casper.prototype.each = function(array, fn) { | ... | @@ -344,7 +347,8 @@ Casper.prototype.each = function(array, fn) { |
344 | * @return Casper | 347 | * @return Casper |
345 | */ | 348 | */ |
346 | Casper.prototype.echo = function(text, style) { | 349 | Casper.prototype.echo = function(text, style) { |
347 | console.log(style ? this.colorizer.colorize(text, style) : text); | 350 | var message = style ? this.colorizer.colorize(text, style) : text; |
351 | console.log(this.filter('echo.message', message) || message); | ||
348 | return this; | 352 | return this; |
349 | }; | 353 | }; |
350 | 354 | ||
... | @@ -781,6 +785,7 @@ Casper.prototype.setHttpAuth = function(username, password) { | ... | @@ -781,6 +785,7 @@ Casper.prototype.setHttpAuth = function(username, password) { |
781 | } | 785 | } |
782 | this.page.settings.userName = username; | 786 | this.page.settings.userName = username; |
783 | this.page.settings.password = password; | 787 | this.page.settings.password = password; |
788 | this.emit('http.auth', username, password); | ||
784 | this.log("Setting HTTP authentication for user " + username, "info"); | 789 | this.log("Setting HTTP authentication for user " + username, "info"); |
785 | return this; | 790 | return this; |
786 | }; | 791 | }; |
... | @@ -976,8 +981,8 @@ Casper.prototype.viewport = function(width, height) { | ... | @@ -976,8 +981,8 @@ Casper.prototype.viewport = function(width, height) { |
976 | * @return Casper | 981 | * @return Casper |
977 | */ | 982 | */ |
978 | Casper.prototype.wait = function(timeout, then) { | 983 | Casper.prototype.wait = function(timeout, then) { |
979 | timeout = Number(timeout, 10); | 984 | timeout = ~~timeout; |
980 | if (!utils.isNumber(timeout) || timeout < 1) { | 985 | if (timeout < 1) { |
981 | this.die("wait() only accepts a positive integer > 0 as a timeout value"); | 986 | this.die("wait() only accepts a positive integer > 0 as a timeout value"); |
982 | } | 987 | } |
983 | if (then && !utils.isFunction(then)) { | 988 | if (then && !utils.isFunction(then)) { | ... | ... |
-
Please register or sign in to post a comment