mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-02 14:30:43 +00:00
Bug 1470558: Use Completion type in DebuggerObject::{set,get}Property. r=jorendorff
Use the `Completion` type to report the result of the `DebuggerObject::setProperty` and `getProperty` methods. Differential Revision: https://phabricator.services.mozilla.com/D25097 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
0817e7f8c3
commit
bbe5b53e74
@ -11528,6 +11528,7 @@ bool DebuggerObject::callMethod(JSContext* cx, unsigned argc, Value* vp) {
|
||||
bool DebuggerObject::getPropertyMethod(JSContext* cx, unsigned argc,
|
||||
Value* vp) {
|
||||
THIS_DEBUGOBJECT(cx, argc, vp, "getProperty", args, object)
|
||||
Debugger* dbg = Debugger::fromChildJSObject(object);
|
||||
|
||||
RootedId id(cx);
|
||||
if (!ValueToId<CanGC>(cx, args.get(0), &id)) {
|
||||
@ -11537,17 +11538,16 @@ bool DebuggerObject::getPropertyMethod(JSContext* cx, unsigned argc,
|
||||
RootedValue receiver(cx,
|
||||
args.length() < 2 ? ObjectValue(*object) : args.get(1));
|
||||
|
||||
if (!DebuggerObject::getProperty(cx, object, id, receiver, args.rval())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
Rooted<Completion> comp(cx);
|
||||
JS_TRY_VAR_OR_RETURN_FALSE(cx, comp, getProperty(cx, object, id, receiver));
|
||||
return comp.get().buildCompletionValue(cx, dbg, args.rval());
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool DebuggerObject::setPropertyMethod(JSContext* cx, unsigned argc,
|
||||
Value* vp) {
|
||||
THIS_DEBUGOBJECT(cx, argc, vp, "setProperty", args, object)
|
||||
Debugger* dbg = Debugger::fromChildJSObject(object);
|
||||
|
||||
RootedId id(cx);
|
||||
if (!ValueToId<CanGC>(cx, args.get(0), &id)) {
|
||||
@ -11559,12 +11559,10 @@ bool DebuggerObject::setPropertyMethod(JSContext* cx, unsigned argc,
|
||||
RootedValue receiver(cx,
|
||||
args.length() < 3 ? ObjectValue(*object) : args.get(2));
|
||||
|
||||
if (!DebuggerObject::setProperty(cx, object, id, value, receiver,
|
||||
args.rval())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
Rooted<Completion> comp(cx);
|
||||
JS_TRY_VAR_OR_RETURN_FALSE(cx, comp,
|
||||
setProperty(cx, object, id, value, receiver));
|
||||
return comp.get().buildCompletionValue(cx, dbg, args.rval());
|
||||
}
|
||||
|
||||
/* static */
|
||||
@ -12522,9 +12520,10 @@ bool DebuggerObject::deleteProperty(JSContext* cx, HandleDebuggerObject object,
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool DebuggerObject::getProperty(JSContext* cx, HandleDebuggerObject object,
|
||||
HandleId id, HandleValue receiver_,
|
||||
MutableHandleValue result) {
|
||||
Result<Completion> DebuggerObject::getProperty(JSContext* cx,
|
||||
HandleDebuggerObject object,
|
||||
HandleId id,
|
||||
HandleValue receiver_) {
|
||||
RootedObject referent(cx, object->referent());
|
||||
Debugger* dbg = object->owner();
|
||||
|
||||
@ -12532,7 +12531,7 @@ bool DebuggerObject::getProperty(JSContext* cx, HandleDebuggerObject object,
|
||||
// that is where any exceptions must be reported.
|
||||
RootedValue receiver(cx, receiver_);
|
||||
if (!dbg->unwrapDebuggeeValue(cx, &receiver)) {
|
||||
return false;
|
||||
return cx->alreadyReportedError();
|
||||
}
|
||||
|
||||
// Enter the debuggee compartment and rewrap all input value for that
|
||||
@ -12542,22 +12541,22 @@ bool DebuggerObject::getProperty(JSContext* cx, HandleDebuggerObject object,
|
||||
EnterDebuggeeObjectRealm(cx, ar, referent);
|
||||
if (!cx->compartment()->wrap(cx, &referent) ||
|
||||
!cx->compartment()->wrap(cx, &receiver)) {
|
||||
return false;
|
||||
return cx->alreadyReportedError();
|
||||
}
|
||||
cx->markId(id);
|
||||
|
||||
LeaveDebuggeeNoExecute nnx(cx);
|
||||
|
||||
bool ok = GetProperty(cx, referent, receiver, id, result);
|
||||
|
||||
return dbg->receiveCompletionValue(ar, ok, result, result);
|
||||
RootedValue result(cx);
|
||||
bool ok = GetProperty(cx, referent, receiver, id, &result);
|
||||
return Completion::fromJSResult(cx, ok, result);
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool DebuggerObject::setProperty(JSContext* cx, HandleDebuggerObject object,
|
||||
HandleId id, HandleValue value_,
|
||||
HandleValue receiver_,
|
||||
MutableHandleValue result) {
|
||||
Result<Completion> DebuggerObject::setProperty(JSContext* cx,
|
||||
HandleDebuggerObject object,
|
||||
HandleId id, HandleValue value_,
|
||||
HandleValue receiver_) {
|
||||
RootedObject referent(cx, object->referent());
|
||||
Debugger* dbg = object->owner();
|
||||
|
||||
@ -12567,7 +12566,7 @@ bool DebuggerObject::setProperty(JSContext* cx, HandleDebuggerObject object,
|
||||
RootedValue receiver(cx, receiver_);
|
||||
if (!dbg->unwrapDebuggeeValue(cx, &value) ||
|
||||
!dbg->unwrapDebuggeeValue(cx, &receiver)) {
|
||||
return false;
|
||||
return cx->alreadyReportedError();
|
||||
}
|
||||
|
||||
// Enter the debuggee compartment and rewrap all input value for that
|
||||
@ -12578,7 +12577,7 @@ bool DebuggerObject::setProperty(JSContext* cx, HandleDebuggerObject object,
|
||||
if (!cx->compartment()->wrap(cx, &referent) ||
|
||||
!cx->compartment()->wrap(cx, &value) ||
|
||||
!cx->compartment()->wrap(cx, &receiver)) {
|
||||
return false;
|
||||
return cx->alreadyReportedError();
|
||||
}
|
||||
cx->markId(id);
|
||||
|
||||
@ -12587,8 +12586,8 @@ bool DebuggerObject::setProperty(JSContext* cx, HandleDebuggerObject object,
|
||||
ObjectOpResult opResult;
|
||||
bool ok = SetProperty(cx, referent, id, value, receiver, opResult);
|
||||
|
||||
result.setBoolean(ok && opResult.reallyOk());
|
||||
return dbg->receiveCompletionValue(ar, ok, result, result);
|
||||
return Completion::fromJSResult(cx, ok,
|
||||
BooleanValue(ok && opResult.reallyOk()));
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "js/GCVariant.h"
|
||||
#include "js/HashTable.h"
|
||||
#include "js/Promise.h"
|
||||
#include "js/Result.h"
|
||||
#include "js/RootingAPI.h"
|
||||
#include "js/Utility.h"
|
||||
#include "js/Wrapper.h"
|
||||
@ -1839,14 +1840,12 @@ class DebuggerObject : public NativeObject {
|
||||
bool& result);
|
||||
static MOZ_MUST_USE bool isFrozen(JSContext* cx, HandleDebuggerObject object,
|
||||
bool& result);
|
||||
static MOZ_MUST_USE bool getProperty(JSContext* cx,
|
||||
HandleDebuggerObject object, HandleId id,
|
||||
HandleValue receiver,
|
||||
MutableHandleValue result);
|
||||
static MOZ_MUST_USE bool setProperty(JSContext* cx,
|
||||
HandleDebuggerObject object, HandleId id,
|
||||
HandleValue value, HandleValue receiver,
|
||||
MutableHandleValue result);
|
||||
static MOZ_MUST_USE JS::Result<Completion> getProperty(
|
||||
JSContext* cx, HandleDebuggerObject object, HandleId id,
|
||||
HandleValue receiver);
|
||||
static MOZ_MUST_USE JS::Result<Completion> setProperty(
|
||||
JSContext* cx, HandleDebuggerObject object, HandleId id,
|
||||
HandleValue value, HandleValue receiver);
|
||||
static MOZ_MUST_USE bool getPrototypeOf(JSContext* cx,
|
||||
HandleDebuggerObject object,
|
||||
MutableHandleDebuggerObject result);
|
||||
|
Loading…
x
Reference in New Issue
Block a user