From 5356de1c58bcee409075e808c7460defbb2e8679 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 9 Sep 2021 01:06:38 +0200 Subject: [PATCH] LibWeb: Use the task queue to fire "error" events on scripts --- Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp index 22375f2362..1eb80393ce 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp @@ -243,11 +243,12 @@ void HTMLScriptElement::prepare_script() if (has_attribute(HTML::AttributeNames::src)) { // 1. Let src be the value of the element's src attribute. auto src = attribute(HTML::AttributeNames::src); - // FIXME: 2. If src is the empty string, queue a task to fire an event named error at the element, and return. + // 2. If src is the empty string, queue a task to fire an event named error at the element, and return. if (src.is_empty()) { dbgln("HTMLScriptElement: Refusing to run script because the src attribute is empty."); - // FIXME: Queue a task to do this. - dispatch_event(DOM::Event::create(HTML::EventNames::error)); + queue_an_element_task(HTML::Task::Source::Unspecified, [this] { + dispatch_event(DOM::Event::create(HTML::EventNames::error)); + }); return; } // 3. Set the element's from an external file flag. @@ -258,8 +259,9 @@ void HTMLScriptElement::prepare_script() // 5. If the previous step failed, queue a task to fire an event named error at the element, and return. Otherwise, let url be the resulting URL record. if (!url.is_valid()) { dbgln("HTMLScriptElement: Refusing to run script because the src URL '{}' is invalid.", url); - // FIXME: Queue a task to do this. - dispatch_event(DOM::Event::create(HTML::EventNames::error)); + queue_an_element_task(HTML::Task::Source::Unspecified, [this] { + dispatch_event(DOM::Event::create(HTML::EventNames::error)); + }); return; }