LibWeb: Allow eval to execute TrustedScripts

This commit is contained in:
Tete17 2025-10-30 23:31:06 +01:00 committed by Jelle Raaijmakers
parent fb2062a9db
commit 6d173d931a
Notes: github-actions[bot] 2025-11-11 08:59:45 +00:00

View file

@ -125,8 +125,10 @@ void initialize_main_thread_vm(AgentType type)
};
// 8.1.6.3 HostGetCodeForEval(argument), https://html.spec.whatwg.org/multipage/webappapis.html#hostgetcodeforeval(argument)
s_main_thread_vm->host_get_code_for_eval = [](JS::Object const&) -> GC::Ptr<JS::PrimitiveString> {
// FIXME: 1. If argument is a TrustedScript object, then return argument's data.
s_main_thread_vm->host_get_code_for_eval = [](JS::Object const& argument) -> GC::Ptr<JS::PrimitiveString> {
// 1. If argument is a TrustedScript object, then return argument's data.
if (auto const* trusted_script = as_if<TrustedTypes::TrustedScript>(argument); trusted_script)
return JS::PrimitiveString::create(argument.vm(), trusted_script->to_string());
// 2. Otherwise, return no-code.
return {};