Bug 1623226 - Pass exception stack from AutoJSAPI::ReportException. r=baku
authorTom Schuster <evilpies@gmail.com>
Tue, 31 Mar 2020 01:19:31 +0000
changeset 521194 ca98d4d3023d21f156093a214baf5fb925fb9e31
parent 521193 a9783d27bb78e3816693c59ac7b420f72f26013e
child 521195 bb8d410a3bf7565327dd72dcc311a365529a9cd7
push id111552
push userevilpies@gmail.com
push dateTue, 31 Mar 2020 02:07:23 +0000
treeherderautoland@ca98d4d3023d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1623226
milestone76.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1623226 - Pass exception stack from AutoJSAPI::ReportException. r=baku Differential Revision: https://phabricator.services.mozilla.com/D67791
dom/script/ScriptSettings.cpp
dom/tests/mochitest/bugs/test_onerror_message.html
testing/web-platform/tests/html/webappapis/scripting/processing-model-2/window-onerror-runtime-error-throw.html
--- a/dom/script/ScriptSettings.cpp
+++ b/dom/script/ScriptSettings.cpp
@@ -491,17 +491,17 @@ void AutoJSAPI::ReportException() {
     }
   }
   MOZ_ASSERT(JS_IsGlobalObject(errorGlobal));
   JSAutoRealm ar(cx(), errorGlobal);
   JS::Rooted<JS::Value> exn(cx());
   JS::Rooted<JSObject*> exnStack(cx());
   js::ErrorReport jsReport(cx());
   if (StealExceptionAndStack(&exn, &exnStack) &&
-      jsReport.init(cx(), exn, js::ErrorReport::WithSideEffects)) {
+      jsReport.init(cx(), exn, js::ErrorReport::WithSideEffects, exnStack)) {
     if (mIsMainThread) {
       RefPtr<xpc::ErrorReport> xpcReport = new xpc::ErrorReport();
 
       RefPtr<nsGlobalWindowInner> inner = xpc::WindowOrNull(errorGlobal);
       bool isChrome =
           nsContentUtils::ObjectPrincipal(errorGlobal)->IsSystemPrincipal();
       xpcReport->Init(jsReport.report(), jsReport.toStringResult().c_str(),
                       isChrome, inner ? inner->WindowID() : 0);
--- a/dom/tests/mochitest/bugs/test_onerror_message.html
+++ b/dom/tests/mochitest/bugs/test_onerror_message.html
@@ -19,21 +19,21 @@ https://bugzilla.mozilla.org/show_bug.cg
 <script type="application/javascript">
 "use strict";
 
 /** Test for Bug 743049 **/
 
 var expected = [
 { name: "Error", message: "foo", filename: String(location), lineNumber: 45 },
 { name: "Error", message: "foo", filename: "bar", lineNumber: 123 },
-{ name: "", message: "uncaught exception: [object Object]" },
+{ name: "", message: "uncaught exception: [object Object]", filename: location.href, lineNumber: 80 },
 { name: "DuckError", message: "foo", filename: "bar", lineNumber: 123 },
-{ name: "", message: "uncaught exception: [object Object]" },
+{ name: "", message: "uncaught exception: [object Object]", filename: location.href, lineNumber: 80 },
 { name: "", message: "foo", filename: "baz", lineNumber: 123 },
-{ name: "", message: "uncaught exception: [object Object]" },
+{ name: "", message: "uncaught exception: [object Object]", filename: location.href, lineNumber: 80 },
 { name: "InvalidStateError", message: "Cannot set 'responseType' property on XMLHttpRequest after 'send()' (when its state is LOADING or DONE).", filename: String(location), lineNumber: 62 },
 { name: "ReferenceError", message: "xxx is not defined", filename: String(location), lineNumber: 64 },
 { name: "ReferenceError", message: "xxx is not defined", filename: String(location), lineNumber: 66 }
 ];
 
 var counter = 0;
 var origin = location.protocol + "//" + location.host;
 postMessage(counter, origin);
@@ -71,27 +71,25 @@ window.onmessage = function(e) {
 	} catch (e) {
 		if (e instanceof Error || typeof e.message=="string" &&
 			("filename" in e || "fileName" in e) && "lineNumber" in e) {
 			is(e.message, expected[counter].message, counter + " catch message");
 			is(e.filename || e.fileName, expected[counter].filename, counter + " catch filename");
 			is(e.lineNumber, expected[counter].lineNumber, counter + " catch lineno");
 		} else {
 			is("uncaught exception: " + e, expected[counter].message, counter + " catch message");
-			is(undefined, expected[counter].filename, counter + " catch filename");
-			is(undefined, expected[counter].lineNumber, counter + " catch lineno");
 		}
 		throw e;
 	}
 	ok(false, counter + " Error should be thrown or test should finish");
 };
 window.onerror = function(message, filename, lineno) {
 	is(message, Error.prototype.toString.call(expected[counter]), counter + " onerror message");
-	is(filename, expected[counter].filename || "", counter + " onerror filename");
-	is(lineno, expected[counter].lineNumber || 0, counter + " onerror lineno");
+	is(filename, expected[counter].filename, counter + " onerror filename");
+	is(lineno, expected[counter].lineNumber, counter + " onerror lineno");
 	postMessage(++counter, origin);
 	return true;
 };
 
 SimpleTest.waitForExplicitFinish();
 
 </script>
 </pre>
--- a/testing/web-platform/tests/html/webappapis/scripting/processing-model-2/window-onerror-runtime-error-throw.html
+++ b/testing/web-platform/tests/html/webappapis/scripting/processing-model-2/window-onerror-runtime-error-throw.html
@@ -15,16 +15,20 @@
  <body>
 
   <div id="log"></div>
   <script>
     setup({allow_uncaught_exception:true});
     var error_count = 0;
     window.onerror = function(msg, url, lineno) {
       ++error_count;
+      test(function() {assert_equals(url, window.location.href)},
+           "correct url passed to window.onerror");
+      test(function() {assert_equals(lineno, 36)},
+           "correct line number passed to window.onerror");
     };
   </script>
   <script>
   try {
     // This error is caught, so it should NOT trigger onerror.
     throw "foo";
   } catch (ex) {
   }