mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 20:59:16 +00:00
LibWeb: Implement window.stop()
Fixes a handful of timeouts on WPT.
This commit is contained in:
parent
fdee82d203
commit
3f461b96df
Notes:
github-actions[bot]
2024-12-05 11:39:56 +00:00
Author: https://github.com/awesomekling
Commit: 3f461b96df
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2778
Reviewed-by: https://github.com/gmta ✅
11 changed files with 94 additions and 0 deletions
|
@ -2234,4 +2234,18 @@ void Navigable::unregister_navigation_observer(Badge<NavigationObserver>, Naviga
|
|||
VERIFY(was_removed);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/document-lifecycle.html#nav-stop
|
||||
void Navigable::stop_loading()
|
||||
{
|
||||
// 1. Let document be navigable's active document.
|
||||
auto document = active_document();
|
||||
|
||||
// 2. If document's unload counter is 0, and navigable's ongoing navigation is a navigation ID, then set the ongoing navigation for navigable to null.
|
||||
if (document->unload_counter() == 0 && ongoing_navigation().has<String>())
|
||||
set_ongoing_navigation(Empty {});
|
||||
|
||||
// 3. Abort a document and its descendants given document.
|
||||
document->abort_a_document_and_its_descendants();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -74,6 +74,8 @@ public:
|
|||
void set_closing(bool value) { m_closing = value; }
|
||||
bool is_script_closable();
|
||||
|
||||
void stop_loading();
|
||||
|
||||
void set_delaying_load_events(bool value);
|
||||
bool is_delaying_load_events() const { return m_delaying_the_load_event.has_value(); }
|
||||
|
||||
|
|
|
@ -856,6 +856,18 @@ GC::Ref<History> Window::history() const
|
|||
return associated_document().history();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-window-stop
|
||||
void Window::stop()
|
||||
{
|
||||
// 1. If this's navigable is null, then return.
|
||||
auto navigable = this->navigable();
|
||||
if (!navigable)
|
||||
return;
|
||||
|
||||
// 2. Stop loading this's navigable.
|
||||
navigable->stop_loading();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#dom-window-focus
|
||||
void Window::focus()
|
||||
{
|
||||
|
|
|
@ -154,6 +154,7 @@ public:
|
|||
[[nodiscard]] GC::Ref<Location> location();
|
||||
GC::Ref<History> history() const;
|
||||
GC::Ref<Navigation> navigation();
|
||||
void stop();
|
||||
void focus();
|
||||
void blur();
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ interface Window : EventTarget {
|
|||
readonly attribute History history;
|
||||
readonly attribute Navigation navigation;
|
||||
readonly attribute CustomElementRegistry customElements;
|
||||
undefined stop();
|
||||
undefined focus();
|
||||
undefined blur();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue