Bug 1274922 part 3 - Fix CompileError::throwError to not call the error reporter if autoJSAPIOwnsErrorReporting. r=jorendorff
authorJan de Mooij <jdemooij@mozilla.com>
Tue, 31 May 2016 08:07:00 +0200
changeset 338638 72383ac6936ff4b73b902fb64b291633727f9bad
parent 338637 524bf899365de17f58e19e911a6c13967015d08f
child 338639 502b474b0d6b3e705ae65b017d13063ad171e2c0
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1274922
milestone49.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 1274922 part 3 - Fix CompileError::throwError to not call the error reporter if autoJSAPIOwnsErrorReporting. r=jorendorff
js/src/frontend/TokenStream.cpp
--- a/js/src/frontend/TokenStream.cpp
+++ b/js/src/frontend/TokenStream.cpp
@@ -573,18 +573,26 @@ CompileError::throwError(JSContext* cx)
     //
     // If an exception is thrown but not caught, the JSREPORT_EXCEPTION
     // flag will be set in report.flags.  Proper behavior for an error
     // reporter is to ignore a report with this flag for all but top-level
     // compilation errors.  The exception will remain pending, and so long
     // as the non-top-level "load", "eval", or "compile" native function
     // returns false, the top-level reporter will eventually receive the
     // uncaught exception report.
-    if (!ErrorToException(cx, message, &report, nullptr, nullptr))
-        CallErrorReporter(cx, message, &report);
+    if (ErrorToException(cx, message, &report, nullptr, nullptr))
+        return;
+
+    // Like ReportError, don't call the error reporter if the embedding is
+    // responsible for handling exceptions. In this case the error reporter
+    // must only be used for warnings.
+    if (cx->options().autoJSAPIOwnsErrorReporting() && !JSREPORT_IS_WARNING(report.flags))
+        return;
+
+    CallErrorReporter(cx, message, &report);
 }
 
 CompileError::~CompileError()
 {
     js_free((void*)report.linebuf());
     js_free((void*)report.ucmessage);
     js_free(message);
     message = nullptr;