Bug 1623226 - Pass exception stack from AutoJSAPI::ReportException. r=baku
☠☠ backed out by ce00073cc7e3 ☠ ☠
authorTom Schuster <evilpies@gmail.com>
Mon, 30 Mar 2020 22:45:14 +0000
changeset 521176 312da02ea6d6aef4ae98390fd2939543c3cd6b64
parent 521175 798079ba88f77fba158c3a6e0c341240ff9e225c
child 521177 1e21eefd5fceeeeee07a1bf19ca4f5cc059d8aeb
push id111538
push userevilpies@gmail.com
push dateMon, 30 Mar 2020 22:46:36 +0000
treeherderautoland@312da02ea6d6 [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) {
   }