mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-05 15:49:11 +00:00
WebContent: Implement the switch-to-parent-frame endpoint
This commit is contained in:
parent
b4aff45854
commit
30ec88dce0
Notes:
github-actions[bot]
2024-09-16 23:05:43 +00:00
Author: https://github.com/trflynn89
Commit: 30ec88dce0
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1412
Reviewed-by: https://github.com/tcl3 ✅
2 changed files with 37 additions and 21 deletions
|
@ -87,6 +87,15 @@ static Gfx::IntRect compute_window_rect(Web::Page const& page)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://w3c.github.io/webdriver/#dfn-no-longer-open
|
||||||
|
static ErrorOr<void, Web::WebDriver::Error> ensure_browsing_context_is_open(JS::GCPtr<Web::HTML::BrowsingContext> browsing_context)
|
||||||
|
{
|
||||||
|
// A browsing context is said to be no longer open if its navigable has been destroyed.
|
||||||
|
if (!browsing_context || browsing_context->has_navigable_been_destroyed())
|
||||||
|
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::NoSuchWindow, "Window not found"sv);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/webdriver/#dfn-scrolls-into-view
|
// https://w3c.github.io/webdriver/#dfn-scrolls-into-view
|
||||||
static ErrorOr<void> scroll_element_into_view(Web::DOM::Element& element)
|
static ErrorOr<void> scroll_element_into_view(Web::DOM::Element& element)
|
||||||
{
|
{
|
||||||
|
@ -572,26 +581,31 @@ Messages::WebDriverClient::SwitchToFrameResponse WebDriverConnection::switch_to_
|
||||||
// 11.7 Switch To Parent Frame, https://w3c.github.io/webdriver/#dfn-switch-to-parent-frame
|
// 11.7 Switch To Parent Frame, https://w3c.github.io/webdriver/#dfn-switch-to-parent-frame
|
||||||
Messages::WebDriverClient::SwitchToParentFrameResponse WebDriverConnection::switch_to_parent_frame(JsonValue const&)
|
Messages::WebDriverClient::SwitchToParentFrameResponse WebDriverConnection::switch_to_parent_frame(JsonValue const&)
|
||||||
{
|
{
|
||||||
dbgln("FIXME: WebDriverConnection::switch_to_parent_frame()");
|
// 1. If session's current browsing context is already the top-level browsing context:
|
||||||
|
if (¤t_browsing_context() == current_top_level_browsing_context()) {
|
||||||
|
// 1. If session's current browsing context is no longer open, return error with error code no such window.
|
||||||
|
TRY(ensure_current_browsing_context_is_open());
|
||||||
|
|
||||||
// FIXME: 1. If session's current browsing context is already the top-level browsing context:
|
// 2. Return success with data null.
|
||||||
|
return JsonValue {};
|
||||||
{
|
|
||||||
// FIXME: 1. If session's current browsing context is no longer open, return error with error code no such window.
|
|
||||||
|
|
||||||
// FIXME: 2. Return success with data null.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: 2. If session's current parent browsing context is no longer open, return error with error code no such window.
|
auto parent_browsing_context = current_parent_browsing_context();
|
||||||
|
|
||||||
// FIXME: 3. Try to handle any user prompts with session.
|
// 2. If session's current parent browsing context is no longer open, return error with error code no such window.
|
||||||
|
TRY(ensure_browsing_context_is_open(parent_browsing_context));
|
||||||
|
|
||||||
// FIXME: 4. If session's current parent browsing context is not null, set the current browsing context with session and current parent browsing context.
|
// 3. Try to handle any user prompts with session.
|
||||||
|
TRY(handle_any_user_prompts());
|
||||||
|
|
||||||
|
// 4. If session's current parent browsing context is not null, set the current browsing context with session and
|
||||||
|
// current parent browsing context.
|
||||||
|
if (parent_browsing_context)
|
||||||
|
m_current_browsing_context = *parent_browsing_context;
|
||||||
|
|
||||||
// FIXME: 5. Update any implementation-specific state that would result from the user selecting session's current browsing context for interaction, without altering OS-level focus.
|
// FIXME: 5. Update any implementation-specific state that would result from the user selecting session's current browsing context for interaction, without altering OS-level focus.
|
||||||
|
|
||||||
// FIXME: 6. Return success with data null.
|
// 6. Return success with data null.
|
||||||
|
|
||||||
return JsonValue {};
|
return JsonValue {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2215,21 +2229,22 @@ Messages::WebDriverClient::PrintPageResponse WebDriverConnection::print_page()
|
||||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::UnsupportedOperation, "Print not implemented"sv);
|
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::UnsupportedOperation, "Print not implemented"sv);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/webdriver/#dfn-no-longer-open
|
|
||||||
static ErrorOr<void, Web::WebDriver::Error> ensure_browsing_context_is_open(JS::GCPtr<Web::HTML::BrowsingContext> browsing_context)
|
|
||||||
{
|
|
||||||
// A browsing context is said to be no longer open if its navigable has been destroyed.
|
|
||||||
if (!browsing_context || browsing_context->has_navigable_been_destroyed())
|
|
||||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::NoSuchWindow, "Window not found"sv);
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
Messages::WebDriverClient::EnsureTopLevelBrowsingContextIsOpenResponse WebDriverConnection::ensure_top_level_browsing_context_is_open()
|
Messages::WebDriverClient::EnsureTopLevelBrowsingContextIsOpenResponse WebDriverConnection::ensure_top_level_browsing_context_is_open()
|
||||||
{
|
{
|
||||||
TRY(ensure_current_top_level_browsing_context_is_open());
|
TRY(ensure_current_top_level_browsing_context_is_open());
|
||||||
return JsonValue {};
|
return JsonValue {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://w3c.github.io/webdriver/#dfn-current-parent-browsing-context
|
||||||
|
JS::GCPtr<Web::HTML::BrowsingContext> WebDriverConnection::current_parent_browsing_context()
|
||||||
|
{
|
||||||
|
auto current_navigable = current_browsing_context().active_document()->navigable();
|
||||||
|
if (!current_navigable || !current_navigable->parent())
|
||||||
|
return {};
|
||||||
|
|
||||||
|
return current_navigable->parent()->active_browsing_context();
|
||||||
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/webdriver/#dfn-current-top-level-browsing-context
|
// https://w3c.github.io/webdriver/#dfn-current-top-level-browsing-context
|
||||||
JS::GCPtr<Web::HTML::BrowsingContext> WebDriverConnection::current_top_level_browsing_context()
|
JS::GCPtr<Web::HTML::BrowsingContext> WebDriverConnection::current_top_level_browsing_context()
|
||||||
{
|
{
|
||||||
|
|
|
@ -105,6 +105,7 @@ private:
|
||||||
virtual Messages::WebDriverClient::EnsureTopLevelBrowsingContextIsOpenResponse ensure_top_level_browsing_context_is_open() override;
|
virtual Messages::WebDriverClient::EnsureTopLevelBrowsingContextIsOpenResponse ensure_top_level_browsing_context_is_open() override;
|
||||||
|
|
||||||
Web::HTML::BrowsingContext& current_browsing_context() { return *m_current_browsing_context; }
|
Web::HTML::BrowsingContext& current_browsing_context() { return *m_current_browsing_context; }
|
||||||
|
JS::GCPtr<Web::HTML::BrowsingContext> current_parent_browsing_context();
|
||||||
JS::GCPtr<Web::HTML::BrowsingContext> current_top_level_browsing_context();
|
JS::GCPtr<Web::HTML::BrowsingContext> current_top_level_browsing_context();
|
||||||
|
|
||||||
ErrorOr<void, Web::WebDriver::Error> ensure_current_browsing_context_is_open();
|
ErrorOr<void, Web::WebDriver::Error> ensure_current_browsing_context_is_open();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue