mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-28 18:17:29 +09:00
1325606 - Return wrapped async function from caller property.
This commit is contained in:
parent
e4867e8b4d
commit
ff46e0c58c
2 changed files with 30 additions and 0 deletions
|
|
@ -284,6 +284,8 @@ CallerGetterImpl(JSContext* cx, const CallArgs& args)
|
||||||
}
|
}
|
||||||
|
|
||||||
RootedObject caller(cx, iter.callee(cx));
|
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))
|
if (!cx->compartment()->wrap(cx, &caller))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -304,6 +306,8 @@ CallerGetterImpl(JSContext* cx, const CallArgs& args)
|
||||||
}
|
}
|
||||||
|
|
||||||
JSFunction* callerFun = &callerObj->as<JSFunction>();
|
JSFunction* callerFun = &callerObj->as<JSFunction>();
|
||||||
|
if (IsWrappedAsyncFunction(callerFun))
|
||||||
|
callerFun = GetUnwrappedAsyncFunction(callerFun);
|
||||||
MOZ_ASSERT(!callerFun->isBuiltin(), "non-builtin iterator returned a builtin?");
|
MOZ_ASSERT(!callerFun->isBuiltin(), "non-builtin iterator returned a builtin?");
|
||||||
|
|
||||||
if (callerFun->strict()) {
|
if (callerFun->strict()) {
|
||||||
|
|
|
||||||
26
js/src/tests/ecma_2017/AsyncFunctions/inner-caller.js
Normal file
26
js/src/tests/ecma_2017/AsyncFunctions/inner-caller.js
Normal file
|
|
@ -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);
|
||||||
Loading…
Add table
Add a link
Reference in a new issue