From 09f732f8d24fc85d48130c4e7550e5a5e2dd692e Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Sun, 20 Oct 2024 08:51:21 -0400 Subject: [PATCH] WebContent: Return the handle of the newly opened window from New Window We were returning the handle of the already opened window, rather than the handle of the window we just opened. (cherry picked from commit 6cba55893e6cd5be39b2f8597970380e7f08b006) --- Userland/Services/WebContent/WebDriverConnection.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Userland/Services/WebContent/WebDriverConnection.cpp b/Userland/Services/WebContent/WebDriverConnection.cpp index cc5e561bc2adca..438608b1e55f1a 100644 --- a/Userland/Services/WebContent/WebDriverConnection.cpp +++ b/Userland/Services/WebContent/WebDriverConnection.cpp @@ -503,13 +503,12 @@ Messages::WebDriverClient::NewWindowResponse WebDriverConnection::new_window(Jso // context is presented to the user are implementation defined. auto* active_window = current_browsing_context().active_window(); VERIFY(active_window); - { - Web::HTML::TemporaryExecutionContext execution_context { active_window->document()->relevant_settings_object() }; - MUST(active_window->window_open_steps("about:blank"sv, ""sv, "noopener"sv)); - } + + Web::HTML::TemporaryExecutionContext execution_context { active_window->document()->relevant_settings_object() }; + auto [target_navigable, no_opener, window_type] = MUST(active_window->window_open_steps_internal("about:blank"sv, ""sv, "noopener"sv)); // 6. Let handle be the associated window handle of the newly created window. - auto handle = current_browsing_context().top_level_traversable()->window_handle(); + auto handle = target_navigable->traversable_navigable()->window_handle(); // 7. Let type be "tab" if the newly created window shares an OS-level window with the current browsing context, or "window" otherwise. auto type = "tab"sv;