diff --git a/js/src/vm/Debugger.cpp b/js/src/vm/Debugger.cpp index 653059780ccc..ba2273f009a2 100644 --- a/js/src/vm/Debugger.cpp +++ b/js/src/vm/Debugger.cpp @@ -8649,19 +8649,17 @@ DebuggerObject::promiseValueGetter(JSContext* cx, unsigned argc, Value* vp) /* static */ bool DebuggerObject::promiseReasonGetter(JSContext* cx, unsigned argc, Value* vp) { - THIS_DEBUGOBJECT_OWNER_PROMISE(cx, argc, vp, "get promiseReason", args, dbg, refobj); + THIS_DEBUGOBJECT(cx, argc, vp, "get promiseReason", args, object); - if (promise->state() != JS::PromiseState::Rejected) { + if (!DebuggerObject::requirePromise(cx, object)) + return false; + + if (object->promiseState() != JS::PromiseState::Rejected) { args.rval().setUndefined(); return true; } - RootedValue result(cx, promise->reason()); - if (!dbg->wrapDebuggeeValue(cx, &result)) - return false; - - args.rval().set(result); - return true; + return DebuggerObject::getPromiseReason(cx, object, args.rval());; } /* static */ bool @@ -9538,6 +9536,16 @@ DebuggerObject::getPromiseValue(JSContext* cx, HandleDebuggerObject object, result.set(object->promise()->value()); return object->owner()->wrapDebuggeeValue(cx, result); } + +/* static */ bool +DebuggerObject::getPromiseReason(JSContext* cx, HandleDebuggerObject object, + MutableHandleValue result) +{ + MOZ_ASSERT(object->promiseState() == JS::PromiseState::Rejected); + + result.set(object->promise()->reason()); + return object->owner()->wrapDebuggeeValue(cx, result); +} #endif // SPIDERMONKEY_PROMISE /* static */ bool diff --git a/js/src/vm/Debugger.h b/js/src/vm/Debugger.h index c04b3459e31e..1cfc55f8514a 100644 --- a/js/src/vm/Debugger.h +++ b/js/src/vm/Debugger.h @@ -1260,6 +1260,8 @@ class DebuggerObject : public NativeObject #ifdef SPIDERMONKEY_PROMISE static MOZ_MUST_USE bool getPromiseValue(JSContext* cx, HandleDebuggerObject object, MutableHandleValue result); + static MOZ_MUST_USE bool getPromiseReason(JSContext* cx, HandleDebuggerObject object, + MutableHandleValue result); #endif // SPIDERMONKEY_PROMISE // Methods