mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 09:34:57 +09:00
LibWeb: Make WebDriver check if the BC's navigable has been destroyed
The spec steps to check if a browsing context is open have been updated for navigables.
This commit is contained in:
parent
623ad94582
commit
747fd86f26
Notes:
sideshowbarker
2024-07-17 06:24:08 +09:00
Author: https://github.com/trflynn89
Commit: 747fd86f26
Pull-request: https://github.com/SerenityOS/serenity/pull/23082
4 changed files with 12 additions and 8 deletions
|
@ -614,4 +614,10 @@ SandboxingFlagSet determine_the_creation_sandboxing_flags(BrowsingContext const&
|
|||
return {};
|
||||
}
|
||||
|
||||
bool BrowsingContext::has_navigable_been_destroyed() const
|
||||
{
|
||||
auto navigable = active_document()->navigable();
|
||||
return navigable && navigable->has_been_destroyed();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -144,7 +144,7 @@ public:
|
|||
// https://html.spec.whatwg.org/multipage/origin.html#one-permitted-sandboxed-navigator
|
||||
BrowsingContext const* the_one_permitted_sandboxed_navigator() const;
|
||||
|
||||
bool has_been_discarded() const { return m_has_been_discarded; }
|
||||
bool has_navigable_been_destroyed() const;
|
||||
|
||||
JS::GCPtr<BrowsingContext> opener_browsing_context() const { return m_opener_browsing_context; }
|
||||
void set_opener_browsing_context(JS::GCPtr<BrowsingContext> browsing_context) { m_opener_browsing_context = browsing_context; }
|
||||
|
@ -197,8 +197,6 @@ private:
|
|||
JS::GCPtr<BrowsingContext> m_last_child;
|
||||
JS::GCPtr<BrowsingContext> m_next_sibling;
|
||||
JS::GCPtr<BrowsingContext> m_previous_sibling;
|
||||
|
||||
bool m_has_been_discarded { false };
|
||||
};
|
||||
|
||||
HTML::Origin determine_the_origin(AK::URL const& url, SandboxingFlagSet sandbox_flags, Optional<HTML::Origin> source_origin);
|
||||
|
|
|
@ -115,9 +115,9 @@ static ErrorOr<JsonValue, ExecuteScriptResultType> internal_json_clone_algorithm
|
|||
if (is<HTML::WindowProxy>(value.as_object())) {
|
||||
auto const& window_proxy = static_cast<HTML::WindowProxy&>(value.as_object());
|
||||
|
||||
// If the associated browsing context of the WindowProxy object in value has been discarded, return error with
|
||||
// If the associated browsing context of the WindowProxy object in value has been destroyed, return error with
|
||||
// error code stale element reference.
|
||||
if (window_proxy.associated_browsing_context()->has_been_discarded())
|
||||
if (window_proxy.associated_browsing_context()->has_navigable_been_destroyed())
|
||||
return ExecuteScriptResultType::BrowsingContextDiscarded;
|
||||
|
||||
// Otherwise return success with data set to WindowProxy reference object for value.
|
||||
|
|
|
@ -1833,8 +1833,8 @@ Messages::WebDriverClient::PrintPageResponse WebDriverConnection::print_page()
|
|||
// https://w3c.github.io/webdriver/#dfn-no-longer-open
|
||||
Messages::WebDriverClient::EnsureTopLevelBrowsingContextIsOpenResponse WebDriverConnection::ensure_top_level_browsing_context_is_open()
|
||||
{
|
||||
// A browsing context is said to be no longer open if it has been discarded.
|
||||
if (m_page_client.page().top_level_browsing_context().has_been_discarded())
|
||||
// A browsing context is said to be no longer open if its navigable has been destroyed.
|
||||
if (m_page_client.page().top_level_browsing_context().has_navigable_been_destroyed())
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::NoSuchWindow, "Window not found"sv);
|
||||
return JsonValue {};
|
||||
}
|
||||
|
@ -1901,7 +1901,7 @@ ErrorOr<void, Web::WebDriver::Error> WebDriverConnection::wait_for_navigation_to
|
|||
return {};
|
||||
|
||||
// 2. If the current browsing context is no longer open, return success with data null.
|
||||
if (m_page_client.page().top_level_browsing_context().has_been_discarded())
|
||||
if (m_page_client.page().top_level_browsing_context().has_navigable_been_destroyed())
|
||||
return {};
|
||||
|
||||
// FIXME: 3. Start a timer. If this algorithm has not completed before timer reaches the session’s session page load timeout in milliseconds, return an error with error code timeout.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue