From d2fbbabd893d84a6b8b68a8bc8034e4d6dc4da4a Mon Sep 17 00:00:00 2001 From: Alan Kemp Date: Sun, 27 Oct 2024 18:33:14 +0000 Subject: [PATCH] LibWeb: Pageshow event dispatched by the user agent should be trusted The spec says that "isTrusted is a convenience that indicates whether an event is dispatched by the user agent (as opposed to using dispatchEvent())" But when dispatching a pageshow event the flag was incorrectly set to false. This fixes https://wpt.fyi/results/html/syntax/parsing/the-end.html --- .../expected/HTML/pageshow-event-istrusted.txt | 1 + .../Text/input/HTML/pageshow-event-istrusted.html | 14 ++++++++++++++ Userland/Libraries/LibWeb/HTML/Window.cpp | 3 +++ 3 files changed, 18 insertions(+) create mode 100644 Tests/LibWeb/Text/expected/HTML/pageshow-event-istrusted.txt create mode 100644 Tests/LibWeb/Text/input/HTML/pageshow-event-istrusted.html diff --git a/Tests/LibWeb/Text/expected/HTML/pageshow-event-istrusted.txt b/Tests/LibWeb/Text/expected/HTML/pageshow-event-istrusted.txt new file mode 100644 index 0000000000..7ef22e9a43 --- /dev/null +++ b/Tests/LibWeb/Text/expected/HTML/pageshow-event-istrusted.txt @@ -0,0 +1 @@ +PASS diff --git a/Tests/LibWeb/Text/input/HTML/pageshow-event-istrusted.html b/Tests/LibWeb/Text/input/HTML/pageshow-event-istrusted.html new file mode 100644 index 0000000000..bb8a89c344 --- /dev/null +++ b/Tests/LibWeb/Text/input/HTML/pageshow-event-istrusted.html @@ -0,0 +1,14 @@ + + + \ No newline at end of file diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp index 73af7d4d4c..795484b7a2 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.cpp +++ b/Userland/Libraries/LibWeb/HTML/Window.cpp @@ -423,6 +423,9 @@ void Window::fire_a_page_transition_event(FlyString const& event_name, bool pers // the bubbles attribute initialized to true, event->set_bubbles(true); + // isTrusted is a convenience that indicates whether an event is dispatched by the user agent (as opposed to using dispatchEvent()) + event->set_is_trusted(true); + // and legacy target override flag set. dispatch_event(event); }