From 9682b150ac122b279a77e7403c87af28cd172e89 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Thu, 24 Oct 2024 13:59:00 -0400 Subject: [PATCH] WebContent: Do not raise errors from invoking element.scrollIntoView The spec does not say to do this. We must instead implement methods to validate the element after attempting to scroll. --- .../Services/WebContent/WebDriverConnection.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Userland/Services/WebContent/WebDriverConnection.cpp b/Userland/Services/WebContent/WebDriverConnection.cpp index 9e4c463084f..18830586a47 100644 --- a/Userland/Services/WebContent/WebDriverConnection.cpp +++ b/Userland/Services/WebContent/WebDriverConnection.cpp @@ -106,7 +106,7 @@ static ErrorOr ensure_browsing_context_is_open(JS:: } // https://w3c.github.io/webdriver/#dfn-scrolls-into-view -static ErrorOr scroll_element_into_view(Web::DOM::Element& element) +static void scroll_element_into_view(Web::DOM::Element& element) { // 1. Let options be the following ScrollIntoViewOptions: Web::DOM::ScrollIntoViewOptions options {}; @@ -118,9 +118,7 @@ static ErrorOr scroll_element_into_view(Web::DOM::Element& element) options.inline_ = Web::Bindings::ScrollLogicalPosition::Nearest; // 2. Run Function.[[Call]](scrollIntoView, options) with element as the this value. - TRY(element.scroll_into_view(options)); - - return {}; + (void)element.scroll_into_view(options); } // https://w3c.github.io/webdriver/#dfn-container @@ -1347,9 +1345,7 @@ Messages::WebDriverClient::ElementClickResponse WebDriverConnection::element_cli // 5. Scroll into view the element’s container. auto element_container = container_for_element(*element); - auto scroll_or_error = scroll_element_into_view(*element_container); - if (scroll_or_error.is_error()) - return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::UnknownError, scroll_or_error.error().string_literal()); + scroll_element_into_view(*element_container); // FIXME: 6. If element’s container is still not in view, return error with error code element not interactable. // FIXME: 7. If element’s container is obscured by another element, return error with error code element click intercepted. @@ -1563,7 +1559,7 @@ Messages::WebDriverClient::ElementClearResponse WebDriverConnection::element_cle return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidElementState, "Element is not editable"sv); // 5. Scroll into view the element. - TRY(scroll_element_into_view(*element)); + scroll_element_into_view(*element); // FIXME: 6. Let timeout be session's session timeouts' implicit wait timeout. // FIXME: 7. Let timer be a new timer. @@ -1620,7 +1616,7 @@ Messages::WebDriverClient::ElementSendKeysResponse WebDriverConnection::element_ // 7. If file is false or the session's strict file interactability, is true run the following substeps: if (!file || m_strict_file_interactability) { // 1. Scroll into view the element. - TRY(scroll_element_into_view(*element)); + scroll_element_into_view(*element); // FIXME: 2. Let timeout be session's session timeouts' implicit wait timeout. // FIXME: 3. Let timer be a new timer. @@ -2271,7 +2267,7 @@ Messages::WebDriverClient::TakeElementScreenshotResponse WebDriverConnection::ta auto element = TRY(Web::WebDriver::get_known_element(current_browsing_context(), element_id)); // 4. Scroll into view the element. - (void)scroll_element_into_view(*element); + scroll_element_into_view(*element); // 5. When the user agent is next to run the animation frame callbacks: // a. Let element rect be element’s rectangle.