dom: set composed flag when constructing ClipboardEvent (#35146)

* clipboardevent: set composed flag

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>

* add clipboardevent test expectations

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
This commit is contained in:
Gae24 2025-01-23 19:07:59 +01:00 committed by GitHub
parent 527eaf628a
commit 6195026db0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 191 additions and 3 deletions

View file

@ -71,10 +71,9 @@ impl ClipboardEventMethods<crate::DomTypeHolder> for ClipboardEvent {
type_: DOMString,
init: &ClipboardEventInit,
) -> DomRoot<ClipboardEvent> {
// Missing composed field
let bubbles = EventBubbles::from(init.parent.bubbles);
let cancelable = EventCancelable::from(init.parent.cancelable);
ClipboardEvent::new(
let event = ClipboardEvent::new(
window,
proto,
type_,
@ -82,7 +81,9 @@ impl ClipboardEventMethods<crate::DomTypeHolder> for ClipboardEvent {
cancelable,
init.clipboardData.as_deref(),
can_gc,
)
);
event.upcast::<Event>().set_composed(init.parent.composed);
event
}
/// <https://www.w3.org/TR/clipboard-apis/#dom-clipboardevent-clipboarddata>

View file

@ -1589,6 +1589,7 @@ impl Document {
// Step 9
event.set_trusted(trusted);
// Step 10 Set events composed to true.
event.set_composed(true);
// Step 11
event.dispatch(target, false, can_gc);
}

View file

@ -623,6 +623,10 @@ impl Event {
self.is_trusted.set(trusted);
}
pub(crate) fn set_composed(&self, composed: bool) {
self.composed.set(composed);
}
/// <https://html.spec.whatwg.org/multipage/#fire-a-simple-event>
pub(crate) fn fire(&self, target: &EventTarget, can_gc: CanGc) -> EventStatus {
self.set_trusted(true);