LibWeb: Implement "close a top-level traversable"

This commit is contained in:
Andreas Kling 2022-12-17 10:37:46 +01:00
parent f3a6fe256f
commit 5a704453af
2 changed files with 20 additions and 0 deletions

View file

@ -511,6 +511,25 @@ void TraversableNavigable::apply_pending_history_changes()
apply_the_history_step(target_step);
}
// https://html.spec.whatwg.org/multipage/document-sequences.html#close-a-top-level-traversable
void TraversableNavigable::close_top_level_traversable()
{
VERIFY(is_top_level_traversable());
// 1. Let toUnload be traversable's active document's inclusive descendant navigables.
auto to_unload = active_document()->inclusive_descendant_navigables();
// FIXME: 2. If the result of checking if unloading is user-canceled for toUnload is true, then return.
// 3. Unload the active documents of each of toUnload.
for (auto navigable : to_unload) {
navigable->active_document()->unload();
}
// 4. Destroy traversable.
destroy_top_level_traversable();
}
// https://html.spec.whatwg.org/multipage/document-sequences.html#destroy-a-top-level-traversable
void TraversableNavigable::destroy_top_level_traversable()
{

View file

@ -46,6 +46,7 @@ public:
void clear_the_forward_session_history();
void traverse_the_history_by_delta(int delta);
void close_top_level_traversable();
void destroy_top_level_traversable();
void append_session_history_traversal_steps(JS::SafeFunction<void()> steps)