1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 02:07:34 +00:00

LibWeb: Propagate errors in Element::scroll_into_view()

This patch will allow us to handle scrolling errors in the WebDriver
implementation :)
This commit is contained in:
Baitinq 2022-12-24 13:15:12 +01:00 committed by Andreas Kling
parent 9a66a9ac4a
commit 6a72a4df96
4 changed files with 19 additions and 13 deletions

View file

@ -199,7 +199,7 @@ static ErrorOr<Web::DOM::ShadowRoot*, Web::WebDriver::Error> get_known_shadow_ro
}
// https://w3c.github.io/webdriver/#dfn-scrolls-into-view
static void scroll_element_into_view(Web::DOM::Element& element)
static ErrorOr<void> scroll_element_into_view(Web::DOM::Element& element)
{
// 1. Let options be the following ScrollIntoViewOptions:
Web::DOM::ScrollIntoViewOptions options {};
@ -211,7 +211,9 @@ static void 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.
element.scroll_into_view(options);
TRY(element.scroll_into_view(options));
return {};
}
template<typename PropertyType = DeprecatedString>
@ -1543,7 +1545,7 @@ Messages::WebDriverClient::TakeElementScreenshotResponse WebDriverConnection::ta
auto* element = TRY(get_known_connected_element(element_id));
// 4. Scroll into view the element.
scroll_element_into_view(*element);
(void)scroll_element_into_view(*element);
// 5. When the user agent is next to run the animation frame callbacks:
// a. Let element rect be elements rectangle.