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> /// <https://html.spec.whatwg.org/multipage/#event-handler-content-attributes>
/// containing the values from /// containing the values from
/// <https://html.spec.whatwg.org/multipage/#globaleventhandlers> /// <https://html.spec.whatwg.org/multipage/#globaleventhandlers> and
static CONTENT_EVENT_HANDLER_NAMES: [&str; 85] = [ /// <https://html.spec.whatwg.org/multipage/#windoweventhandlers> as well as
/// specific attributes for elements
static CONTENT_EVENT_HANDLER_NAMES: [&str; 108] = [
"onabort", "onabort",
"onauxclick", "onauxclick",
"onbeforeinput", "onbeforeinput",
@ -160,6 +162,32 @@ static CONTENT_EVENT_HANDLER_NAMES: [&str; 85] = [
// https://w3c.github.io/selection-api/#extensions-to-globaleventhandlers-interface // https://w3c.github.io/selection-api/#extensions-to-globaleventhandlers-interface
"onselectstart", "onselectstart",
"onselectionchange", "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)] #[derive(Clone, JSTraceable, MallocSizeOf, PartialEq)]

View file

@ -524326,7 +524326,7 @@
[] []
], ],
"event-handler-attributes.mjs": [ "event-handler-attributes.mjs": [
"8d54524950b9c09d8e4dccbb369968262c3098fd", "3ac700d3dbf73d85c95109e6662baf4db43835f4",
[] []
], ],
"frame-without-trusted-types.html": [ "frame-without-trusted-types.html": [

View file

@ -1,2 +0,0 @@
[TrustedTypePolicyFactory-getAttributeType-event-handler-content-attributes.tentative.html]
expected: ERROR

View file

@ -1,2 +0,0 @@
[set-event-handlers-content-attributes.tentative.html]
expected: ERROR

View file

@ -35,13 +35,17 @@ export async function getEventHandlerAttributeWithInterfaceNames() {
addOnAttributes(htmlIDL, interfaceName); addOnAttributes(htmlIDL, interfaceName);
}); });
const encryptedMediaIDL = await (await fetch("/interfaces/encrypted-media.idl")).text(); if ("HTMLMediaElement" in self) {
// HTMLMediaElement (the parent for <audio> and <video>) has extra event handlers. const encryptedMediaIDL = await (await fetch("/interfaces/encrypted-media.idl")).text();
addOnAttributes(encryptedMediaIDL, "HTMLMediaElement"); // HTMLMediaElement (the parent for <audio> and <video>) has extra event handlers.
addOnAttributes(encryptedMediaIDL, "HTMLMediaElement");
}
const svgAnimationsIDL = await (await fetch("/interfaces/svg-animations.idl")).text(); if ("SVGAnimationElement" in self) {
// SVGAnimationElement has extra event handlers. const svgAnimationsIDL = await (await fetch("/interfaces/svg-animations.idl")).text();
addOnAttributes(svgAnimationsIDL, "SVGAnimationElement"); // SVGAnimationElement has extra event handlers.
addOnAttributes(svgAnimationsIDL, "SVGAnimationElement");
}
return attributeNamesWithInterfaceName; return attributeNamesWithInterfaceName;
} }