diff --git a/shadow-dom/focus/focus-method-delegatesFocus.html b/shadow-dom/focus/focus-method-delegatesFocus.html index 30d60f975d9ab4..de0b6bf70f8083 100644 --- a/shadow-dom/focus/focus-method-delegatesFocus.html +++ b/shadow-dom/focus/focus-method-delegatesFocus.html @@ -283,5 +283,28 @@ assert_equals(dom.outerShadow.activeElement, dom.innerHost); assert_equals(dom.innerShadow.activeElement, dom.innerShadowChild); }, 'focus() on host with delegatesFocus with another host with delegatesFocus and a focusable child'); + +// Note that we use flat tree here however it might not be the behavior we end up +// wanting, per https://github.com/whatwg/html/issues/7207 +test(() => { + // Structure: + //
host + // #shadowRoot root delegatesFocus=true + // + // (slotted)
+ // + const host = document.createElement("div"); + const slotted = document.createElement("div"); + const firstFocusable = document.createElement("input"); + slotted.appendChild(firstFocusable); + host.appendChild(slotted); + + const root = host.attachShadow({mode: "open", delegatesFocus: true}); + root.innerHTML = ""; + document.body.appendChild(host); + + host.focus(); + assert_equals(document.activeElement, firstFocusable); +}, "Focus() on host with delegatesFocus should focus the focusable child when it is a descendant of the slotted element");