mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:27:35 +00:00
LibWeb+WebContent+WebDriver: Add WebDriver endpoint to open new window
This commit is contained in:
parent
7061322606
commit
f287165823
7 changed files with 53 additions and 0 deletions
|
@ -536,6 +536,45 @@ Messages::WebDriverClient::CloseWindowResponse WebDriverConnection::close_window
|
|||
return JsonValue {};
|
||||
}
|
||||
|
||||
// 11.5 New Window, https://w3c.github.io/webdriver/#dfn-new-window
|
||||
Messages::WebDriverClient::NewWindowResponse WebDriverConnection::new_window(JsonValue const&)
|
||||
{
|
||||
// 1. If the implementation does not support creating new top-level browsing contexts, return error with error code unsupported operation.
|
||||
|
||||
// 2. If the current top-level browsing context is no longer open, return error with error code no such window.
|
||||
TRY(ensure_open_top_level_browsing_context());
|
||||
|
||||
// 3. Handle any user prompts and return its value if it is an error.
|
||||
TRY(handle_any_user_prompts());
|
||||
|
||||
// FIXME: 4. Let type hint be the result of getting the property "type" from the parameters argument.
|
||||
|
||||
// 5. Create a new top-level browsing context by running the window open steps with url set to "about:blank",
|
||||
// target set to the empty string, and features set to "noopener" and the user agent configured to create a new
|
||||
// browsing context. This must be done without invoking the focusing steps for the created browsing context. If
|
||||
// type hint has the value "tab", and the implementation supports multiple browsing context in the same OS
|
||||
// window, the new browsing context should share an OS window with the current browsing context. If type hint
|
||||
// is "window", and the implementation supports multiple browsing contexts in separate OS windows, the
|
||||
// created browsing context should be in a new OS window. In all other cases the details of how the browsing
|
||||
// context is presented to the user are implementation defined.
|
||||
// FIXME: Reuse code of window.open() instead of calling choose_a_browsing_context
|
||||
auto [browsing_context, window_type] = m_page_client.page().top_level_browsing_context().choose_a_browsing_context("_blank"sv, true);
|
||||
|
||||
// 6. Let handle be the associated window handle of the newly created window.
|
||||
auto handle = browsing_context->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;
|
||||
|
||||
// 8. Let result be a new JSON Object initialized with:
|
||||
JsonObject result;
|
||||
result.set("handle"sv, JsonValue { handle });
|
||||
result.set("type"sv, JsonValue { type });
|
||||
|
||||
// 9. Return success with data result.
|
||||
return result;
|
||||
}
|
||||
|
||||
// 11.8.1 Get Window Rect, https://w3c.github.io/webdriver/#dfn-get-window-rect
|
||||
Messages::WebDriverClient::GetWindowRectResponse WebDriverConnection::get_window_rect()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue