From feae2f5325ef86f1d2c9c821b0f151b5cfede5c4 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Sun, 7 Jan 2018 19:08:33 -0800 Subject: [PATCH] Bug 1428605 - Add JS:: namespace to API where it's missing. r=sfink --- dom/base/nsJSEnvironment.cpp | 2 +- js/rust/build.rs | 2 +- js/src/jsapi.h | 10 +++++++++- js/src/jsexn.cpp | 2 +- js/src/shell/js.cpp | 3 ++- js/src/vm/Runtime.cpp | 4 ++-- xpcom/base/CycleCollectedJSContext.cpp | 4 ++-- xpcom/base/CycleCollectedJSContext.h | 2 +- 8 files changed, 19 insertions(+), 10 deletions(-) diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index dffadd0caf06..7bfd1eb3c038 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -253,7 +253,7 @@ FindExceptionStackForConsoleReport(nsPIDOMWindowInner* win, JS::RootingContext* rcx = RootingCx(); JS::RootedObject exceptionObject(rcx, &exceptionValue.toObject()); - JSObject* stackObject = ExceptionStackOrNull(exceptionObject); + JSObject* stackObject = JS::ExceptionStackOrNull(exceptionObject); if (stackObject) { return stackObject; } diff --git a/js/rust/build.rs b/js/rust/build.rs index 2c1b5365711c..949507e418f6 100644 --- a/js/rust/build.rs +++ b/js/rust/build.rs @@ -256,7 +256,7 @@ const WHITELIST_VARS: &'static [&'static str] = &[ /// Functions we want to generate bindings to. const WHITELIST_FUNCTIONS: &'static [&'static str] = &[ "INTERNED_STRING_TO_JSID", - "ExceptionStackOrNull", + "JS::ExceptionStackOrNull", "JS_AddExtraGCRootsTracer", "JS_AddInterruptCallback", "JS::AddPromiseReactions", diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 36014030950d..ade5e9e3af01 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -560,14 +560,19 @@ typedef bool JS::HandleObject allocationSite, JS::HandleObject incumbentGlobal, void* data); +namespace JS { + enum class PromiseRejectionHandlingState { Unhandled, Handled }; +} /* namespace JS */ + typedef void (* JSPromiseRejectionTrackerCallback)(JSContext* cx, JS::HandleObject promise, - PromiseRejectionHandlingState state, void* data); + JS::PromiseRejectionHandlingState state, + void* data); typedef void (* JSProcessPromiseCallback)(JSContext* cx, JS::HandleObject promise); @@ -5806,6 +5811,7 @@ JS_DropExceptionState(JSContext* cx, JSExceptionState* state); extern JS_PUBLIC_API(JSErrorReport*) JS_ErrorFromException(JSContext* cx, JS::HandleObject obj); +namespace JS { /** * If the given object is an exception object (or an unwrappable * cross-compartment wrapper for one), return the stack for that exception, if @@ -5816,6 +5822,8 @@ JS_ErrorFromException(JSContext* cx, JS::HandleObject obj); extern JS_PUBLIC_API(JSObject*) ExceptionStackOrNull(JS::HandleObject obj); +} /* namespace JS */ + /** * A JS context always has an "owner thread". The owner thread is set when the * context is created (to the current thread) and practically all entry points diff --git a/js/src/jsexn.cpp b/js/src/jsexn.cpp index 767a3d011787..d99032b7d274 100644 --- a/js/src/jsexn.cpp +++ b/js/src/jsexn.cpp @@ -423,7 +423,7 @@ js::ErrorFromException(JSContext* cx, HandleObject objArg) } JS_PUBLIC_API(JSObject*) -ExceptionStackOrNull(HandleObject objArg) +JS::ExceptionStackOrNull(HandleObject objArg) { JSObject* obj = CheckedUnwrap(objArg); if (!obj || !obj->is()) { diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index c06bc422f7eb..7ce81ed9e82d 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -848,7 +848,8 @@ DrainJobQueue(JSContext* cx, unsigned argc, Value* vp) static void ForwardingPromiseRejectionTrackerCallback(JSContext* cx, JS::HandleObject promise, - PromiseRejectionHandlingState state, void* data) + JS::PromiseRejectionHandlingState state, + void* data) { RootedValue callback(cx, GetShellContext(cx)->promiseRejectionTrackerCallback); if (callback.isNull()) { diff --git a/js/src/vm/Runtime.cpp b/js/src/vm/Runtime.cpp index 3d61126bc6df..3b750b2690e9 100644 --- a/js/src/vm/Runtime.cpp +++ b/js/src/vm/Runtime.cpp @@ -753,7 +753,7 @@ JSRuntime::addUnhandledRejectedPromise(JSContext* cx, js::HandleObject promise) void* data = cx->promiseRejectionTrackerCallbackData; cx->promiseRejectionTrackerCallback(cx, promise, - PromiseRejectionHandlingState::Unhandled, data); + JS::PromiseRejectionHandlingState::Unhandled, data); } void @@ -765,7 +765,7 @@ JSRuntime::removeUnhandledRejectedPromise(JSContext* cx, js::HandleObject promis void* data = cx->promiseRejectionTrackerCallbackData; cx->promiseRejectionTrackerCallback(cx, promise, - PromiseRejectionHandlingState::Handled, data); + JS::PromiseRejectionHandlingState::Handled, data); } mozilla::non_crypto::XorShift128PlusRNG& diff --git a/xpcom/base/CycleCollectedJSContext.cpp b/xpcom/base/CycleCollectedJSContext.cpp index da2f54d001cb..ec2b66be8810 100644 --- a/xpcom/base/CycleCollectedJSContext.cpp +++ b/xpcom/base/CycleCollectedJSContext.cpp @@ -250,7 +250,7 @@ CycleCollectedJSContext::EnqueuePromiseJobCallback(JSContext* aCx, void CycleCollectedJSContext::PromiseRejectionTrackerCallback(JSContext* aCx, JS::HandleObject aPromise, - PromiseRejectionHandlingState state, + JS::PromiseRejectionHandlingState state, void* aData) { #ifdef DEBUG @@ -259,7 +259,7 @@ CycleCollectedJSContext::PromiseRejectionTrackerCallback(JSContext* aCx, MOZ_ASSERT(aCx == self->Context()); MOZ_ASSERT(Get() == self); - if (state == PromiseRejectionHandlingState::Unhandled) { + if (state == JS::PromiseRejectionHandlingState::Unhandled) { PromiseDebugging::AddUncaughtRejection(aPromise); } else { PromiseDebugging::AddConsumedRejection(aPromise); diff --git a/xpcom/base/CycleCollectedJSContext.h b/xpcom/base/CycleCollectedJSContext.h index b06ed16aaf64..d2dbab7bffa5 100644 --- a/xpcom/base/CycleCollectedJSContext.h +++ b/xpcom/base/CycleCollectedJSContext.h @@ -115,7 +115,7 @@ private: void* aData); static void PromiseRejectionTrackerCallback(JSContext* aCx, JS::HandleObject aPromise, - PromiseRejectionHandlingState state, + JS::PromiseRejectionHandlingState state, void* aData); void AfterProcessMicrotask(uint32_t aRecursionDepth);