Truly independent web browser
LibWeb: Only set the legacy target override flag where the spec does
Andreas Klingb6bc8e8a76d0
diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cppindex d2f9d067a02..37c28889612 100644--- a/Libraries/LibWeb/DOM/Document.cpp+++ b/Libraries/LibWeb/DOM/Document.cpp@@ -114,6 +114,7 @@#include <LibWeb/DOM/ElementByIdMap.h>#include <LibWeb/DOM/ElementFactory.h>#include <LibWeb/DOM/Event.h>+#include <LibWeb/DOM/EventDispatcher.h>#include <LibWeb/DOM/FragmentDirective.h>#include <LibWeb/DOM/HTMLCollection.h>#include <LibWeb/DOM/InputEventsTarget.h>@@ -6818,13 +6819,10 @@ void Document::unload(GC::Ptr<Document> new_document)// 12. If oldDocument's salvageable state is false, then fire an event named unload at oldDocument's relevant global// object, with legacy target override flag set.if (!m_salvageable) {- // then fire an event named unload at document's relevant global object, with legacy target override flag set.- // FIXME: The legacy target override flag is currently set by a virtual override of dispatch_event()- // We should reorganize this so that the flag appears explicitly here instead.auto event = DOM::Event::create(HTML::EventNames::unload,HighResolutionTime::current_high_resolution_time(relevant_global_object(*this)));- HTML::relevant_window(*this).dispatch_event(event);+ EventDispatcher::dispatch(HTML::relevant_window(*this), event, true);}// 13. If unloadTimingInfo is not null, then set unloadTimingInfo's unload event end time to the current highdiff --git a/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp b/Libraries/LibWeb/HTML/Parser/HTMLParser.cppindex 6879c551431..d704f84fa05 100644--- a/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp+++ b/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp@@ -30,6 +30,7 @@#include <LibWeb/DOM/Element.h>#include <LibWeb/DOM/ElementFactory.h>#include <LibWeb/DOM/Event.h>+#include <LibWeb/DOM/EventDispatcher.h>#include <LibWeb/DOM/NamedNodeMap.h>#include <LibWeb/DOM/ProcessingInstruction.h>#include <LibWeb/DOM/QualifiedName.h>@@ -998,11 +999,7 @@ void HTMLParserEndState::complete()log_document_stats_event(*document, "load"sv);// 5. Fire an event named load at window, with legacy target override flag set.- // FIXME: The legacy target override flag is currently set by a virtual override of dispatch_event()- // We should reorganize this so that the flag appears explicitly here instead.- window.dispatch_event(DOM::Event::create(- HTML::EventNames::load,- HighResolutionTime::current_high_resolution_time(relevant_global_object(window))));+ DOM::EventDispatcher::dispatch(window, DOM::Event::create(HTML::EventNames::load, HighResolutionTime::current_high_resolution_time(relevant_global_object(window))), true);// INTEROP: A load event handler can call document.open(), which associates a replacement parser after the old// parser was detached above. Do not let this completion continue into the replacement document.diff --git a/Libraries/LibWeb/HTML/Window.cpp b/Libraries/LibWeb/HTML/Window.cppindex f61c45b7386..ae90ddab24b 100644--- a/Libraries/LibWeb/HTML/Window.cpp+++ b/Libraries/LibWeb/HTML/Window.cpp@@ -576,7 +576,7 @@ WebIDL::ExceptionOr<Window::OpenedWindow> Window::window_open_steps_internal(Utfbool Window::dispatch_event(DOM::Event& event){- return DOM::EventDispatcher::dispatch(*this, event, true);+ return DOM::EventDispatcher::dispatch(*this, event);}Page& Window::page()@@ -772,7 +772,7 @@ void Window::fire_a_page_transition_event(Utf16FlyString const& event_name, boolevent->set_is_trusted(true);// and legacy target override flag set.- dispatch_event(event);+ DOM::EventDispatcher::dispatch(*this, event, true);}// https://html.spec.whatwg.org/multipage/webstorage.html#dom-localstoragediff --git a/Tests/LibWeb/Text/expected/wpt-import/dom/events/Event-dispatch-throwing-multiple-globals.txt b/Tests/LibWeb/Text/expected/wpt-import/dom/events/Event-dispatch-throwing-multiple-globals.txtindex 0817b888141..0feed938835 100644--- a/Tests/LibWeb/Text/expected/wpt-import/dom/events/Event-dispatch-throwing-multiple-globals.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/dom/events/Event-dispatch-throwing-multiple-globals.txt@@ -2,6 +2,6 @@ Harness status: OKFound 2 tests-2 Fail-Fail exception thrown in event listener function should result in error event on listener's global-Fail exception thrown in event listener interface object should result in error event on listener's global\ No newline at end of file+2 Pass+Pass exception thrown in event listener function should result in error event on listener's global+Pass exception thrown in event listener interface object should result in error event on listener's global\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/browsers/browsing-the-web/history-traversal/hashchange_event.txt b/Tests/LibWeb/Text/expected/wpt-import/html/browsers/browsing-the-web/history-traversal/hashchange_event.txtindex e868d66c1f8..1319f447362 100644--- a/Tests/LibWeb/Text/expected/wpt-import/html/browsers/browsing-the-web/history-traversal/hashchange_event.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/html/browsers/browsing-the-web/history-traversal/hashchange_event.txt@@ -2,5 +2,5 @@ Harness status: OKFound 1 tests-1 Fail-Fail Queue a task to fire hashchange event\ No newline at end of file+1 Pass+Pass Queue a task to fire hashchange event\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/browsers/browsing-the-web/history-traversal/popstate_event.txt b/Tests/LibWeb/Text/expected/wpt-import/html/browsers/browsing-the-web/history-traversal/popstate_event.txtindex e1984a45db3..5c0a7e89947 100644--- a/Tests/LibWeb/Text/expected/wpt-import/html/browsers/browsing-the-web/history-traversal/popstate_event.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/html/browsers/browsing-the-web/history-traversal/popstate_event.txt@@ -2,5 +2,5 @@ Harness status: OKFound 1 tests-1 Fail-Fail Queue a task to fire popstate event\ No newline at end of file+1 Pass+Pass Queue a task to fire popstate event\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/browsers/browsing-the-web/scroll-to-fragid/004.txt b/Tests/LibWeb/Text/expected/wpt-import/html/browsers/browsing-the-web/scroll-to-fragid/004.txtindex 96065c76d3a..ccfae117458 100644--- a/Tests/LibWeb/Text/expected/wpt-import/html/browsers/browsing-the-web/scroll-to-fragid/004.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/html/browsers/browsing-the-web/scroll-to-fragid/004.txt@@ -2,5 +2,5 @@ Harness status: OKFound 1 tests-1 Fail-Fail Fragment Navigation: hashchange event\ No newline at end of file+1 Pass+Pass Fragment Navigation: hashchange event\ No newline at end of file