mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:37:35 +00:00
LibJS: Add missing steps and spec comments to PerformEval
While adding spec comments to PerformEval, I noticed we were missing multiple steps. Namely, these were: - Checking if the host will allow us to compile the string (allowing LibWeb to perform CSP for eval) - The parser's initial state depending on the environment around us on direct eval: - Allowing new.target via eval in functions - Allowing super calls and super properties via eval in classes - Disallowing the use of the arguments object in class field initializers at eval's parse time - Setting ScriptOrModule of eval's execution context The spec allows us to apply the additional parsing steps in any order. The method I have gone with is passing in a struct to the parser's constructor, which overrides the parser's initial state to (dis)allow the things stated above from the get-go.
This commit is contained in:
parent
f4f850aaf2
commit
34f902fb52
8 changed files with 185 additions and 39 deletions
|
@ -131,6 +131,17 @@ VM::VM(OwnPtr<CustomData> custom_data)
|
|||
return HostResizeArrayBufferResult::Unhandled;
|
||||
};
|
||||
|
||||
// 19.2.1.2 HostEnsureCanCompileStrings ( callerRealm, calleeRealm ), https://tc39.es/ecma262/#sec-hostensurecancompilestrings
|
||||
host_ensure_can_compile_strings = [](Realm&, Realm&) -> ThrowCompletionOr<void> {
|
||||
// The host-defined abstract operation HostEnsureCanCompileStrings takes arguments callerRealm (a Realm Record) and calleeRealm (a Realm Record)
|
||||
// and returns either a normal completion containing unused or an abrupt completion.
|
||||
// It allows host environments to block certain ECMAScript functions which allow developers to compile strings into ECMAScript code.
|
||||
// An implementation of HostEnsureCanCompileStrings must conform to the following requirements:
|
||||
// - If the returned Completion Record is a normal completion, it must be a normal completion containing unused.
|
||||
// The default implementation of HostEnsureCanCompileStrings is to return NormalCompletion(unused).
|
||||
return {};
|
||||
};
|
||||
|
||||
#define __JS_ENUMERATE(SymbolName, snake_name) \
|
||||
m_well_known_symbol_##snake_name = js_symbol(*this, "Symbol." #SymbolName, false);
|
||||
JS_ENUMERATE_WELL_KNOWN_SYMBOLS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue