Skip to content

Commit

Permalink
WebContent: Return the handle of the newly opened window from New Window
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
trflynn89 authored and nico committed Nov 24, 2024
1 parent 9958085 commit 09f732f
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Userland/Services/WebContent/WebDriverConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 09f732f

Please sign in to comment.