1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 12:17:45 +00:00

Browser+WebContent+WebDriver: Move Back, Forward, Refresh to WebContent

This commit is contained in:
Timothy Flynn 2022-11-11 13:46:22 -05:00 committed by Linus Groh
parent 24fb7cd0ad
commit 7f142745e2
10 changed files with 77 additions and 101 deletions

View file

@ -512,8 +512,7 @@ Web::WebDriver::Response Client::handle_back(Vector<StringView> const& parameter
{
dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session/<session_id>/back");
auto* session = TRY(find_session_with_id(parameters[0]));
auto result = TRY(session->back());
return make_json_value(result);
return session->web_content_connection().back();
}
// 10.4 Forward, https://w3c.github.io/webdriver/#dfn-forward
@ -522,8 +521,7 @@ Web::WebDriver::Response Client::handle_forward(Vector<StringView> const& parame
{
dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session/<session_id>/forward");
auto* session = TRY(find_session_with_id(parameters[0]));
auto result = TRY(session->forward());
return make_json_value(result);
return session->web_content_connection().forward();
}
// 10.5 Refresh, https://w3c.github.io/webdriver/#dfn-refresh
@ -532,8 +530,7 @@ Web::WebDriver::Response Client::handle_refresh(Vector<StringView> const& parame
{
dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session/<session_id>/refresh");
auto* session = TRY(find_session_with_id(parameters[0]));
auto result = TRY(session->refresh());
return make_json_value(result);
return session->web_content_connection().refresh();
}
// 10.6 Get Title, https://w3c.github.io/webdriver/#dfn-get-title

View file

@ -172,71 +172,6 @@ Web::WebDriver::Response Session::set_timeouts(JsonValue const& payload)
return JsonValue {};
}
// 10.3 Back, https://w3c.github.io/webdriver/#dfn-back
Web::WebDriver::Response Session::back()
{
// 1. If the current top-level browsing context is no longer open, return error with error code no such window.
TRY(check_for_open_top_level_browsing_context_or_return_error());
// FIXME: 2. Handle any user prompts and return its value if it is an error.
// 3. Traverse the history by a delta 1 for the current browsing context.
m_browser_connection->async_back();
// FIXME: 4. If the previous step completed results in a pageHide event firing, wait until pageShow event
// fires or for the session page load timeout milliseconds to pass, whichever occurs sooner.
// FIXME: 5. If the previous step completed by the session page load timeout being reached, and user
// prompts have been handled, return error with error code timeout.
// 6. Return success with data null.
return JsonValue();
}
// 10.4 Forward, https://w3c.github.io/webdriver/#dfn-forward
Web::WebDriver::Response Session::forward()
{
// 1. If the current top-level browsing context is no longer open, return error with error code no such window.
TRY(check_for_open_top_level_browsing_context_or_return_error());
// FIXME: 2. Handle any user prompts and return its value if it is an error.
// 3. Traverse the history by a delta 1 for the current browsing context.
m_browser_connection->async_forward();
// FIXME: 4. If the previous step completed results in a pageHide event firing, wait until pageShow event
// fires or for the session page load timeout milliseconds to pass, whichever occurs sooner.
// FIXME: 5. If the previous step completed by the session page load timeout being reached, and user
// prompts have been handled, return error with error code timeout.
// 6. Return success with data null.
return JsonValue();
}
// 10.5 Refresh, https://w3c.github.io/webdriver/#dfn-refresh
Web::WebDriver::Response Session::refresh()
{
// 1. If the current top-level browsing context is no longer open, return error with error code no such window.
TRY(check_for_open_top_level_browsing_context_or_return_error());
// FIXME: 2. Handle any user prompts and return its value if it is an error.
// 3. Initiate an overridden reload of the current top-level browsing contexts active document.
m_browser_connection->async_refresh();
// FIXME: 4. If url is special except for file:
// FIXME: 1. Try to wait for navigation to complete.
// FIXME: 2. Try to run the post-navigation checks.
// FIXME: 5. Set the current browsing context with current top-level browsing context.
// 6. Return success with data null.
return JsonValue();
}
// 10.6 Get Title, https://w3c.github.io/webdriver/#dfn-get-title
Web::WebDriver::Response Session::get_title()
{

View file

@ -51,9 +51,6 @@ public:
Web::WebDriver::Response stop();
JsonObject get_timeouts();
Web::WebDriver::Response set_timeouts(JsonValue const& payload);
Web::WebDriver::Response back();
Web::WebDriver::Response forward();
Web::WebDriver::Response refresh();
Web::WebDriver::Response get_title();
Web::WebDriver::Response get_window_handle();
ErrorOr<void, Variant<Web::WebDriver::Error, Error>> close_window();