зеркало из https://github.com/mozilla/gecko-dev.git
Bug 911216 - Part 17: Make promise-related Debugger.Object.prototype getters work with wrapped promises. r=shu
This commit is contained in:
Родитель
385d8245b5
Коммит
81145858c4
|
@ -0,0 +1,36 @@
|
|||
if (typeof Promise === "undefined")
|
||||
quit(0);
|
||||
|
||||
let g = newGlobal();
|
||||
let dbg = new Debugger();
|
||||
let gw = dbg.addDebuggee(g);
|
||||
|
||||
g.promise = Promise.resolve(42);
|
||||
|
||||
let promiseDO = gw.getOwnPropertyDescriptor('promise').value;
|
||||
|
||||
assertEq(promiseDO.isPromise, true);
|
||||
|
||||
let state = promiseDO.promiseState;
|
||||
assertEq(state.state, "fulfilled");
|
||||
assertEq(state.value, 42);
|
||||
assertEq("reason" in state, true);
|
||||
assertEq(state.reason, undefined);
|
||||
|
||||
let allocationSite = promiseDO.promiseAllocationSite;
|
||||
// Depending on whether async stacks are activated, this can be null, which
|
||||
// has typeof null.
|
||||
assertEq(typeof allocationSite === "object", true);
|
||||
|
||||
let resolutionSite = promiseDO.promiseResolutionSite;
|
||||
// Depending on whether async stacks are activated, this can be null, which
|
||||
// has typeof null.
|
||||
assertEq(typeof resolutionSite === "object", true);
|
||||
|
||||
assertEq(promiseDO.promiseID, 1);
|
||||
|
||||
assertEq(typeof promiseDO.promiseDependentPromises, "object");
|
||||
assertEq(promiseDO.promiseDependentPromises.length, 0);
|
||||
|
||||
assertEq(typeof promiseDO.promiseLifetime, "number");
|
||||
assertEq(typeof promiseDO.promiseTimeToResolution, "number");
|
|
@ -7747,6 +7747,7 @@ DebuggerObject_checkThis(JSContext* cx, const CallArgs& args, const char* fnname
|
|||
|
||||
#define THIS_DEBUGOBJECT_PROMISE(cx, argc, vp, fnname, args, obj) \
|
||||
THIS_DEBUGOBJECT_REFERENT(cx, argc, vp, fnname, args, obj); \
|
||||
obj = CheckedUnwrap(obj); \
|
||||
if (!obj->is<PromiseObject>()) { \
|
||||
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_EXPECTED_TYPE, \
|
||||
"Debugger", "Promise", obj->getClass()->name); \
|
||||
|
@ -7756,6 +7757,7 @@ DebuggerObject_checkThis(JSContext* cx, const CallArgs& args, const char* fnname
|
|||
|
||||
#define THIS_DEBUGOBJECT_OWNER_PROMISE(cx, argc, vp, fnname, args, dbg, obj) \
|
||||
THIS_DEBUGOBJECT_OWNER_REFERENT(cx, argc, vp, fnname, args, dbg, obj); \
|
||||
obj = CheckedUnwrap(obj); \
|
||||
if (!obj->is<PromiseObject>()) { \
|
||||
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_EXPECTED_TYPE, \
|
||||
"Debugger", "Promise", obj->getClass()->name); \
|
||||
|
@ -8056,6 +8058,7 @@ DebuggerObject_getIsPromise(JSContext* cx, unsigned argc, Value* vp)
|
|||
{
|
||||
THIS_DEBUGOBJECT_REFERENT(cx, argc, vp, "get isPromise", args, refobj);
|
||||
|
||||
refobj = CheckedUnwrap(refobj);
|
||||
args.rval().setBoolean(refobj->is<PromiseObject>());
|
||||
return true;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче