Title: [284360] trunk/LayoutTests/imported/w3c
Revision
284360
Author
[email protected]
Date
2021-10-18 03:11:49 -0700 (Mon, 18 Oct 2021)

Log Message

Re-import shadow-dom WPT
https://bugs.webkit.org/show_bug.cgi?id=231845

Reviewed by Antoine Quint.

Upstream commit: https://github.com/web-platform-tests/wpt/commit/deaab24d4e359f4264ba8843fa87a558ed9e0b81

The flakiness of focus-pseudo-matches-on-shadow-host.html was due to not waiting for the "update rendering"
steps for autofocus to happen, which is flaky with the new autofocus behavior. This has been fixed by a Gecko
committer who had the issue on their side as well:

https://github.com/web-platform-tests/wpt/commit/7555902a6e5c2b2f285bc6d0e2e05b5f3229af6a

* resources/resource-files.json:
* web-platform-tests/shadow-dom/declarative/declarative-shadow-dom-attachment.tentative.html:
* web-platform-tests/shadow-dom/focus/blur-on-shadow-host-delegatesFocus-expected.txt: Added.
* web-platform-tests/shadow-dom/focus/blur-on-shadow-host-delegatesFocus.html: Added.
* web-platform-tests/shadow-dom/focus/click-focus-delegatesFocus-click-method-expected.txt: Removed.
* web-platform-tests/shadow-dom/focus/click-focus-delegatesFocus-click-method.html: Removed.
* web-platform-tests/shadow-dom/focus/click-focus-delegatesFocus-click-expected.txt: Added.
* web-platform-tests/shadow-dom/focus/click-focus-delegatesFocus-click.html: Added.
* web-platform-tests/shadow-dom/focus/focus-pseudo-matches-on-shadow-host.html:
* web-platform-tests/shadow-dom/focus/focus-pseudo-on-shadow-host-2.html:
* web-platform-tests/shadow-dom/focus/focus-selector-delegatesFocus-expected.txt:
* web-platform-tests/shadow-dom/focus/focus-selector-delegatesFocus.html:
* web-platform-tests/shadow-dom/focus/focus-tab-on-shadow-host-expected.txt: Added.
* web-platform-tests/shadow-dom/focus/focus-tab-on-shadow-host.html: Added.
* web-platform-tests/shadow-dom/focus/w3c-import.log:

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (284359 => 284360)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-10-18 10:07:52 UTC (rev 284359)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-10-18 10:11:49 UTC (rev 284360)
@@ -1,3 +1,34 @@
+2021-10-18  Tim Nguyen  <[email protected]>
+
+        Re-import shadow-dom WPT
+        https://bugs.webkit.org/show_bug.cgi?id=231845
+
+        Reviewed by Antoine Quint.
+
+        Upstream commit: https://github.com/web-platform-tests/wpt/commit/deaab24d4e359f4264ba8843fa87a558ed9e0b81
+
+        The flakiness of focus-pseudo-matches-on-shadow-host.html was due to not waiting for the "update rendering"
+        steps for autofocus to happen, which is flaky with the new autofocus behavior. This has been fixed by a Gecko
+        committer who had the issue on their side as well:
+
+        https://github.com/web-platform-tests/wpt/commit/7555902a6e5c2b2f285bc6d0e2e05b5f3229af6a
+
+        * resources/resource-files.json:
+        * web-platform-tests/shadow-dom/declarative/declarative-shadow-dom-attachment.tentative.html:
+        * web-platform-tests/shadow-dom/focus/blur-on-shadow-host-delegatesFocus-expected.txt: Added.
+        * web-platform-tests/shadow-dom/focus/blur-on-shadow-host-delegatesFocus.html: Added.
+        * web-platform-tests/shadow-dom/focus/click-focus-delegatesFocus-click-method-expected.txt: Removed.
+        * web-platform-tests/shadow-dom/focus/click-focus-delegatesFocus-click-method.html: Removed.
+        * web-platform-tests/shadow-dom/focus/click-focus-delegatesFocus-click-expected.txt: Added.
+        * web-platform-tests/shadow-dom/focus/click-focus-delegatesFocus-click.html: Added.
+        * web-platform-tests/shadow-dom/focus/focus-pseudo-matches-on-shadow-host.html:
+        * web-platform-tests/shadow-dom/focus/focus-pseudo-on-shadow-host-2.html:
+        * web-platform-tests/shadow-dom/focus/focus-selector-delegatesFocus-expected.txt:
+        * web-platform-tests/shadow-dom/focus/focus-selector-delegatesFocus.html:
+        * web-platform-tests/shadow-dom/focus/focus-tab-on-shadow-host-expected.txt: Added.
+        * web-platform-tests/shadow-dom/focus/focus-tab-on-shadow-host.html: Added.
+        * web-platform-tests/shadow-dom/focus/w3c-import.log:
+
 2021-10-15  Antoine Quint  <[email protected]>
 
         CSS Animations creation and sorting is incorrect and may lead to crash

Modified: trunk/LayoutTests/imported/w3c/resources/resource-files.json (284359 => 284360)


--- trunk/LayoutTests/imported/w3c/resources/resource-files.json	2021-10-18 10:07:52 UTC (rev 284359)
+++ trunk/LayoutTests/imported/w3c/resources/resource-files.json	2021-10-18 10:11:49 UTC (rev 284360)
@@ -2897,6 +2897,7 @@
         "web-platform-tests/shadow-dom/declarative/support/declarative-child-frame.html",
         "web-platform-tests/shadow-dom/event-on-pseudo-element-crash.html",
         "web-platform-tests/shadow-dom/imperative-slot-api-crash.html",
+        "web-platform-tests/shadow-dom/imperative-slot-assign-not-slotable-crash.html",
         "web-platform-tests/shadow-dom/nested-slot-remove-crash.html",
         "web-platform-tests/shadow-dom/user-agent-shadow-root-crash.html",
         "web-platform-tests/svg/animations/end-of-time-crash.html",

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/declarative/declarative-shadow-dom-attachment.tentative.html (284359 => 284360)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/declarative/declarative-shadow-dom-attachment.tentative.html	2021-10-18 10:07:52 UTC (rev 284359)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/declarative/declarative-shadow-dom-attachment.tentative.html	2021-10-18 10:11:49 UTC (rev 284360)
@@ -50,6 +50,14 @@
         assert_equals(element.shadowRoot.innerHTML, '', 'Empty shadow content');
         assert_equals(element.shadowRoot.mode, mode, 'Original shadow mode');
       }
+
+      assert_throws_dom('NotSupportedError', () => {
+        element.attachShadow({mode: mode});
+      }, 'Calling attachShadow a second time on an element with a declarative shadow fails (same mode)');
+
+      assert_throws_dom('NotSupportedError', () => {
+        element.attachShadow({mode: oppositeMode});
+      }, 'Calling attachShadow a second time on an element with a declarative shadow fails (opposite mode)');
     } else {
       const wrapper = nodes.wrapper;
       if (!nochildren) {

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/blur-on-shadow-host-delegatesFocus-expected.txt (0 => 284360)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/blur-on-shadow-host-delegatesFocus-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/blur-on-shadow-host-delegatesFocus-expected.txt	2021-10-18 10:11:49 UTC (rev 284360)
@@ -0,0 +1,5 @@
+
+
+PASS Calling blur() on shadow host with delegatesFocus should remove the focus.
+PASS Calling blur() on shadow host with delegatesFocus when the focus is on a slotted element should not remove the focus.
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/blur-on-shadow-host-delegatesFocus.html (0 => 284360)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/blur-on-shadow-host-delegatesFocus.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/blur-on-shadow-host-delegatesFocus.html	2021-10-18 10:11:49 UTC (rev 284360)
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Test: Blur on shadow host</title>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+
+<div id="host">
+  <input id="slotted">
+</div>
+
+<script>
+const host = document.getElementById("host");
+
+const shadowRoot = host.attachShadow({ mode: "open", delegatesFocus: true });
+
+shadowRoot.innerHTML = "<input><slot>"
+
+test(function() {
+  host.focus();
+  assert_equals(document.activeElement, host);
+  assert_equals(shadowRoot.activeElement, shadowRoot.querySelector("input"));
+  host.blur();
+  assert_equals(document.activeElement, document.body);
+  assert_equals(shadowRoot.activeElement, null);
+}, "Calling blur() on shadow host with delegatesFocus should remove the focus.");
+
+test(function() {
+  const slotted = document.getElementById("slotted");
+  slotted.focus();
+  assert_equals(document.activeElement, slotted);
+  assert_equals(shadowRoot.activeElement, null)
+  host.blur();
+  assert_equals(document.activeElement, slotted);
+  assert_equals(shadowRoot.activeElement, null)
+}, "Calling blur() on shadow host with delegatesFocus when the focus is on a slotted element should not remove the focus.");
+</script>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/click-focus-delegatesFocus-click-expected.txt (0 => 284360)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/click-focus-delegatesFocus-click-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/click-focus-delegatesFocus-click-expected.txt	2021-10-18 10:11:49 UTC (rev 284360)
@@ -0,0 +1,10 @@
+slotted
+outside
+
+PASS call click() on host with delegatesFocus, all tabindex=0
+PASS call click() on slotted element in delegatesFocus shadow tree, all tabindex=0
+PASS click on the host with delegatesFocus with another host with delegatesFocus and a focusable child
+PASS click on the host with delegatesFocus with another host with no delegatesFocus and a focusable child
+PASS click on the host with no delegatesFocus with another host with delegatesFocus and a focusable child
+PASS click on the host with no delegatesFocus with another host with no delegatesFocus and a focusable child
+

Deleted: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/click-focus-delegatesFocus-click-method-expected.txt (284359 => 284360)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/click-focus-delegatesFocus-click-method-expected.txt	2021-10-18 10:07:52 UTC (rev 284359)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/click-focus-delegatesFocus-click-method-expected.txt	2021-10-18 10:11:49 UTC (rev 284360)
@@ -1,6 +0,0 @@
-slotted
-outside
-
-PASS call click() on host with delegatesFocus, all tabindex=0
-PASS call click() on slotted element in delegatesFocus shadow tree, all tabindex=0
-

Deleted: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/click-focus-delegatesFocus-click-method.html (284359 => 284360)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/click-focus-delegatesFocus-click-method.html	2021-10-18 10:07:52 UTC (rev 284359)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/click-focus-delegatesFocus-click-method.html	2021-10-18 10:11:49 UTC (rev 284360)
@@ -1,67 +0,0 @@
-<!DOCTYPE html>
-<meta charset="utf-8">
-<title>HTML Test: click on shadow host with delegatesFocus</title>
-<script src=""
-<script src=""
-<script src=""
-<script src=""
-<script src=""
-
-<body>
-<div id="host">
-  <div id="slotted">slotted</div>
-</div>
-<div id="outside">outside</div>
-</body>
-
-<script>
-const host = document.getElementById("host");
-const slotted = document.getElementById("slotted");
-
-const shadowRoot = host.attachShadow({ mode: "open", delegatesFocus: true });
-const aboveSlot = document.createElement("div");
-aboveSlot.innerText = "aboveSlot";
-const slot = document.createElement("slot");
-shadowRoot.appendChild(aboveSlot);
-shadowRoot.appendChild(slot);
-
-const elementsInFlatTreeOrder = [host, aboveSlot, slot, slotted, outside];
-
-// Final structure:
-// <div #host> (delegatesFocus=true)
-//    #shadowRoot
-//      <div #aboveSlot>
-//      <slot #slot>
-//        (slotted) <div #slotted>
-// <div #outside>
-
-function setAllTabIndex(value) {
-  setTabIndex(elementsInFlatTreeOrder, value);
-}
-
-function removeAllTabIndex() {
-  removeTabIndex(elementsInFlatTreeOrder);
-}
-
-function resetTabIndexAndFocus() {
-  removeAllTabIndex();
-  resetFocus(document);
-  resetFocus(shadowRoot);
-}
-
-test(() => {
-  resetTabIndexAndFocus();
-  setAllTabIndex(0);
-  host.click();
-  assert_equals(shadowRoot.activeElement, null);
-  assert_equals(document.activeElement, document.body);
-}, "call click() on host with delegatesFocus, all tabindex=0");
-
-test(() => {
-  resetTabIndexAndFocus();
-  setAllTabIndex(0);
-  slotted.click();
-  assert_equals(shadowRoot.activeElement, null);
-  assert_equals(document.activeElement, document.body);
-}, "call click() on slotted element in delegatesFocus shadow tree, all tabindex=0");
-</script>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/click-focus-delegatesFocus-click.html (0 => 284360)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/click-focus-delegatesFocus-click.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/click-focus-delegatesFocus-click.html	2021-10-18 10:11:49 UTC (rev 284360)
@@ -0,0 +1,138 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Test: click on shadow host with delegatesFocus</title>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+
+<body>
+<div id="host">
+  <div id="slotted">slotted</div>
+</div>
+<div id="outside">outside</div>
+</body>
+
+<script>
+const host = document.getElementById("host");
+const slotted = document.getElementById("slotted");
+
+const shadowRoot = host.attachShadow({ mode: "open", delegatesFocus: true });
+const aboveSlot = document.createElement("div");
+aboveSlot.innerText = "aboveSlot";
+const slot = document.createElement("slot");
+shadowRoot.appendChild(aboveSlot);
+shadowRoot.appendChild(slot);
+
+const elementsInFlatTreeOrder = [host, aboveSlot, slot, slotted, outside];
+
+// Final structure:
+// <div #host> (delegatesFocus=true)
+//    #shadowRoot
+//      <div #aboveSlot>
+//      <slot #slot>
+//        (slotted) <div #slotted>
+// <div #outside>
+
+function setAllTabIndex(value) {
+  setTabIndex(elementsInFlatTreeOrder, value);
+}
+
+function removeAllTabIndex() {
+  removeTabIndex(elementsInFlatTreeOrder);
+}
+
+function resetTabIndexAndFocus() {
+  removeAllTabIndex();
+  resetFocus(document);
+  resetFocus(shadowRoot);
+}
+
+test(() => {
+  resetTabIndexAndFocus();
+  setAllTabIndex(0);
+  host.click();
+  assert_equals(shadowRoot.activeElement, null);
+  assert_equals(document.activeElement, document.body);
+}, "call click() on host with delegatesFocus, all tabindex=0");
+
+test(() => {
+  resetTabIndexAndFocus();
+  setAllTabIndex(0);
+  slotted.click();
+  assert_equals(shadowRoot.activeElement, null);
+  assert_equals(document.activeElement, document.body);
+}, "call click() on slotted element in delegatesFocus shadow tree, all tabindex=0");
+
+function createNestedHosts(outerDelegatesFocus, innerDelegatesFocus) {
+  // Structure:
+  // <div> outerHost
+  //   <input> outerLightChild
+  //   #shadowRoot outerShadow delegatesFocus=true
+  //     <div> spacer
+  //     <span> innerHost
+  //       #shadowRoot innerShadow delegatesFocus=true/false
+  //         <input> innerShadowChild
+  //     <input> outerShadowChild
+  const outerHost = document.createElement('div');
+  const outerLightChild = document.createElement('input');
+  outerHost.appendChild(outerLightChild);
+  const innerHost = document.createElement('span');
+  const outerShadow = outerHost.attachShadow({mode: 'closed', delegatesFocus:outerDelegatesFocus});
+
+  const spacer = document.createElement("div");
+  spacer.style = "height: 1000px;";
+  outerShadow.appendChild(spacer);
+
+  outerShadow.appendChild(innerHost);
+  const outerShadowChild = document.createElement('input');
+  outerShadow.appendChild(outerShadowChild);
+
+  const innerShadow = innerHost.attachShadow({mode: 'closed', delegatesFocus:innerDelegatesFocus});
+  const innerShadowChild = document.createElement('input');
+  innerShadow.appendChild(innerShadowChild);
+
+  document.body.insertBefore(outerHost, document.body.firstChild);
+  return {outerHost: outerHost,
+      outerLightChild: outerLightChild,
+      outerShadow: outerShadow,
+      outerShadowChild: outerShadowChild,
+      innerHost: innerHost,
+      innerShadow: innerShadow,
+      innerShadowChild: innerShadowChild};
+}
+
+promise_test(async function() {
+  const dom = createNestedHosts(true, true);
+  await test_driver.click(dom.outerHost);
+  assert_equals(document.activeElement, dom.outerHost);
+  assert_equals(dom.outerShadow.activeElement, dom.innerHost);
+  assert_equals(dom.innerShadow.activeElement, dom.innerShadowChild);
+}, "click on the host with delegatesFocus with another host with delegatesFocus and a focusable child");
+
+promise_test(async function() {
+  const dom = createNestedHosts(true, false);
+  await test_driver.click(dom.outerHost);
+  assert_equals(document.activeElement, dom.outerHost);
+  assert_equals(dom.outerShadow.activeElement, dom.innerHost);
+  assert_equals(dom.innerShadow.activeElement, dom.innerShadowChild);
+}, "click on the host with delegatesFocus with another host with no delegatesFocus and a focusable child");
+
+promise_test(async function() {
+  const dom = createNestedHosts(false, true);
+  await test_driver.click(dom.outerHost);
+  assert_equals(document.activeElement, document.body);
+  assert_equals(dom.outerShadow.activeElement, null);
+  assert_equals(dom.innerShadow.activeElement, null);
+}, "click on the host with no delegatesFocus with another host with delegatesFocus and a focusable child");
+
+promise_test(async function() {
+  const dom = createNestedHosts(false, false);
+  await test_driver.click(dom.outerHost);
+  assert_equals(document.activeElement, document.body);
+  assert_equals(dom.outerShadow.activeElement, null);
+  assert_equals(dom.innerShadow.activeElement, null);
+}, "click on the host with no delegatesFocus with another host with no delegatesFocus and a focusable child");
+
+</script>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-pseudo-matches-on-shadow-host.html (284359 => 284360)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-pseudo-matches-on-shadow-host.html	2021-10-18 10:07:52 UTC (rev 284359)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-pseudo-matches-on-shadow-host.html	2021-10-18 10:11:49 UTC (rev 284360)
@@ -16,11 +16,21 @@
 
 let focusedDefault = false;
 function didFocusDefault() { }
-function checkFocusMatch() {
+function handleFocus() {
+    if (!focusedDefault) {
+        // Use step_timeout here to avoid nested focusing steps.
+        // For example, <input id="defaultFocus" autofocus> could run scripts
+        // while it's autofocusing which may run the tests, so that the
+        // focus() usage in the tests becomes nested focusing steps.
+        step_timeout(function() {
+          testInMode('open');
+          testInMode('closed');
+        }, 0);
+    }
     focusedDefault = true;
     didFocusDefault();
 }
-defaultFocus.addEventListener('focus', checkFocusMatch);
+defaultFocus.addEventListener('focus', handleFocus);
 
 function prepare(test)
 {
@@ -75,9 +85,6 @@
 
 }
 
-testInMode('open');
-testInMode('closed');
-
 </script>
 </body>
 </html>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-pseudo-on-shadow-host-2.html (284359 => 284360)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-pseudo-on-shadow-host-2.html	2021-10-18 10:07:52 UTC (rev 284359)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-pseudo-on-shadow-host-2.html	2021-10-18 10:11:49 UTC (rev 284360)
@@ -6,6 +6,7 @@
 <link rel="help" href=""
 <link rel="help=" href=""
 <link rel="match" href=""
+<link rel="stylesheet" type="text/css" href=""
 </head>
 <body>
 <p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
@@ -12,7 +13,7 @@
 <div id="host"><span>FAIL</span></div>
 <style>
 #host { background: green; width: 100px; height: 100px; }
-#host span { background: red; }
+#host span { background: red; font: 10px/1 Ahem; }
 #host:focus span { background: green; color: green; }
 </style>
 <script>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-selector-delegatesFocus-expected.txt (284359 => 284360)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-selector-delegatesFocus-expected.txt	2021-10-18 10:07:52 UTC (rev 284359)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-selector-delegatesFocus-expected.txt	2021-10-18 10:11:49 UTC (rev 284360)
@@ -1,3 +1,4 @@
+
 foo
 foo
 
@@ -4,9 +5,13 @@
 PASS :focus applies to host with delegatesFocus=true when the shadow root's descendant has focus
 PASS :focus does not apply to host with delegatesFocus=true when slotted element has focus
 PASS :focus applies to host with delegatesFocus=true when an element in a nested shadow tree with delegatesFocus=true is focused
+PASS :focus should be removed from hosts with delegatesFocus=true when none of the elements in a nested shadow tree with delegatesFocus=true is focused
 PASS :focus applies to host with delegatesFocus=true when an element in a nested shadow tree with delegatesFocus=false is focused
+PASS :focus should be removed from hosts with delegatesFocus=true when none of the elements in a nested shadow tree with delegatesFocus=false is focused
 PASS :focus applies to host with delegatesFocus=false when the shadow root's descendant has focus
 PASS :focus does not apply to host with delegatesFocus=false when slotted element has focus
 PASS :focus applies to host with delegatesFocus=false when an element in a nested shadow tree with delegatesFocus=true is focused
+PASS :focus should be removed from hosts with delegatesFocus=false when none of the elements in a nested shadow tree with delegatesFocus=true is focused
 PASS :focus applies to host with delegatesFocus=false when an element in a nested shadow tree with delegatesFocus=false is focused
+PASS :focus should be removed from hosts with delegatesFocus=false when none of the elements in a nested shadow tree with delegatesFocus=false is focused
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-selector-delegatesFocus.html (284359 => 284360)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-selector-delegatesFocus.html	2021-10-18 10:07:52 UTC (rev 284359)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-selector-delegatesFocus.html	2021-10-18 10:11:49 UTC (rev 284360)
@@ -11,6 +11,8 @@
 </head>
 
 <body>
+<input>
+
 <script>
 function createFocusableDiv() {
   const div = document.createElement("div");
@@ -63,7 +65,27 @@
       assert_true(nestedShadowChild.matches(":focus"), "element in nested shadow tree matches :focus");
       assert_true(nestedHost.matches(":focus"), "host of nested shadow tree matches focus");
       assert_true(host.matches(":focus"), "topmost host matches focus");
-}, `:focus applies to host with delegatesFocus=${delegatesFocus} when an element in a nested shadow tree with delegatesFocus=${nestedDelegatesFocus} is focused`);
+    }, `:focus applies to host with delegatesFocus=${delegatesFocus} when an element in a nested shadow tree with delegatesFocus=${nestedDelegatesFocus} is focused`);
+
+    test(() => {
+      resetFocus();
+      const host = createShadowHost(delegatesFocus, document.body);
+      const nestedHost = createShadowHost(nestedDelegatesFocus, host.shadowRoot);
+      const nestedShadowChild = createFocusableDiv();
+      nestedHost.shadowRoot.appendChild(nestedShadowChild);
+      // All nested shadow hosts should has :focus applied
+      nestedShadowChild.focus();
+
+      const elementOutsideOfShadowDOM = document.querySelector("input");
+      // Move the focus to an element which is outside of the nested
+      // shadow DOM trees
+      elementOutsideOfShadowDOM.focus();
+
+      assert_false(nestedShadowChild.matches(":focus"), "element in nested shadow tree doesn't matche :focus");
+      assert_false(nestedHost.matches(":focus"), "host of nested shadow tree doesn't match focus");
+      assert_false(host.matches(":focus"), "topmost host matches focus");
+      assert_true(elementOutsideOfShadowDOM.matches(":focus"), "The element outside of shadow dom matches :focus");
+    }, `:focus should be removed from hosts with delegatesFocus=${delegatesFocus} when none of the elements in a nested shadow tree with delegatesFocus=${nestedDelegatesFocus} is focused`);
   }
 }
 </script>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-tab-on-shadow-host-expected.txt (0 => 284360)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-tab-on-shadow-host-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-tab-on-shadow-host-expected.txt	2021-10-18 10:11:49 UTC (rev 284360)
@@ -0,0 +1,3 @@
+
+PASS :focus should be applied to the host when the focus is moved by <tab>
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-tab-on-shadow-host.html (0 => 284360)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-tab-on-shadow-host.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-tab-on-shadow-host.html	2021-10-18 10:11:49 UTC (rev 284360)
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTML Test: Use tab to navigate the focus to an element inside shadow host with delegatesFocus</title>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+
+<body>
+  <div id="host"></div>
+</body>
+
+<script>
+const host = document.getElementById("host");
+
+const shadowRoot = host.attachShadow({ mode: "open", delegatesFocus: true });
+const input = document.createElement("input");
+shadowRoot.appendChild(input);
+
+promise_test(async function() {
+  assert_equals(document.activeElement, document.body);
+  // Press <tab>
+  await navigateFocusForward();
+  assert_equals(document.activeElement, host);
+  assert_equals(shadowRoot.activeElement, input);
+  assert_true(host.matches(':focus'));
+}, ":focus should be applied to the host when the focus is moved by <tab>");
+</script>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/w3c-import.log (284359 => 284360)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/w3c-import.log	2021-10-18 10:07:52 UTC (rev 284359)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/w3c-import.log	2021-10-18 10:11:49 UTC (rev 284360)
@@ -16,7 +16,8 @@
 List of files:
 /LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/DocumentOrShadowRoot-activeElement.html
 /LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/ShadowRoot-delegatesFocus.html
-/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/click-focus-delegatesFocus-click-method.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/blur-on-shadow-host-delegatesFocus.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/click-focus-delegatesFocus-click.html
 /LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/click-focus-delegatesFocus-tabindex-varies.html
 /LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/click-focus-delegatesFocus-tabindex-zero.html
 /LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-method-delegatesFocus.html
@@ -28,6 +29,7 @@
 /LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-pseudo-on-shadow-host-3-expected.xht
 /LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-pseudo-on-shadow-host-3.html
 /LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-selector-delegatesFocus.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-tab-on-shadow-host.html
 /LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-tabindex-order-shadow-negative-delegatesFocus.html
 /LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-tabindex-order-shadow-negative.html
 /LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-tabindex-order-shadow-slot-one.html
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to