Truly independent web browser
LibWeb: Stop firing `loadingdone` for font face sets that never loaded
Tim Ledbetteradb1706d69d2
diff --git a/Libraries/LibWeb/CSS/FontFaceSet.cpp b/Libraries/LibWeb/CSS/FontFaceSet.cppindex 88bc5bd125b..79b5bf171ef 100644--- a/Libraries/LibWeb/CSS/FontFaceSet.cpp+++ b/Libraries/LibWeb/CSS/FontFaceSet.cpp@@ -538,6 +538,7 @@ void FontFaceSet::switch_to_loaded()return;// 3. Set font face set’s status attribute to "loaded".+ auto was_loading = m_status == FontFaceSetLoadStatus::Loading;m_status = FontFaceSetLoadStatus::Loaded;// 4. Fulfill font face set’s [[ReadyPromise]] attribute’s value with font face set.@@ -545,6 +546,11 @@ void FontFaceSet::switch_to_loaded()HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };Bindings::resolve_font_face_set_promise(realm, m_ready_promise, *this);+ // AD-HOC: A set that never switched to loading only fulfills its ready promise. Firing loadingdone for it would+ // report a load that never happened.+ if (!was_loading)+ return;+// 5. Queue a task to perform the following steps synchronously:HTML::queue_a_task(HTML::Task::Source::FontLoading, nullptr, nullptr, GC::create_function(GC::Heap::the(), [this] {// 1. Let loaded fonts be the (possibly empty) contents of font face set’s [[LoadedFonts]] slot.