Bug 1256364. If we have an exception stack in the onerror handler in SimpleTest, include it in the error message. r=jmaher
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 14 Mar 2016 20:48:21 -0400
changeset 288677 dca912a377eac9a3f2a149a9edb08c84631acea4
parent 288676 007066bf36c62944e2ace4b1ec4e6346a325c3b8
child 288678 21e5497ebb7269dde3315ec97d28243fe09f72de
push id18174
push usercbook@mozilla.com
push dateTue, 15 Mar 2016 09:44:58 +0000
treeherderfx-team@dd0baa33759d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs1256364
milestone48.0a1
Bug 1256364. If we have an exception stack in the onerror handler in SimpleTest, include it in the error message. r=jmaher
testing/mochitest/tests/SimpleTest/SimpleTest.js
--- a/testing/mochitest/tests/SimpleTest/SimpleTest.js
+++ b/testing/mochitest/tests/SimpleTest/SimpleTest.js
@@ -1521,26 +1521,33 @@ var isfuzzy = SimpleTest.isfuzzy;
 var isnot = SimpleTest.isnot;
 var todo = SimpleTest.todo;
 var todo_is = SimpleTest.todo_is;
 var todo_isnot = SimpleTest.todo_isnot;
 var isDeeply = SimpleTest.isDeeply;
 var info = SimpleTest.info;
 
 var gOldOnError = window.onerror;
-window.onerror = function simpletestOnerror(errorMsg, url, lineNumber) {
+window.onerror = function simpletestOnerror(errorMsg, url, lineNumber,
+                                            columnNumber, originalException) {
     // Log the message.
     // XXX Chrome mochitests sometimes trigger this window.onerror handler,
     // but there are a number of uncaught JS exceptions from those tests.
     // For now, for tests that self identify as having unintentional uncaught
     // exceptions, just dump it so that the error is visible but doesn't cause
     // a test failure.  See bug 652494.
     var isExpected = !!SimpleTest._expectingUncaughtException;
     var message = (isExpected ? "expected " : "") + "uncaught exception";
-    var error = errorMsg + " at " + url + ":" + lineNumber;
+    var error = errorMsg + " at ";
+    try {
+        error += originalException.stack;
+    } catch (e) {
+        // At least use the url+line+column we were given
+        error += url + ":" + lineNumber + ":" + columnNumber;
+    }
     if (!SimpleTest._ignoringAllUncaughtExceptions) {
         // Don't log if SimpleTest.finish() is already called, it would cause failures
         if (!SimpleTest._alreadyFinished)
           SimpleTest.ok(isExpected, message, error);
         SimpleTest._expectingUncaughtException = false;
     } else {
         SimpleTest.todo(false, message + ": " + error);
     }