зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1325606 - Return wrapped async function from caller property. r=jwalden
This commit is contained in:
Родитель
d7971f4aa5
Коммит
00069dd84f
|
@ -284,6 +284,8 @@ CallerGetterImpl(JSContext* cx, const CallArgs& args)
|
|||
}
|
||||
|
||||
RootedObject caller(cx, iter.callee(cx));
|
||||
if (caller->is<JSFunction>() && caller->as<JSFunction>().isAsync())
|
||||
caller = GetWrappedAsyncFunction(&caller->as<JSFunction>());
|
||||
if (!cx->compartment()->wrap(cx, &caller))
|
||||
return false;
|
||||
|
||||
|
@ -298,6 +300,8 @@ CallerGetterImpl(JSContext* cx, const CallArgs& args)
|
|||
}
|
||||
|
||||
JSFunction* callerFun = &callerObj->as<JSFunction>();
|
||||
if (IsWrappedAsyncFunction(callerFun))
|
||||
callerFun = GetUnwrappedAsyncFunction(callerFun);
|
||||
MOZ_ASSERT(!callerFun->isBuiltin(), "non-builtin iterator returned a builtin?");
|
||||
|
||||
if (callerFun->strict()) {
|
||||
|
@ -351,6 +355,10 @@ CallerSetterImpl(JSContext* cx, const CallArgs& args)
|
|||
return true;
|
||||
|
||||
RootedObject caller(cx, iter.callee(cx));
|
||||
// |caller| is only used for security access-checking and for its
|
||||
// strictness. An unwrapped async function has its wrapped async
|
||||
// function's security access and strictness, so don't bother calling
|
||||
// |GetUnwrappedAsyncFunction|.
|
||||
if (!cx->compartment()->wrap(cx, &caller)) {
|
||||
cx->clearPendingException();
|
||||
return true;
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
var BUGNUMBER = 1185106;
|
||||
var summary = "caller property of function inside async function should return wrapped async function";
|
||||
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
(async function f() {
|
||||
var inner = (function g() {
|
||||
return g.caller;
|
||||
})();
|
||||
assertEq(inner, f);
|
||||
})();
|
||||
|
||||
(async function f() {
|
||||
"use strict";
|
||||
try {
|
||||
(function g() {
|
||||
return g.caller;
|
||||
})();
|
||||
assertEq(true, false);
|
||||
} catch (e) {
|
||||
assertEq(e instanceof TypeError, true);
|
||||
}
|
||||
})();
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
Загрузка…
Ссылка в новой задаче