From 5010e42cd3512b39b6a53977a1027c781535c3ae Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Sun, 3 Nov 2024 21:09:38 -0500 Subject: [PATCH] WebContent: Treat elements as navigable containers in WebDriver --- .../Services/WebContent/WebDriverConnection.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/Userland/Services/WebContent/WebDriverConnection.cpp b/Userland/Services/WebContent/WebDriverConnection.cpp index c8142aa79b4..8949938f589 100644 --- a/Userland/Services/WebContent/WebDriverConnection.cpp +++ b/Userland/Services/WebContent/WebDriverConnection.cpp @@ -631,22 +631,14 @@ Messages::WebDriverClient::SwitchToFrameResponse WebDriverConnection::switch_to_ auto element = WEBDRIVER_TRY(Web::WebDriver::get_known_element(current_browsing_context(), element_id)); // 4. If element is not a frame or iframe element, return error with error code no such frame. - bool is_frame = is(*element); - bool is_iframe = is(*element); - - if (!is_frame && !is_iframe) { + if (!is(*element) && !is(*element)) { async_driver_execution_complete(Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::NoSuchFrame, "element is not a frame"sv)); return; } // 5. Set the current browsing context with session and element's content navigable's active browsing context. - if (is_frame) { - // FIXME: Should HTMLFrameElement also be a NavigableContainer? - set_current_browsing_context(*element->navigable()->active_browsing_context()); - } else { - auto& navigable_container = static_cast(*element); - set_current_browsing_context(*navigable_container.content_navigable()->active_browsing_context()); - } + auto& navigable_container = static_cast(*element); + set_current_browsing_context(*navigable_container.content_navigable()->active_browsing_context()); async_driver_execution_complete(JsonValue {}); });