script: Add remaining unique element event listeners (#38888)

This adds the remaining window as well as specific svg and animation
listeners. The test suite was erroring before, as we don't implement
`SVGAnimationElement` yet. Now, the test gracefully checks if the
interface exists before doing a lookup.

Part of #36258

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This commit is contained in:
Tim van der Lippe 2025-08-26 08:51:27 +02:00 committed by GitHub
parent c4b2f3af56
commit d38533530b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 41 additions and 13 deletions

View file

@ -70,8 +70,10 @@ use crate::script_runtime::CanGc;
/// <https://html.spec.whatwg.org/multipage/#event-handler-content-attributes>
/// containing the values from
/// <https://html.spec.whatwg.org/multipage/#globaleventhandlers>
static CONTENT_EVENT_HANDLER_NAMES: [&str; 85] = [
/// <https://html.spec.whatwg.org/multipage/#globaleventhandlers> and
/// <https://html.spec.whatwg.org/multipage/#windoweventhandlers> as well as
/// specific attributes for elements
static CONTENT_EVENT_HANDLER_NAMES: [&str; 108] = [
"onabort",
"onauxclick",
"onbeforeinput",
@ -160,6 +162,32 @@ static CONTENT_EVENT_HANDLER_NAMES: [&str; 85] = [
// https://w3c.github.io/selection-api/#extensions-to-globaleventhandlers-interface
"onselectstart",
"onselectionchange",
// https://html.spec.whatwg.org/multipage/#windoweventhandlers
"onafterprint",
"onbeforeprint",
"onbeforeunload",
"onhashchange",
"onlanguagechange",
"onmessage",
"onmessageerror",
"onoffline",
"ononline",
"onpagehide",
"onpagereveal",
"onpageshow",
"onpageswap",
"onpopstate",
"onrejectionhandled",
"onstorage",
"onunhandledrejection",
"onunload",
// https://w3c.github.io/encrypted-media/#attributes-3
"onencrypted",
"onwaitingforkey",
// https://svgwg.org/svg2-draft/interact.html#AnimationEvents
"onbegin",
"onend",
"onrepeat",
];
#[derive(Clone, JSTraceable, MallocSizeOf, PartialEq)]