Skip to content

Commit 5c1397f

Browse files
committed
LibWeb: Allow eval to execute TrustedScripts
1 parent b04d942 commit 5c1397f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Libraries/LibWeb/Bindings/MainThreadVM.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,10 @@ void initialize_main_thread_vm(AgentType type)
125125
};
126126

127127
// 8.1.6.3 HostGetCodeForEval(argument), https://html.spec.whatwg.org/multipage/webappapis.html#hostgetcodeforeval(argument)
128-
s_main_thread_vm->host_get_code_for_eval = [](JS::Object const&) -> GC::Ptr<JS::PrimitiveString> {
129-
// FIXME: 1. If argument is a TrustedScript object, then return argument's data.
128+
s_main_thread_vm->host_get_code_for_eval = [](JS::Object const& argument) -> GC::Ptr<JS::PrimitiveString> {
129+
// 1. If argument is a TrustedScript object, then return argument's data.
130+
if (auto const* trusted_script = as_if<TrustedTypes::TrustedScript>(argument); trusted_script)
131+
return JS::PrimitiveString::create(argument.vm(), trusted_script->to_string());
130132

131133
// 2. Otherwise, return no-code.
132134
return {};

0 commit comments

Comments
 (0)