Commit db31a63b db31a63b2a99000772d3534d57ecac538c2a04e9 by Laurent Jouanneau

Fixes reference errors in testers.js

stackArray is not a standard property of the Error object. It is
added by PhantomJS (modification in the sources of QTWebkit).
We should use the stack property if stackArray is not present
(like in SlimerJS)
1 parent 831e82f8
...@@ -1029,7 +1029,7 @@ Tester.prototype.done = function done() { ...@@ -1029,7 +1029,7 @@ Tester.prototype.done = function done() {
1029 /*jshint maxstatements:20, maxcomplexity:20*/ 1029 /*jshint maxstatements:20, maxcomplexity:20*/
1030 var planned, config = this.currentSuite && this.currentSuite.config || {}; 1030 var planned, config = this.currentSuite && this.currentSuite.config || {};
1031 1031
1032 if (utils.isNumber(arguments[0])) { 1032 if (arguments.length && utils.isNumber(arguments[0])) {
1033 this.casper.warn('done() `planned` arg is deprecated as of 1.1'); 1033 this.casper.warn('done() `planned` arg is deprecated as of 1.1');
1034 planned = arguments[0]; 1034 planned = arguments[0];
1035 } 1035 }
...@@ -1230,9 +1230,27 @@ Tester.prototype.processAssertionError = function(error) { ...@@ -1230,9 +1230,27 @@ Tester.prototype.processAssertionError = function(error) {
1230 testFile = this.currentTestFile, 1230 testFile = this.currentTestFile,
1231 stackEntry; 1231 stackEntry;
1232 try { 1232 try {
1233 stackEntry = error.stackArray.filter(function(entry) { 1233 if ("stackArray" in error) {
1234 return testFile === entry.sourceURL; 1234 // PhantomJS has changed the API of the Error object :-/
1235 })[0]; 1235 // https://github.com/ariya/phantomjs/commit/c9cf14f221f58a3daf585c47313da6fced0276bc
1236 stackEntry = error.stackArray.filter(function(entry) {
1237 return testFile === entry.sourceURL;
1238 })[0];
1239 }
1240 else if ('stack' in error) {
1241 var r = /^\s*(.*)@(.*):(\d+)\s*$/gm;
1242 var m;
1243 while ((m = r.exec(e.stack))) {
1244 var sourceURL = m[2];
1245 if (sourceURL.indexOf('->') != -1) {
1246 sourceURL = sourceURL.split('->')[1].trim();
1247 }
1248 if (sourceURL == testFile) {
1249 stackEntry = { sourceURL: sourceURL, line: m[3]}
1250 break;
1251 }
1252 }
1253 }
1236 } catch (e) {} 1254 } catch (e) {}
1237 if (stackEntry) { 1255 if (stackEntry) {
1238 result.line = stackEntry.line; 1256 result.line = stackEntry.line;
......