Permalink
Browse files

update the phantomjs script to avoid problems when phantom console ca…

…llback doesn't send all the expected arguments
  • Loading branch information...
1 parent fa8ba26 commit 650e120a0b12d7ef0c0c20d148b56bf9447d63b9 Tiago Rodrigues committed Jul 19, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 script/phantom.js
View
@@ -17,10 +17,14 @@ page.open(captureUrl, function(status) {
}
page.onConsoleMessage = function (msg, line, id) {
- var fileName = id.split('/');
+ var composedMsg = '';
+ var fileName = id ? id.split('/') : null;
// format the output message with filename, line number and message
// weird gotcha: phantom only uses the first console.log argument it gets :(
- console.log(fileName[fileName.length-1]+', '+ line +': '+ msg);
+ composedMsg = fileName ? fileName[fileName.length-1]+', ' : '';
+ composedMsg = line ? line +': ' : '';
+ composedMsg = msg;
+ console.log(composedMsg);
};
page.onAlert = function(msg) {

0 comments on commit 650e120

Please sign in to comment.