From ac22157491abcfa7aba2fc3a59de5cc4019c5a0b Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Thu, 23 Jan 2025 20:14:16 -0500 Subject: [PATCH] script: Handle shadow roots when determining common ancestors of dirty roots. (#35132) Signed-off-by: Josh Matthews --- components/script/dom/document.rs | 11 +++++++++-- .../untriaged/events/event-dispatch/test-003.html.ini | 4 +++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index f34e78d892b..ef158e5c332 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -606,8 +606,15 @@ impl Document { ancestor.set_flag(NodeFlags::HAS_DIRTY_DESCENDANTS, has_dirty_descendants); has_dirty_descendants &= *ancestor != *new_dirty_root; } - self.dirty_root - .set(Some(new_dirty_root.downcast::().unwrap())); + + let maybe_shadow_host = new_dirty_root + .downcast::() + .map(ShadowRootMethods::Host); + let new_dirty_root_element = new_dirty_root + .downcast::() + .or(maybe_shadow_host.as_deref()); + + self.dirty_root.set(new_dirty_root_element); } pub(crate) fn take_dirty_root(&self) -> Option> { diff --git a/tests/wpt/meta/shadow-dom/untriaged/events/event-dispatch/test-003.html.ini b/tests/wpt/meta/shadow-dom/untriaged/events/event-dispatch/test-003.html.ini index a2b0b97e56f..46b247f57e1 100644 --- a/tests/wpt/meta/shadow-dom/untriaged/events/event-dispatch/test-003.html.ini +++ b/tests/wpt/meta/shadow-dom/untriaged/events/event-dispatch/test-003.html.ini @@ -1,2 +1,4 @@ [test-003.html] - expected: CRASH + expected: TIMEOUT + [A_05_05_03_T01] + expected: TIMEOUT