Bug 1277278 part 3 - Rename error reporter callback to warning reporter, assert it's only used for warnings. r=luke
authorJan de Mooij <jdemooij@mozilla.com>
Tue, 07 Jun 2016 20:30:48 +0200
changeset 300910 3b42129e45a9bdfbefeb35a2ea26d60d757c7e1f
parent 300909 3e9f480972b441c53802cace2cacbfb7510c53c6
child 300911 b605a7bb8c498569ed597ed66202a93d01fcfaad
push id78133
push userjandemooij@gmail.com
push dateTue, 07 Jun 2016 18:37:10 +0000
treeherdermozilla-inbound@bd2089fe075e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1277278
milestone50.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 1277278 part 3 - Rename error reporter callback to warning reporter, assert it's only used for warnings. r=luke
dom/base/ScriptSettings.cpp
dom/base/ScriptSettings.h
ipc/testshell/XPCShellEnvironment.cpp
js/src/frontend/TokenStream.cpp
js/src/gdb/gdb-tests.cpp
js/src/jsapi-tests/tests.h
js/src/jsapi.cpp
js/src/jsapi.h
js/src/jscntxt.cpp
js/src/jscntxt.h
js/src/jsexn.cpp
js/src/shell/js.cpp
js/src/vm/Debugger.cpp
js/src/vm/Runtime.cpp
js/src/vm/Runtime.h
js/src/vm/SelfHosting.cpp
netwerk/base/ProxyAutoConfig.cpp
xpcom/base/CycleCollectedJSRuntime.cpp
--- a/dom/base/ScriptSettings.cpp
+++ b/dom/base/ScriptSettings.cpp
@@ -306,18 +306,18 @@ AutoJSAPI::~AutoJSAPI()
     // No need to do anything here: we never managed to Init, so can't have an
     // exception on our (nonexistent) JSContext.  We also don't need to restore
     // any state on it.
     return;
   }
 
   ReportException();
 
-  if (mOldErrorReporter.isSome()) {
-    JS_SetErrorReporter(JS_GetRuntime(cx()), mOldErrorReporter.value());
+  if (mOldWarningReporter.isSome()) {
+    JS::SetWarningReporter(JS_GetRuntime(cx()), mOldWarningReporter.value());
   }
 }
 
 void
 WarningOnlyErrorReporter(JSContext* aCx, const char* aMessage,
                          JSErrorReport* aRep);
 
 void
@@ -343,19 +343,19 @@ AutoJSAPI::InitInternal(nsIGlobalObject*
     JS::Rooted<JSObject*> global(JS_GetRuntime(aCx), aGlobal);
     mCxPusher.emplace(mCx);
     mAutoNullableCompartment.emplace(mCx, global);
   } else {
     mAutoNullableCompartment.emplace(mCx, aGlobal);
   }
 
   JSRuntime* rt = JS_GetRuntime(aCx);
-  mOldErrorReporter.emplace(JS_GetErrorReporter(rt));
+  mOldWarningReporter.emplace(JS::GetWarningReporter(rt));
 
-  JS_SetErrorReporter(rt, WarningOnlyErrorReporter);
+  JS::SetWarningReporter(rt, WarningOnlyErrorReporter);
 
 #ifdef DEBUG
   if (haveException) {
     JS::Rooted<JS::Value> exn(aCx);
     JS_GetPendingException(aCx, &exn);
 
     JS_ClearPendingException(aCx);
     if (exn.isObject()) {
--- a/dom/base/ScriptSettings.h
+++ b/dom/base/ScriptSettings.h
@@ -308,17 +308,17 @@ private:
   // we could construct this at that point.  It might be worth it do to that.
   RefPtr<nsIGlobalObject> mGlobalObject;
   mozilla::Maybe<danger::AutoCxPusher> mCxPusher;
   mozilla::Maybe<JSAutoNullableCompartment> mAutoNullableCompartment;
   JSContext *mCx;
 
   // Whether we're mainthread or not; set when we're initialized.
   bool mIsMainThread;
-  Maybe<JSErrorReporter> mOldErrorReporter;
+  Maybe<JS::WarningReporter> mOldWarningReporter;
 
   void InitInternal(nsIGlobalObject* aGlobalObject, JSObject* aGlobal,
                     JSContext* aCx, bool aIsMainThread);
 
   AutoJSAPI(const AutoJSAPI&) = delete;
   AutoJSAPI& operator= (const AutoJSAPI&) = delete;
 };
 
--- a/ipc/testshell/XPCShellEnvironment.cpp
+++ b/ipc/testshell/XPCShellEnvironment.cpp
@@ -364,27 +364,27 @@ XPCShellEnvironment::ProcessFile(JSConte
         } while (!JS_BufferIsCompilableUnit(cx, global, buffer, strlen(buffer)));
 
         /* Clear any pending exception from previous failed compiles.  */
         JS_ClearPendingException(cx);
         JS::CompileOptions options(cx);
         options.setFileAndLine("typein", startline);
         JS::Rooted<JSScript*> script(cx);
         if (JS_CompileScript(cx, buffer, strlen(buffer), options, &script)) {
-            JSErrorReporter older;
+            JS::WarningReporter older;
 
             ok = JS_ExecuteScript(cx, script, &result);
             if (ok && !result.isUndefined()) {
-                /* Suppress error reports from JS::ToString(). */
-                older = JS_SetErrorReporter(JS_GetRuntime(cx), nullptr);
+                /* Suppress warnings from JS::ToString(). */
+                older = JS::SetWarningReporter(JS_GetRuntime(cx), nullptr);
                 str = JS::ToString(cx, result);
                 JSAutoByteString bytes;
                 if (str)
                     bytes.encodeLatin1(cx, str);
-                JS_SetErrorReporter(JS_GetRuntime(cx), older);
+                JS::SetWarningReporter(JS_GetRuntime(cx), older);
 
                 if (!!bytes)
                     fprintf(stdout, "%s\n", bytes.ptr());
                 else
                     ok = false;
             }
         }
     } while (!hitEOF && !env->IsQuitting());
@@ -592,22 +592,22 @@ XPCShellEnvironment::EvaluateString(cons
 
   if (aResult) {
       aResult->Truncate();
   }
 
   JS::Rooted<JS::Value> result(cx);
   bool ok = JS_ExecuteScript(cx, script, &result);
   if (ok && !result.isUndefined()) {
-      JSErrorReporter old = JS_SetErrorReporter(JS_GetRuntime(cx), nullptr);
+      JS::WarningReporter old = JS::SetWarningReporter(JS_GetRuntime(cx), nullptr);
       JSString* str = JS::ToString(cx, result);
       nsAutoJSString autoStr;
       if (str)
           autoStr.init(cx, str);
-      JS_SetErrorReporter(JS_GetRuntime(cx), old);
+      JS::SetWarningReporter(JS_GetRuntime(cx), old);
 
       if (!autoStr.IsEmpty() && aResult) {
           aResult->Assign(autoStr);
       }
   }
 
   return true;
 }
--- a/js/src/frontend/TokenStream.cpp
+++ b/js/src/frontend/TokenStream.cpp
@@ -576,23 +576,18 @@ CompileError::throwError(JSContext* cx)
     // 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))
         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 (!JSREPORT_IS_WARNING(report.flags))
-        return;
-
-    CallErrorReporter(cx, message, &report);
+    if (JSREPORT_IS_WARNING(report.flags))
+        CallWarningReporter(cx, message, &report);
 }
 
 CompileError::~CompileError()
 {
     js_free((void*)report.linebuf());
     js_free((void*)report.ucmessage);
     js_free(message);
     message = nullptr;
--- a/js/src/gdb/gdb-tests.cpp
+++ b/js/src/gdb/gdb-tests.cpp
@@ -37,18 +37,18 @@ checkPtr(T* ptr)
 
 static void
 checkBool(bool success)
 {
   if (! success)
     abort();
 }
 
-/* The error reporter callback. */
-void reportError(JSContext* cx, const char* message, JSErrorReport* report)
+/* The warning reporter callback. */
+void reportWarning(JSContext* cx, const char* message, JSErrorReport* report)
 {
     fprintf(stderr, "%s:%u: %s\n",
             report->filename ? report->filename : "<no filename>",
             (unsigned int) report->lineno,
             message);
 }
 
 // prologue.py sets a breakpoint on this function; test functions can call it
@@ -67,17 +67,17 @@ int
 main(int argc, const char** argv)
 {
     if (!JS_Init()) return 1;
     JSRuntime* runtime = checkPtr(JS_NewRuntime(1024 * 1024));
     JS_SetGCParameter(runtime, JSGC_MAX_BYTES, 0xffffffff);
     JS_SetNativeStackQuota(runtime, 5000000);
 
     JSContext* cx = checkPtr(JS_NewContext(runtime, 8192));
-    JS_SetErrorReporter(runtime, reportError);
+    JS::SetWarningReporter(runtime, reportWarning);
 
     JSAutoRequest ar(cx);
 
     /* Create the global object. */
     JS::CompartmentOptions options;
     options.behaviors().setVersion(JSVERSION_LATEST);
 
     RootedObject global(cx, checkPtr(JS_NewGlobalObject(cx, &global_class,
--- a/js/src/jsapi-tests/tests.h
+++ b/js/src/jsapi-tests/tests.h
@@ -284,17 +284,17 @@ class JSAPITest
 
         JS_SetNativeStackQuota(rt, MAX_STACK_SIZE);
     }
 
     virtual JSRuntime * createRuntime() {
         JSRuntime* rt = JS_NewRuntime(8L * 1024 * 1024);
         if (!rt)
             return nullptr;
-        JS_SetErrorReporter(rt, &reportWarning);
+        JS::SetWarningReporter(rt, &reportWarning);
         setNativeStackQuota(rt);
         return rt;
     }
 
     virtual void destroyRuntime() {
         MOZ_RELEASE_ASSERT(!cx);
         MOZ_RELEASE_ASSERT(rt);
         JS_DestroyRuntime(rt);
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -4176,27 +4176,27 @@ JS_BufferIsCompilableUnit(JSContext* cx,
     // Return true on any out-of-memory error or non-EOF-related syntax error, so our
     // caller doesn't try to collect more buffered source.
     bool result = true;
 
     CompileOptions options(cx);
     Parser<frontend::FullParseHandler> parser(cx, &cx->tempLifoAlloc(),
                                               options, chars, length,
                                               /* foldConstants = */ true, nullptr, nullptr);
-    JSErrorReporter older = JS_SetErrorReporter(cx->runtime(), nullptr);
+    JS::WarningReporter older = JS::SetWarningReporter(cx->runtime(), nullptr);
     if (!parser.checkOptions() || !parser.parse()) {
         // We ran into an error. If it was because we ran out of source, we
         // return false so our caller knows to try to collect more buffered
         // source.
         if (parser.isUnexpectedEOF())
             result = false;
 
         cx->clearPendingException();
     }
-    JS_SetErrorReporter(cx->runtime(), older);
+    JS::SetWarningReporter(cx->runtime(), older);
 
     js_free(chars);
     return result;
 }
 
 JS_PUBLIC_API(JSObject*)
 JS_GetGlobalFromScript(JSScript* script)
 {
@@ -5680,29 +5680,27 @@ JS_ReportOutOfMemory(JSContext* cx)
 }
 
 JS_PUBLIC_API(void)
 JS_ReportAllocationOverflow(JSContext* cx)
 {
     ReportAllocationOverflow(cx);
 }
 
-JS_PUBLIC_API(JSErrorReporter)
-JS_GetErrorReporter(JSRuntime* rt)
-{
-    return rt->errorReporter;
-}
-
-JS_PUBLIC_API(JSErrorReporter)
-JS_SetErrorReporter(JSRuntime* rt, JSErrorReporter er)
-{
-    JSErrorReporter older;
-
-    older = rt->errorReporter;
-    rt->errorReporter = er;
+JS_PUBLIC_API(JS::WarningReporter)
+JS::GetWarningReporter(JSRuntime* rt)
+{
+    return rt->warningReporter;
+}
+
+JS_PUBLIC_API(JS::WarningReporter)
+JS::SetWarningReporter(JSRuntime* rt, JS::WarningReporter reporter)
+{
+    WarningReporter older = rt->warningReporter;
+    rt->warningReporter = reporter;
     return older;
 }
 
 /************************************************************************/
 
 /*
  * Dates.
  */
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -614,19 +614,16 @@ enum class PromiseRejectionHandlingState
 
 typedef void
 (* JSPromiseRejectionTrackerCallback)(JSContext* cx, JS::HandleObject promise,
                                       PromiseRejectionHandlingState state, void* data);
 
 typedef void
 (* JSProcessPromiseCallback)(JSContext* cx, JS::HandleObject promise);
 
-typedef void
-(* JSErrorReporter)(JSContext* cx, const char* message, JSErrorReport* report);
-
 /**
  * Possible exception types. These types are part of a JSErrorFormatString
  * structure. They define which error to throw in case of a runtime error.
  *
  * JSEXN_WARN is used for warnings in js.msg files (for instance because we
  * don't want to prepend 'Error:' to warning messages). This value can go away
  * if we ever decide to use an entirely separate mechanism for warnings.
  */
@@ -5090,18 +5087,17 @@ JS_GetLocaleCallbacks(JSRuntime* rt);
  */
 
 namespace JS {
 const uint16_t MaxNumErrorArguments = 10;
 };
 
 /**
  * Report an exception represented by the sprintf-like conversion of format
- * and its arguments.  This exception message string is passed to a pre-set
- * JSErrorReporter function (set by JS_SetErrorReporter).
+ * and its arguments.
  */
 extern JS_PUBLIC_API(void)
 JS_ReportError(JSContext* cx, const char* format, ...);
 
 /*
  * Use an errorNumber to retrieve the format string, args are char*
  */
 extern JS_PUBLIC_API(void)
@@ -5222,24 +5218,27 @@ class JSErrorReport
  * JS_ExecuteScript returns failure, and signal or propagate the exception, as
  * appropriate.
  */
 #define JSREPORT_IS_WARNING(flags)      (((flags) & JSREPORT_WARNING) != 0)
 #define JSREPORT_IS_EXCEPTION(flags)    (((flags) & JSREPORT_EXCEPTION) != 0)
 #define JSREPORT_IS_STRICT(flags)       (((flags) & JSREPORT_STRICT) != 0)
 #define JSREPORT_IS_STRICT_MODE_ERROR(flags) (((flags) &                      \
                                               JSREPORT_STRICT_MODE_ERROR) != 0)
-extern JS_PUBLIC_API(JSErrorReporter)
-JS_GetErrorReporter(JSRuntime* rt);
-
-extern JS_PUBLIC_API(JSErrorReporter)
-JS_SetErrorReporter(JSRuntime* rt, JSErrorReporter er);
-
 namespace JS {
 
+typedef void
+(* WarningReporter)(JSContext* cx, const char* message, JSErrorReport* report);
+
+extern JS_PUBLIC_API(WarningReporter)
+SetWarningReporter(JSRuntime* rt, WarningReporter reporter);
+
+extern JS_PUBLIC_API(WarningReporter)
+GetWarningReporter(JSRuntime* rt);
+
 extern JS_PUBLIC_API(bool)
 CreateError(JSContext* cx, JSExnType type, HandleObject stack,
             HandleString fileName, uint32_t lineNumber, uint32_t columnNumber,
             JSErrorReport* report, HandleString message, MutableHandleValue rval);
 
 /************************************************************************/
 
 /*
--- a/js/src/jscntxt.cpp
+++ b/js/src/jscntxt.cpp
@@ -223,28 +223,18 @@ ReportError(JSContext* cx, const char* m
         reportp->errorNumber == JSMSG_UNCAUGHT_EXCEPTION)
     {
         reportp->flags |= JSREPORT_EXCEPTION;
     }
 
     if (ErrorToException(cx, message, reportp, callback, userRef))
         return;
 
-    /*
-     * The AutoJSAPI error reporter only allows warnings to be reported so
-     * just ignore this error rather than try to report it.
-     */
-    if (!JSREPORT_IS_WARNING(reportp->flags))
-        return;
-
-    /*
-     * Call the error reporter only if an exception wasn't raised.
-     */
-    if (message)
-        CallErrorReporter(cx, message, reportp);
+    if (JSREPORT_IS_WARNING(reportp->flags))
+        CallWarningReporter(cx, message, reportp);
 }
 
 /*
  * The given JSErrorReport object have been zeroed and must not outlive
  * cx->fp() (otherwise owned fields may become invalid).
  */
 static void
 PopulateReportBlame(JSContext* cx, JSErrorReport* report)
@@ -790,23 +780,24 @@ js::ReportErrorNumberUCArray(JSContext* 
 
     js_free(message);
     js_free((void*)report.ucmessage);
 
     return warning;
 }
 
 void
-js::CallErrorReporter(JSContext* cx, const char* message, JSErrorReport* reportp)
+js::CallWarningReporter(JSContext* cx, const char* message, JSErrorReport* reportp)
 {
     MOZ_ASSERT(message);
     MOZ_ASSERT(reportp);
+    MOZ_ASSERT(JSREPORT_IS_WARNING(reportp->flags));
 
-    if (JSErrorReporter onError = cx->runtime()->errorReporter)
-        onError(cx, message, reportp);
+    if (JS::WarningReporter warningReporter = cx->runtime()->warningReporter)
+        warningReporter(cx, message, reportp);
 }
 
 bool
 js::ReportIsNotDefined(JSContext* cx, HandleId id)
 {
     JSAutoByteString printable;
     if (ValueToPrintable(cx, IdToValue(id), &printable))
         JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_DEFINED, printable.ptr());
--- a/js/src/jscntxt.h
+++ b/js/src/jscntxt.h
@@ -587,20 +587,20 @@ ReportUsageError(JSContext* cx, HandleOb
  * is true.
  * Returns false otherwise, printing just the message if the report is nullptr.
  */
 extern bool
 PrintError(JSContext* cx, FILE* file, const char* message, JSErrorReport* report,
            bool reportWarnings);
 
 /*
- * Send a JSErrorReport to the errorReporter callback.
+ * Send a JSErrorReport to the warningReporter callback.
  */
 void
-CallErrorReporter(JSContext* cx, const char* message, JSErrorReport* report);
+CallWarningReporter(JSContext* cx, const char* message, JSErrorReport* report);
 
 extern bool
 ReportIsNotDefined(JSContext* cx, HandlePropertyName name);
 
 extern bool
 ReportIsNotDefined(JSContext* cx, HandleId id);
 
 /*
--- a/js/src/jsexn.cpp
+++ b/js/src/jsexn.cpp
@@ -239,28 +239,28 @@ js::CopyErrorReport(JSContext* cx, JSErr
 
 #undef JS_CHARS_SIZE
     return copy;
 }
 
 struct SuppressErrorsGuard
 {
     JSContext* cx;
-    JSErrorReporter prevReporter;
+    JS::WarningReporter prevReporter;
     JS::AutoSaveExceptionState prevState;
 
     explicit SuppressErrorsGuard(JSContext* cx)
       : cx(cx),
-        prevReporter(JS_SetErrorReporter(cx->runtime(), nullptr)),
+        prevReporter(JS::SetWarningReporter(cx->runtime(), nullptr)),
         prevState(cx)
     {}
 
     ~SuppressErrorsGuard()
     {
-        JS_SetErrorReporter(cx->runtime(), prevReporter);
+        JS::SetWarningReporter(cx->runtime(), prevReporter);
     }
 };
 
 // Cut off the stack if it gets too deep (most commonly for infinite recursion
 // errors).
 static const size_t MAX_REPORTED_STACK_DEPTH = 1u << 7;
 
 static bool
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -2890,17 +2890,17 @@ WorkerMain(void* arg)
         JS_DestroyRuntime(rt);
         js_delete(input);
         return;
     }
 
     sr->isWorker = true;
     JS_SetRuntimePrivate(rt, sr.get());
     JS_SetFutexCanWait(rt);
-    JS_SetErrorReporter(rt, WarningReporter);
+    JS::SetWarningReporter(rt, WarningReporter);
     JS_InitDestroyPrincipalsCallback(rt, ShellPrincipals::destroy);
     SetWorkerRuntimeOptions(rt);
 
     JSContext* cx = NewContext(rt);
     if (!cx) {
         JS_DestroyRuntime(rt);
         js_delete(input);
         return;
@@ -7353,17 +7353,17 @@ main(int argc, char** argv, char** envp)
 
     UniquePtr<ShellRuntime> sr = MakeUnique<ShellRuntime>(rt);
     if (!sr)
         return 1;
 
     JS_SetRuntimePrivate(rt, sr.get());
     // Waiting is allowed on the shell's main thread, for now.
     JS_SetFutexCanWait(rt);
-    JS_SetErrorReporter(rt, WarningReporter);
+    JS::SetWarningReporter(rt, WarningReporter);
     if (!SetRuntimeOptions(rt, op))
         return 1;
 
     JS_SetGCParameter(rt, JSGC_MAX_BYTES, 0xffffffff);
 
     size_t availMem = op.getIntOption("available-memory");
     if (availMem > 0)
         JS_SetGCParametersBasedOnAvailableMemory(rt, availMem);
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -4925,33 +4925,33 @@ Debugger::isCompilableUnit(JSContext* cx
 
     bool result = true;
 
     CompileOptions options(cx);
     frontend::Parser<frontend::FullParseHandler> parser(cx, &cx->tempLifoAlloc(),
                                                         options, chars.twoByteChars(),
                                                         length, /* foldConstants = */ true,
                                                         nullptr, nullptr);
-    JSErrorReporter older = JS_SetErrorReporter(cx->runtime(), nullptr);
+    JS::WarningReporter older = JS::SetWarningReporter(cx->runtime(), nullptr);
     if (!parser.checkOptions() || !parser.parse()) {
         // We ran into an error. If it was because we ran out of memory we report
         // it in the usual way.
         if (cx->isThrowingOutOfMemory()) {
-            JS_SetErrorReporter(cx->runtime(), older);
+            JS::SetWarningReporter(cx->runtime(), older);
             return false;
         }
 
         // If it was because we ran out of source, we return false so our caller
         // knows to try to collect more [source].
         if (parser.isUnexpectedEOF())
             result = false;
 
         cx->clearPendingException();
     }
-    JS_SetErrorReporter(cx->runtime(), older);
+    JS::SetWarningReporter(cx->runtime(), older);
     args.rval().setBoolean(result);
     return true;
 }
 
 
 bool
 Debugger::drainTraceLoggerScriptCalls(JSContext* cx, unsigned argc, Value* vp)
 {
--- a/js/src/vm/Runtime.cpp
+++ b/js/src/vm/Runtime.cpp
@@ -212,17 +212,17 @@ JSRuntime::JSRuntime(JSRuntime* parentRu
     signalHandlersInstalled_(false),
     canUseSignalHandlers_(false),
     defaultFreeOp_(thisFromCtor()),
     debuggerMutations(0),
     securityCallbacks(&NullSecurityCallbacks),
     DOMcallbacks(nullptr),
     destroyPrincipals(nullptr),
     readPrincipals(nullptr),
-    errorReporter(nullptr),
+    warningReporter(nullptr),
     buildIdOp(nullptr),
     propertyRemovals(0),
 #if !EXPOSE_INTL_API
     thousandsSeparator(0),
     decimalSeparator(0),
     numGrouping(0),
 #endif
     mathCache_(nullptr),
--- a/js/src/vm/Runtime.h
+++ b/js/src/vm/Runtime.h
@@ -1275,18 +1275,18 @@ struct JSRuntime : public JS::shadow::Ru
 
     uint32_t            debuggerMutations;
 
     const JSSecurityCallbacks* securityCallbacks;
     const js::DOMCallbacks* DOMcallbacks;
     JSDestroyPrincipalsOp destroyPrincipals;
     JSReadPrincipalsOp readPrincipals;
 
-    /* Optional error reporter. */
-    JSErrorReporter     errorReporter;
+    /* Optional warning reporter. */
+    JS::WarningReporter warningReporter;
 
     JS::BuildIdOp buildIdOp;
 
     /* AsmJSCache callbacks are runtime-wide. */
     JS::AsmJSCacheOps   asmJSCacheOps;
 
     /*
      * The propertyRemovals counter is incremented for every JSObject::clear,
--- a/js/src/vm/SelfHosting.cpp
+++ b/js/src/vm/SelfHosting.cpp
@@ -2709,26 +2709,26 @@ MaybePrintAndClearPendingException(JSCon
 
     MOZ_ASSERT(!JSREPORT_IS_WARNING(report.report()->flags));
     PrintError(cx, file, report.message(), report.report(), true);
 }
 
 class MOZ_STACK_CLASS AutoSelfHostingErrorReporter
 {
     JSContext* cx_;
-    JSErrorReporter oldReporter_;
+    JS::WarningReporter oldReporter_;
 
   public:
     explicit AutoSelfHostingErrorReporter(JSContext* cx)
       : cx_(cx)
     {
-        oldReporter_ = JS_SetErrorReporter(cx_->runtime(), selfHosting_WarningReporter);
+        oldReporter_ = JS::SetWarningReporter(cx_->runtime(), selfHosting_WarningReporter);
     }
     ~AutoSelfHostingErrorReporter() {
-        JS_SetErrorReporter(cx_->runtime(), oldReporter_);
+        JS::SetWarningReporter(cx_->runtime(), oldReporter_);
 
         // Exceptions in self-hosted code will usually be printed to stderr in
         // ErrorToException, but not all exceptions are handled there. For
         // instance, ReportOutOfMemory will throw the "out of memory" string
         // without going through ErrorToException. We handle these other
         // exceptions here.
         MaybePrintAndClearPendingException(cx_, stderr);
     }
--- a/netwerk/base/ProxyAutoConfig.cpp
+++ b/netwerk/base/ProxyAutoConfig.cpp
@@ -677,17 +677,17 @@ private:
   nsresult Init()
   {
     /*
      * Not setting this will cause JS_CHECK_RECURSION to report false
      * positives
      */
     JS_SetNativeStackQuota(mRuntime, 128 * sizeof(size_t) * 1024);
 
-    JS_SetErrorReporter(mRuntime, PACWarningReporter);
+    JS::SetWarningReporter(mRuntime, PACWarningReporter);
 
     mContext = JS_NewContext(mRuntime, 0);
     NS_ENSURE_TRUE(mContext, NS_ERROR_OUT_OF_MEMORY);
 
     JSAutoRequest ar(mContext);
 
     JS::CompartmentOptions options;
     options.creationOptions().setZone(JS::SystemZone);
--- a/xpcom/base/CycleCollectedJSRuntime.cpp
+++ b/xpcom/base/CycleCollectedJSRuntime.cpp
@@ -477,17 +477,17 @@ CycleCollectedJSRuntime::~CycleCollected
 
   mozilla::dom::DestroyScriptSettings();
 
   mOwningThread->SetScriptObserver(nullptr);
   NS_RELEASE(mOwningThread);
 }
 
 static void
-MozCrashErrorReporter(JSContext*, const char*, JSErrorReport*)
+MozCrashWarningReporter(JSContext*, const char*, JSErrorReport*)
 {
   MOZ_CRASH("Why is someone touching JSAPI without an AutoJSAPI?");
 }
 
 nsresult
 CycleCollectedJSRuntime::Initialize(JSRuntime* aParentRuntime,
                                     uint32_t aMaxBytes,
                                     uint32_t aMaxNurseryBytes)
@@ -526,17 +526,17 @@ CycleCollectedJSRuntime::Initialize(JSRu
   JS_SetObjectsTenuredCallback(mJSRuntime, JSObjectsTenuredCb, this);
   JS::SetOutOfMemoryCallback(mJSRuntime, OutOfMemoryCallback, this);
   JS::SetLargeAllocationFailureCallback(mJSRuntime,
                                         LargeAllocationFailureCallback, this);
   JS_SetContextCallback(mJSRuntime, ContextCallback, this);
   JS_SetDestroyZoneCallback(mJSRuntime, XPCStringConvert::FreeZoneCache);
   JS_SetSweepZoneCallback(mJSRuntime, XPCStringConvert::ClearZoneCache);
   JS::SetBuildIdOp(mJSRuntime, GetBuildId);
-  JS_SetErrorReporter(mJSRuntime, MozCrashErrorReporter);
+  JS::SetWarningReporter(mJSRuntime, MozCrashWarningReporter);
 
   static js::DOMCallbacks DOMcallbacks = {
     InstanceClassHasProtoAtDepth
   };
   SetDOMCallbacks(mJSRuntime, &DOMcallbacks);
   js::SetScriptEnvironmentPreparer(mJSRuntime, &mEnvironmentPreparer);
 
 #ifdef SPIDERMONKEY_PROMISE