Bug 911216 - Part 28: Second round of fixes for Promise accessors on Debugger.Object.prototype. r=ejpbruel

This commit is contained in:
Till Schneidereit 2016-07-16 12:00:41 +02:00
Родитель ebc26445fb
Коммит a649a91853
2 изменённых файлов: 47 добавлений и 27 удалений

Просмотреть файл

@ -8289,18 +8289,17 @@ DebuggerObject::errorMessageNameGetter(JSContext *cx, unsigned argc, Value* vp)
}
#ifdef SPIDERMONKEY_PROMISE
static bool
DebuggerObject_getIsPromise(JSContext* cx, unsigned argc, Value* vp)
/* static */ bool
DebuggerObject::isPromiseGetter(JSContext* cx, unsigned argc, Value* vp)
{
THIS_DEBUGOBJECT_REFERENT(cx, argc, vp, "get isPromise", args, refobj);
THIS_DEBUGOBJECT(cx, argc, vp, "get isPromise", args, object)
refobj = CheckedUnwrap(refobj);
args.rval().setBoolean(refobj->is<PromiseObject>());
args.rval().setBoolean(object->isPromise());
return true;
}
static bool
DebuggerObject_getPromiseState(JSContext* cx, unsigned argc, Value* vp)
/* static */ bool
DebuggerObject::promiseStateGetter(JSContext* cx, unsigned argc, Value* vp)
{
THIS_DEBUGOBJECT_OWNER_PROMISE(cx, argc, vp, "get promiseState", args, dbg, refobj);
@ -8339,8 +8338,8 @@ DebuggerObject_getPromiseState(JSContext* cx, unsigned argc, Value* vp)
return true;
}
static bool
DebuggerObject_getPromiseLifetime(JSContext* cx, unsigned argc, Value* vp)
/* static */ bool
DebuggerObject::promiseLifetimeGetter(JSContext* cx, unsigned argc, Value* vp)
{
THIS_DEBUGOBJECT_PROMISE(cx, argc, vp, "get promiseLifetime", args, refobj);
@ -8348,8 +8347,8 @@ DebuggerObject_getPromiseLifetime(JSContext* cx, unsigned argc, Value* vp)
return true;
}
static bool
DebuggerObject_getPromiseTimeToResolution(JSContext* cx, unsigned argc, Value* vp)
/* static */ bool
DebuggerObject::promiseTimeToResolutionGetter(JSContext* cx, unsigned argc, Value* vp)
{
THIS_DEBUGOBJECT_PROMISE(cx, argc, vp, "get promiseTimeToResolution", args, refobj);
@ -8362,8 +8361,8 @@ DebuggerObject_getPromiseTimeToResolution(JSContext* cx, unsigned argc, Value* v
return true;
}
static bool
DebuggerObject_getPromiseAllocationSite(JSContext* cx, unsigned argc, Value* vp)
/* static */ bool
DebuggerObject::promiseAllocationSiteGetter(JSContext* cx, unsigned argc, Value* vp)
{
THIS_DEBUGOBJECT_PROMISE(cx, argc, vp, "get promiseAllocationSite", args, refobj);
@ -8379,8 +8378,8 @@ DebuggerObject_getPromiseAllocationSite(JSContext* cx, unsigned argc, Value* vp)
return true;
}
static bool
DebuggerObject_getPromiseResolutionSite(JSContext* cx, unsigned argc, Value* vp)
/* static */ bool
DebuggerObject::promiseResolutionSiteGetter(JSContext* cx, unsigned argc, Value* vp)
{
THIS_DEBUGOBJECT_PROMISE(cx, argc, vp, "get promiseResolutionSite", args, refobj);
@ -8401,8 +8400,8 @@ DebuggerObject_getPromiseResolutionSite(JSContext* cx, unsigned argc, Value* vp)
return true;
}
static bool
DebuggerObject_getPromiseID(JSContext* cx, unsigned argc, Value* vp)
/* static */ bool
DebuggerObject::promiseIDGetter(JSContext* cx, unsigned argc, Value* vp)
{
THIS_DEBUGOBJECT_PROMISE(cx, argc, vp, "get promiseID", args, refobj);
@ -8410,8 +8409,8 @@ DebuggerObject_getPromiseID(JSContext* cx, unsigned argc, Value* vp)
return true;
}
static bool
DebuggerObject_getPromiseDependentPromises(JSContext* cx, unsigned argc, Value* vp)
/* static */ bool
DebuggerObject::promiseDependentPromisesGetter(JSContext* cx, unsigned argc, Value* vp)
{
THIS_DEBUGOBJECT_OWNER_PROMISE(cx, argc, vp, "get promiseDependentPromises", args, dbg, refobj);
@ -8860,14 +8859,14 @@ const JSPropertySpec DebuggerObject::properties_[] = {
#ifdef SPIDERMONKEY_PROMISE
const JSPropertySpec DebuggerObject::promiseProperties_[] = {
JS_PSG("isPromise", DebuggerObject_getIsPromise, 0),
JS_PSG("promiseState", DebuggerObject_getPromiseState, 0),
JS_PSG("promiseLifetime", DebuggerObject_getPromiseLifetime, 0),
JS_PSG("promiseTimeToResolution", DebuggerObject_getPromiseTimeToResolution, 0),
JS_PSG("promiseAllocationSite", DebuggerObject_getPromiseAllocationSite, 0),
JS_PSG("promiseResolutionSite", DebuggerObject_getPromiseResolutionSite, 0),
JS_PSG("promiseID", DebuggerObject_getPromiseID, 0),
JS_PSG("promiseDependentPromises", DebuggerObject_getPromiseDependentPromises, 0),
JS_PSG("isPromise", DebuggerObject::isPromiseGetter, 0),
JS_PSG("promiseState", DebuggerObject::promiseStateGetter, 0),
JS_PSG("promiseLifetime", DebuggerObject::promiseLifetimeGetter, 0),
JS_PSG("promiseTimeToResolution", DebuggerObject::promiseTimeToResolutionGetter, 0),
JS_PSG("promiseAllocationSite", DebuggerObject::promiseAllocationSiteGetter, 0),
JS_PSG("promiseResolutionSite", DebuggerObject::promiseResolutionSiteGetter, 0),
JS_PSG("promiseID", DebuggerObject::promiseIDGetter, 0),
JS_PSG("promiseDependentPromises", DebuggerObject::promiseDependentPromisesGetter, 0),
JS_PS_END
};
#endif // SPIDERMONKEY_PROMISE
@ -8974,6 +8973,16 @@ DebuggerObject::isGlobal() const
return referent()->is<GlobalObject>();
}
bool
DebuggerObject::isPromise() const
{
JSObject* obj = referent();
if (IsCrossCompartmentWrapper(obj))
obj = CheckedUnwrap(obj);
return obj->is<PromiseObject>();
}
/* static */ bool
DebuggerObject::getClassName(JSContext* cx, Handle<DebuggerObject*> object,
MutableHandleString result)

Просмотреть файл

@ -1250,6 +1250,7 @@ class DebuggerObject : public NativeObject
bool isBoundFunction() const;
bool isArrowFunction() const;
bool isGlobal() const;
bool isPromise() const;
JSAtom* name() const;
JSAtom* displayName() const;
@ -1298,6 +1299,16 @@ class DebuggerObject : public NativeObject
static MOZ_MUST_USE bool globalGetter(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool allocationSiteGetter(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool errorMessageNameGetter(JSContext* cx, unsigned argc, Value* vp);
#ifdef SPIDERMONKEY_PROMISE
static MOZ_MUST_USE bool isPromiseGetter(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool promiseStateGetter(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool promiseLifetimeGetter(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool promiseTimeToResolutionGetter(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool promiseAllocationSiteGetter(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool promiseResolutionSiteGetter(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool promiseIDGetter(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool promiseDependentPromisesGetter(JSContext* cx, unsigned argc, Value* vp);
#endif // SPIDERMONKEY_PROMISE
// JSNative methods
static MOZ_MUST_USE bool isExtensibleMethod(JSContext* cx, unsigned argc, Value* vp);