diff options
author | davidot <davidot@serenityos.org> | 2022-03-09 17:54:55 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-03-09 18:35:27 +0100 |
commit | bfedec6a98f01bcdf5e8abed8b26453d07e7e582 (patch) | |
tree | 662738c8ecef883202c32b90d2dc52d364976eb1 /Userland/Libraries/LibJS/Runtime/NativeFunction.cpp | |
parent | 1e53cc3f5b48451e8208b52ef5d14dc3b7e245e9 (diff) | |
download | serenity-bfedec6a98f01bcdf5e8abed8b26453d07e7e582.zip |
LibJS: Keep PrivateEnvironment through NativeFunction calls
Previously the variable and lexical environments were already kept in a
NativeFunction call. However when we (try to) call a private method from
within an async function we go through async_block_start which sets up
a NativeFunction to call.
This is technically not exactly as the spec describes it, as that
requires you to actually "continue" the context. Since we don't have
that concept (yet) we use this as an implementation detail to access the
private environment from within a native function.
Note that this not allow general private environment access since most
things get blocked by the parser already.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/NativeFunction.cpp')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/NativeFunction.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp b/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp index a26db38685..ab4bf8544e 100644 --- a/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp @@ -139,6 +139,9 @@ ThrowCompletionOr<Value> NativeFunction::internal_call(Value this_argument, Mark callee_context.lexical_environment = caller_context.lexical_environment; callee_context.variable_environment = caller_context.variable_environment; + // Note: Keeping the private environment is probably only needed because of async methods in classes + // calling async_block_start which goes through a NativeFunction here. + callee_context.private_environment = caller_context.private_environment; // NOTE: This is a LibJS specific hack for NativeFunction to inherit the strictness of its caller. callee_context.is_strict_mode = vm.in_strict_mode(); |