Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (286158 => 286159)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-11-25 06:41:08 UTC (rev 286158)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2021-11-25 06:59:55 UTC (rev 286159)
@@ -1,3 +1,18 @@
+2021-11-24 Tim Nguyen <[email protected]>
+
+ Re-import html/semantics/interactive-elements/the-dialog-element WPT
+ https://bugs.webkit.org/show_bug.cgi?id=233482
+
+ Reviewed by Cameron McCormack.
+
+ Upstream commit: https://github.com/web-platform-tests/wpt/commit/71c864f8bd7f855f12c81bfc7a1fc3ebf18657f3
+
+ * web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-focus-shadow-delegatesfocus-expected.txt: Added.
+ * web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-focus-shadow-delegatesfocus.html: Added.
+ * web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-focus-shadow-expected.txt: Added.
+ * web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-focus-shadow.html: Added.
+ * web-platform-tests/html/semantics/interactive-elements/the-dialog-element/w3c-import.log:
+
2021-11-24 Patrick Griffis <[email protected]>
CSP: Implement submitting samples in violation reports
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-focus-shadow-delegatesfocus-expected.txt (0 => 286159)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-focus-shadow-delegatesfocus-expected.txt (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-focus-shadow-delegatesfocus-expected.txt 2021-11-25 06:59:55 UTC (rev 286159)
@@ -0,0 +1,4 @@
+
+FAIL show() assert_equals: document.activeElement expected Element node <div></div> but got Element node <button tabindex="-1">Focusable</button>
+FAIL showModal() assert_equals: document.activeElement expected Element node <div></div> but got Element node <button tabindex="-1">Focusable</button>
+
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-focus-shadow-delegatesfocus.html (0 => 286159)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-focus-shadow-delegatesfocus.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-focus-shadow-delegatesfocus.html 2021-11-25 06:59:55 UTC (rev 286159)
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>dialog focusing delegation with autofocus plus delegatesFocus inside the dialog</title>
+<script src=""
+<script src=""
+<body>
+
+<dialog>
+ <template class="turn-into-shadow-tree">
+ <button disabled>Non-focusable</button>
+ <template class="turn-into-shadow-tree delegates-focus">
+ <button tabindex="-1">Focusable</button>
+ <button tabindex="-1" autofocus>Focusable</button>
+ <button tabindex="-1">Focusable</button>
+ </template>
+ <button tabindex="-1">Focusable</button>
+ </template>
+ <button tabindex="-1">Focusable</button>
+</dialog>
+
+<script>
+function turnIntoShadowTree(template) {
+ for (const subTemplate of template.content.querySelectorAll(".turn-into-shadow-tree")) {
+ turnIntoShadowTree(subTemplate);
+ }
+
+ const div = document.createElement("div");
+ div.attachShadow({ mode: "open", delegatesFocus: template.classList.contains("delegates-focus") });
+ div.shadowRoot.append(template.content);
+ template.replaceWith(div);
+}
+
+for (const template of document.querySelectorAll(".turn-into-shadow-tree")) {
+ turnIntoShadowTree(template);
+}
+
+for (const method of ["show", "showModal"]) {
+ test(t => {
+ const dialog = document.querySelector("dialog");
+ dialog[method]();
+ t.add_cleanup(() => dialog.close());
+
+ const shadowHostOuter = dialog.querySelector("div");
+ assert_equals(document.activeElement, shadowHostOuter, "document.activeElement");
+
+ const shadowHostInner = shadowHostOuter.shadowRoot.querySelector("div");
+ assert_equals(shadowHostOuter.shadowRoot.activeElement, shadowHostInner, "shadowHostOuter.shadowRoot.activeElement");
+
+ const button = shadowHostInner.shadowRoot.querySelector("[autofocus]");
+ assert_equals(shadowHostInner.shadowRoot.activeElement, button, "shadowHostInner.shadowRoot.activeElement");
+ }, `${method}()`);
+}
+</script>
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-focus-shadow-expected.txt (0 => 286159)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-focus-shadow-expected.txt (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-focus-shadow-expected.txt 2021-11-25 06:59:55 UTC (rev 286159)
@@ -0,0 +1,20 @@
+
+FAIL show: When autofocus is not present, the first focusable shadow-including descendant must be focused assert_equals: expected Element node <div></div> but got Element node <body>
+
+<dialog data-description="When autofocus is not p...
+FAIL showModal: When autofocus is not present, the first focusable shadow-including descendant must be focused assert_equals: expected Element node <div></div> but got Element node <body>
+
+<dialog data-description="When autofocus is not p...
+FAIL show: autofocus outside a shadow tree must take precedence over earlier in-shadow-tree focusable elements assert_equals: expected Element node <div></div> but got Element node <button tabindex="-1" autofocus="">Focusable</button>
+FAIL showModal: autofocus outside a shadow tree must take precedence over earlier in-shadow-tree focusable elements assert_equals: expected Element node <div></div> but got Element node <button tabindex="-1" autofocus="">Focusable</button>
+FAIL show: autofocus inside a shadow tree must be ignored: no focusable elements outside the shadow tree assert_equals: expected Element node <div></div> but got Element node <body>
+
+<dialog data-description="When autofocus is not p...
+FAIL showModal: autofocus inside a shadow tree must be ignored: no focusable elements outside the shadow tree assert_equals: expected Element node <div></div> but got Element node <body>
+
+<dialog data-description="When autofocus is not p...
+PASS show: autofocus inside a shadow tree must be ignored: focusable element before the shadow tree
+PASS showModal: autofocus inside a shadow tree must be ignored: focusable element before the shadow tree
+PASS show: autofocus inside a shadow tree must be ignored: focusable element after the shadow tree
+PASS showModal: autofocus inside a shadow tree must be ignored: focusable element after the shadow tree
+
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-focus-shadow.html (0 => 286159)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-focus-shadow.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-focus-shadow.html 2021-11-25 06:59:55 UTC (rev 286159)
@@ -0,0 +1,77 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<script src=""
+<script src=""
+<body>
+
+<dialog data-description="When autofocus is not present, the first focusable shadow-including descendant must be focused">
+ <template class="turn-into-shadow-tree">
+ <button disabled>Non-focusable</button>
+ <button tabindex="-1" class="focus-me">Focusable</button>
+ <button disabled>Non-focusable</button>
+ </template>
+</dialog>
+
+<dialog data-description="autofocus outside a shadow tree must take precedence over earlier in-shadow-tree focusable elements">
+ <button disabled>Non-focusable</button>
+ <template class="turn-into-shadow-tree">
+ <button tabindex="-1">Focusable</button>
+ </template>
+ <button tabindex="-1" autofocus>Focusable</button>
+</dialog>
+
+<dialog data-description="autofocus inside a shadow tree must be ignored: no focusable elements outside the shadow tree">
+ <template class="turn-into-shadow-tree">
+ <button tabindex="-1" class="focus-me">Focusable</button>
+ <button tabindex="-1" autofocus>Focusable</button>
+ <button tabindex="-1">Focusable</button>
+ </template>
+</dialog>
+
+<dialog data-description="autofocus inside a shadow tree must be ignored: focusable element before the shadow tree">
+ <button tabindex="-1" class="focus-me">Focusable</button>
+ <template class="turn-into-shadow-tree">
+ <button tabindex="-1">Focusable</button>
+ <button tabindex="-1" autofocus>Focusable</button>
+ <button tabindex="-1">Focusable</button>
+ </template>
+</dialog>
+
+<dialog data-description="autofocus inside a shadow tree must be ignored: focusable element after the shadow tree">
+ <template class="turn-into-shadow-tree">
+ <button tabindex="-1">Focusable</button>
+ <button tabindex="-1" autofocus>Focusable</button>
+ <button tabindex="-1">Focusable</button>
+ </template>
+ <button tabindex="-1" class="focus-me">Focusable</button>
+</dialog>
+
+<script>
+for (const template of document.querySelectorAll(".turn-into-shadow-tree")) {
+ const div = document.createElement("div");
+ div.attachShadow({ mode: "open" });
+ div.shadowRoot.append(template.content);
+ template.replaceWith(div);
+}
+
+for (const dialog of document.querySelectorAll("dialog")) {
+ for (const method of ["show", "showModal"]) {
+ test(t => {
+ dialog[method]();
+ t.add_cleanup(() => dialog.close());
+
+ const expectedFocusOutsideShadowTree = dialog.querySelector(".focus-me");
+ if (expectedFocusOutsideShadowTree) {
+ assert_equals(document.activeElement, expectedFocusOutsideShadowTree);
+ } else {
+ const shadowHost = dialog.querySelector("div");
+ const expectedFocusInsideShadowTree = shadowHost.shadowRoot.querySelector(".focus-me");
+ assert_not_equals(expectedFocusInsideShadowTree, "Precondition check: the test was set up to expect a focused element, either outside the shadow tree or inside");
+
+ assert_equals(document.activeElement, shadowHost);
+ assert_equals(shadowHost.shadowRoot.activeElement, expectedFocusInsideShadowTree);
+ }
+ }, `${method}: ${dialog.dataset.description}`);
+ }
+}
+</script>
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/w3c-import.log (286158 => 286159)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/w3c-import.log 2021-11-25 06:41:08 UTC (rev 286158)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/w3c-import.log 2021-11-25 06:59:55 UTC (rev 286159)
@@ -41,6 +41,8 @@
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-cancel-with-select.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-close.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-enabled.html
+/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-focus-shadow-delegatesfocus.html
+/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-focus-shadow.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-focusing-steps-disconnected.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-focusing-steps-inert.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-focusing-steps-prevent-autofocus.html