Bug 1278562 - Make the isPromise getter infallible. r=jimb

This commit is contained in:
Eddy Bruel 2016-08-31 16:44:15 +02:00
parent 5b0b9d1324
commit d26c95551e
2 changed files with 10 additions and 20 deletions

View File

@ -8602,11 +8602,7 @@ DebuggerObject::isPromiseGetter(JSContext* cx, unsigned argc, Value* vp)
{
THIS_DEBUGOBJECT(cx, argc, vp, "get isPromise", args, object)
bool result;
if (!DebuggerObject::getIsPromise(cx, object, result))
return false;
args.rval().setBoolean(result);
args.rval().setBoolean(object->isPromise());
return true;
}
@ -9325,22 +9321,18 @@ DebuggerObject::isScriptedProxy() const
}
#ifdef SPIDERMONKEY_PROMISE
/* static */ bool
DebuggerObject::getIsPromise(JSContext* cx, HandleDebuggerObject object,
bool& result)
bool
DebuggerObject::isPromise() const
{
JSObject* referent = object->referent();
JSObject* referent = this->referent();
if (IsCrossCompartmentWrapper(referent)) {
referent = CheckedUnwrap(referent);
if (!referent) {
JS_ReportError(cx, "Permission denied to access object");
if (!referent)
return false;
}
}
result = referent->is<PromiseObject>();
return true;
return referent->is<PromiseObject>();
}
#endif // SPIDERMONKEY_PROMISE

View File

@ -1256,11 +1256,6 @@ class DebuggerObject : public NativeObject
MutableHandleDebuggerObject result);
static MOZ_MUST_USE bool getScriptedProxyHandler(JSContext* cx, HandleDebuggerObject object,
MutableHandleDebuggerObject result);
#ifdef SPIDERMONKEY_PROMISE
static MOZ_MUST_USE bool getIsPromise(JSContext* cx, HandleDebuggerObject object,
bool& result);
#endif // SPIDERMONKEY_PROMISE
// Methods
static MOZ_MUST_USE bool isExtensible(JSContext* cx, HandleDebuggerObject object,
bool& result);
@ -1309,6 +1304,9 @@ class DebuggerObject : public NativeObject
bool isArrowFunction() const;
bool isGlobal() const;
bool isScriptedProxy() const;
#ifdef SPIDERMONKEY_PROMISE
bool isPromise() const;
#endif // SPIDERMONKEY_PROMISE
JSAtom* name() const;
JSAtom* displayName() const;