From 264b2827cd024752c11f0d955cfdcae4cd1674c7 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Fri, 27 Sep 2024 17:42:07 -0400 Subject: [PATCH] WebContent: Create a temporary execution context to parse WebDriver JSON --- Userland/Services/WebContent/WebDriverConnection.cpp | 4 ++++ Userland/Services/WebContent/WebDriverConnection.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Userland/Services/WebContent/WebDriverConnection.cpp b/Userland/Services/WebContent/WebDriverConnection.cpp index 18db9e64593..071c14a6539 100644 --- a/Userland/Services/WebContent/WebDriverConnection.cpp +++ b/Userland/Services/WebContent/WebDriverConnection.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -2350,6 +2351,9 @@ ErrorOr WebDriverConnection::find(StartNodeGet // https://w3c.github.io/webdriver/#dfn-extract-the-script-arguments-from-a-request ErrorOr WebDriverConnection::extract_the_script_arguments_from_a_request(JS::VM& vm, JsonValue const& payload) { + // Creating JSON objects below requires an execution context. + Web::HTML::TemporaryExecutionContext execution_context { current_browsing_context().active_document()->relevant_settings_object() }; + // 1. Let script be the result of getting a property named script from the parameters. // 2. If script is not a String, return error with error code invalid argument. auto script = TRY(get_property(payload, "script"sv)); diff --git a/Userland/Services/WebContent/WebDriverConnection.h b/Userland/Services/WebContent/WebDriverConnection.h index 1ed76a14a58..25e3e5f550b 100644 --- a/Userland/Services/WebContent/WebDriverConnection.h +++ b/Userland/Services/WebContent/WebDriverConnection.h @@ -128,7 +128,7 @@ private: ByteString script; JS::MarkedVector arguments; }; - static ErrorOr extract_the_script_arguments_from_a_request(JS::VM&, JsonValue const& payload); + ErrorOr extract_the_script_arguments_from_a_request(JS::VM&, JsonValue const& payload); void delete_cookies(Optional const& name = {}); // https://w3c.github.io/webdriver/#dfn-page-load-strategy