LibWeb: Remove tasks for destroyed documents when filtering on tasks

In TaskQueue::take_tasks_matching(), we were not discarding tasks for
destroyed documents as we now do in ::take_first_runnable() since commit
c8baa6e179.

This fixes some occurrences of missing browsing contexts / active
documents in TraversableNavigable::destroy_top_level_traversable().
This commit is contained in:
Jelle Raaijmakers
2026-03-22 12:32:03 +01:00
committed by Andreas Kling
parent eb293197f7
commit 624d514f47
Notes: github-actions[bot] 2026-03-22 19:27:57 +00:00
3 changed files with 12 additions and 2 deletions

View File

@@ -52,8 +52,7 @@ GC::Ptr<Task> TaskQueue::take_first_runnable()
if (m_tasks[i]->is_runnable())
return m_tasks.take(i);
// A non-runnable task with a destroyed document will never become runnable again; remove it.
if (m_tasks[i]->document() && m_tasks[i]->document()->has_been_destroyed()) {
if (m_tasks[i]->is_permanently_unrunnable()) {
m_tasks.remove(i);
continue;
}
@@ -91,6 +90,11 @@ GC::RootVector<GC::Ref<Task>> TaskQueue::take_tasks_matching(Function<bool(HTML:
for (size_t i = 0; i < m_tasks.size();) {
auto& task = m_tasks.at(i);
if (task->is_permanently_unrunnable()) {
m_tasks.remove(i);
continue;
}
if (filter(*task)) {
matching_tasks.append(task);
m_tasks.remove(i);