diff --git a/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp b/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp
index 41a52e5a53..129ff9174c 100644
--- a/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp
+++ b/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp
@@ -200,7 +200,7 @@ void EventLoop::process()
// FIXME: 2. If there are no tasks in the event loop's task queues and the WorkerGlobalScope object's closing flag is true, then destroy the event loop, aborting these steps, resuming the run a worker steps described in the Web workers section below.
// If there are tasks in the queue, schedule a new round of processing. :^)
- if (!m_task_queue.is_empty() || !m_microtask_queue.is_empty())
+ if (m_task_queue.has_runnable_tasks() || !m_microtask_queue.is_empty())
schedule();
}
diff --git a/Userland/Libraries/LibWeb/HTML/EventLoop/TaskQueue.cpp b/Userland/Libraries/LibWeb/HTML/EventLoop/TaskQueue.cpp
index 51fb07df29..8a773faa89 100644
--- a/Userland/Libraries/LibWeb/HTML/EventLoop/TaskQueue.cpp
+++ b/Userland/Libraries/LibWeb/HTML/EventLoop/TaskQueue.cpp
@@ -33,4 +33,13 @@ OwnPtr TaskQueue::take_first_runnable()
return nullptr;
}
+bool TaskQueue::has_runnable_tasks() const
+{
+ for (auto& task : m_tasks) {
+ if (task->is_runnable())
+ return true;
+ }
+ return false;
+}
+
}
diff --git a/Userland/Libraries/LibWeb/HTML/EventLoop/TaskQueue.h b/Userland/Libraries/LibWeb/HTML/EventLoop/TaskQueue.h
index e7638b07bb..cfc2a15254 100644
--- a/Userland/Libraries/LibWeb/HTML/EventLoop/TaskQueue.h
+++ b/Userland/Libraries/LibWeb/HTML/EventLoop/TaskQueue.h
@@ -18,6 +18,8 @@ public:
bool is_empty() const { return m_tasks.is_empty(); }
+ bool has_runnable_tasks() const;
+
void add(NonnullOwnPtr);
OwnPtr take_first_runnable();