mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:07:45 +00:00
WebContent+WebDriver: Move the Get Current URL command to WebContent
This commit is contained in:
parent
31bb79295d
commit
3ba6b5a7cb
6 changed files with 21 additions and 18 deletions
|
@ -11,6 +11,7 @@
|
|||
#include <AK/JsonObject.h>
|
||||
#include <AK/JsonValue.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/HTML/BrowsingContext.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
#include <LibWeb/Platform/Timer.h>
|
||||
|
@ -86,6 +87,23 @@ Messages::WebDriverClient::NavigateToResponse WebDriverConnection::navigate_to(J
|
|||
return { make_success_response({}) };
|
||||
}
|
||||
|
||||
// 10.2 Get Current URL, https://w3c.github.io/webdriver/#get-current-url
|
||||
Messages::WebDriverClient::GetCurrentUrlResponse WebDriverConnection::get_current_url()
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "WebDriverConnection::get_current_url");
|
||||
|
||||
// 1. If the current top-level browsing context is no longer open, return error with error code no such window.
|
||||
DRIVER_TRY(ensure_open_top_level_browsing_context());
|
||||
|
||||
// FIXME: 2. Handle any user prompts and return its value if it is an error.
|
||||
|
||||
// 3. Let url be the serialization of the current top-level browsing context’s active document’s document URL.
|
||||
auto url = m_page_host.page().top_level_browsing_context().active_document()->url().to_string();
|
||||
|
||||
// 4. Return success with data url.
|
||||
return { make_success_response(url) };
|
||||
}
|
||||
|
||||
// https://w3c.github.io/webdriver/#dfn-no-longer-open
|
||||
ErrorOr<void, Web::WebDriver::Error> WebDriverConnection::ensure_open_top_level_browsing_context()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue