From 8dd16259287f58f9273002717ec4d27e97127719 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:43:14 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- .../tests/shadow-dom/declarative/WEB_FEATURES.yml | 3 + .../tests/shadow-dom/declarative/gethtml.html | 31 ++-- .../focus-navigation-slot-nested-2levels.html | 1 + .../focus-navigation-slots-in-slot.html | 1 + .../focus-navigation-with-delegatesFocus.html | 1 + .../focus-navigation/focus-navigation.html | 1 + .../tentative/grid-order-on-shadow-host.html | 43 ++++++ .../tentative/grid-order-with-iframe.html | 33 +++++ .../tentative/grid-order-with-nested-grids.html | 72 +++++++++ .../tentative/grid-order-with-popover.html | 64 ++++++++ .../tentative/grid-order-with-slots.html | 164 +++++++++++++++++++++ .../reading-order/tentative/grid-order.html | 89 +++++++++++ .../focus-navigation/resources/focus-utils.js | 41 +++++- 13 files changed, 514 insertions(+), 30 deletions(-) create mode 100644 testing/web-platform/tests/shadow-dom/declarative/WEB_FEATURES.yml create mode 100644 testing/web-platform/tests/shadow-dom/focus-navigation/reading-order/tentative/grid-order-on-shadow-host.html create mode 100644 testing/web-platform/tests/shadow-dom/focus-navigation/reading-order/tentative/grid-order-with-iframe.html create mode 100644 testing/web-platform/tests/shadow-dom/focus-navigation/reading-order/tentative/grid-order-with-nested-grids.html create mode 100644 testing/web-platform/tests/shadow-dom/focus-navigation/reading-order/tentative/grid-order-with-popover.html create mode 100644 testing/web-platform/tests/shadow-dom/focus-navigation/reading-order/tentative/grid-order-with-slots.html create mode 100644 testing/web-platform/tests/shadow-dom/focus-navigation/reading-order/tentative/grid-order.html (limited to 'testing/web-platform/tests/shadow-dom') diff --git a/testing/web-platform/tests/shadow-dom/declarative/WEB_FEATURES.yml b/testing/web-platform/tests/shadow-dom/declarative/WEB_FEATURES.yml new file mode 100644 index 0000000000..4e31ed4962 --- /dev/null +++ b/testing/web-platform/tests/shadow-dom/declarative/WEB_FEATURES.yml @@ -0,0 +1,3 @@ +features: +- name: declarative-shadow-dom + files: "**" diff --git a/testing/web-platform/tests/shadow-dom/declarative/gethtml.html b/testing/web-platform/tests/shadow-dom/declarative/gethtml.html index d950ca7734..ff70653477 100644 --- a/testing/web-platform/tests/shadow-dom/declarative/gethtml.html +++ b/testing/web-platform/tests/shadow-dom/declarative/gethtml.html @@ -29,7 +29,6 @@ function testElementType(allowsShadowDom, elementType, runGetHTMLOnShadowRoot, } let shadowRoot; - const isOpen = mode === 'open'; let initDict = {mode: mode, delegatesFocus: delegatesFocus, clonable}; let expectedSerializable = null; switch (serializable) { @@ -47,12 +46,8 @@ function testElementType(allowsShadowDom, elementType, runGetHTMLOnShadowRoot, `shadowrootmode=${mode}${delegatesAttr}${serializableAttr}` + `${clonableAttr}>`; wrapper.setHTMLUnsafe(html); - if (isOpen) { - shadowRoot = wrapper.firstElementChild.shadowRoot; - } else { - // For closed shadow root, we rely on the behavior of attachShadow to return it to us - shadowRoot = wrapper.firstElementChild.attachShadow(initDict); - } + // Get hold of the declarative shadow root in a way that works when its mode is "closed" + shadowRoot = wrapper.firstElementChild.attachShadow(initDict); } else { // Imperative shadow dom const element = document.createElement(elementType); @@ -78,22 +73,14 @@ function testElementType(allowsShadowDom, elementType, runGetHTMLOnShadowRoot, assert_equals(shadowRoot.clonable,clonable); shadowRoot.appendChild(document.createElement('slot')); const emptyElement = `<${elementType}>${lightDOMContent}`; - if (isOpen) { - if (expectedSerializable) { - assert_equals(wrapper.getHTML({serializableShadowRoots: true}), - correctHtml); - assert_equals(wrapper.firstElementChild.getHTML({ - serializableShadowRoots: true}), - `${correctShadowHtml}${lightDOMContent}`); - } else { - assert_equals(wrapper.getHTML({serializableShadowRoots: true}), emptyElement); - } - } else { - // Closed shadow roots should not be returned unless shadowRoots specifically contains the shadow root: + if (expectedSerializable) { assert_equals(wrapper.getHTML({serializableShadowRoots: true}), - emptyElement); - assert_equals(wrapper.getHTML({serializableShadowRoots: true, - shadowRoots: []}), emptyElement); + correctHtml); + assert_equals(wrapper.firstElementChild.getHTML({ + serializableShadowRoots: true}), + `${correctShadowHtml}${lightDOMContent}`); + } else { + assert_equals(wrapper.getHTML({serializableShadowRoots: true}), emptyElement); } // If we provide the shadow root, serialize it, regardless of serializableShadowRoots. assert_equals(wrapper.getHTML({serializableShadowRoots: true, shadowRoots: diff --git a/testing/web-platform/tests/shadow-dom/focus-navigation/focus-navigation-slot-nested-2levels.html b/testing/web-platform/tests/shadow-dom/focus-navigation/focus-navigation-slot-nested-2levels.html index 7d733ea7c2..1b867cc2a9 100644 --- a/testing/web-platform/tests/shadow-dom/focus-navigation/focus-navigation-slot-nested-2levels.html +++ b/testing/web-platform/tests/shadow-dom/focus-navigation/focus-navigation-slot-nested-2levels.html @@ -1,4 +1,5 @@ + diff --git a/testing/web-platform/tests/shadow-dom/focus-navigation/focus-navigation-slots-in-slot.html b/testing/web-platform/tests/shadow-dom/focus-navigation/focus-navigation-slots-in-slot.html index 39b0806603..3c929de727 100644 --- a/testing/web-platform/tests/shadow-dom/focus-navigation/focus-navigation-slots-in-slot.html +++ b/testing/web-platform/tests/shadow-dom/focus-navigation/focus-navigation-slots-in-slot.html @@ -1,4 +1,5 @@ + diff --git a/testing/web-platform/tests/shadow-dom/focus-navigation/focus-navigation-with-delegatesFocus.html b/testing/web-platform/tests/shadow-dom/focus-navigation/focus-navigation-with-delegatesFocus.html index 64942a109e..e37accbc8e 100644 --- a/testing/web-platform/tests/shadow-dom/focus-navigation/focus-navigation-with-delegatesFocus.html +++ b/testing/web-platform/tests/shadow-dom/focus-navigation/focus-navigation-with-delegatesFocus.html @@ -1,4 +1,5 @@ + diff --git a/testing/web-platform/tests/shadow-dom/focus-navigation/focus-navigation.html b/testing/web-platform/tests/shadow-dom/focus-navigation/focus-navigation.html index 9e593eb100..faf3c34cdb 100644 --- a/testing/web-platform/tests/shadow-dom/focus-navigation/focus-navigation.html +++ b/testing/web-platform/tests/shadow-dom/focus-navigation/focus-navigation.html @@ -1,4 +1,5 @@ + diff --git a/testing/web-platform/tests/shadow-dom/focus-navigation/reading-order/tentative/grid-order-on-shadow-host.html b/testing/web-platform/tests/shadow-dom/focus-navigation/reading-order/tentative/grid-order-on-shadow-host.html new file mode 100644 index 0000000000..a48eda1b57 --- /dev/null +++ b/testing/web-platform/tests/shadow-dom/focus-navigation/reading-order/tentative/grid-order-on-shadow-host.html @@ -0,0 +1,43 @@ + + +CSS Display: reading-order-items with value grid-order on shadow host + + + + + + + + + + + + +
+
+ +
+
+ +
+
+ +
+
+ + diff --git a/testing/web-platform/tests/shadow-dom/focus-navigation/reading-order/tentative/grid-order-with-iframe.html b/testing/web-platform/tests/shadow-dom/focus-navigation/reading-order/tentative/grid-order-with-iframe.html new file mode 100644 index 0000000000..87b9e0a83d --- /dev/null +++ b/testing/web-platform/tests/shadow-dom/focus-navigation/reading-order/tentative/grid-order-with-iframe.html @@ -0,0 +1,33 @@ + + +CSS Display: reading-order-items with value grid-order on iframe + + + + + + + + + + + + +
+ +
+ + +
+ +
+ + diff --git a/testing/web-platform/tests/shadow-dom/focus-navigation/reading-order/tentative/grid-order-with-nested-grids.html b/testing/web-platform/tests/shadow-dom/focus-navigation/reading-order/tentative/grid-order-with-nested-grids.html new file mode 100644 index 0000000000..d3da6682a3 --- /dev/null +++ b/testing/web-platform/tests/shadow-dom/focus-navigation/reading-order/tentative/grid-order-with-nested-grids.html @@ -0,0 +1,72 @@ + + +CSS Display: reading-order-items with value grid-order in nested grids + + + + + + + + + + + + +
+
+
Div 1 + + +
+
Div 2 + +
+
Div 3 + + +
+
+
+ +
+
+
Div 1 + + +
+
Div 2 + +
+
Div 3 + + +
+
+
+ +
+
A +
B +
C
+
D
+
+
+
+ + diff --git a/testing/web-platform/tests/shadow-dom/focus-navigation/reading-order/tentative/grid-order-with-popover.html b/testing/web-platform/tests/shadow-dom/focus-navigation/reading-order/tentative/grid-order-with-popover.html new file mode 100644 index 0000000000..2e98c04157 --- /dev/null +++ b/testing/web-platform/tests/shadow-dom/focus-navigation/reading-order/tentative/grid-order-with-popover.html @@ -0,0 +1,64 @@ + + +CSS Display: reading-order-items with value grid-order + + + + + + + + + + + + +
+ + + +
+
+ + + +
+ + \ No newline at end of file diff --git a/testing/web-platform/tests/shadow-dom/focus-navigation/reading-order/tentative/grid-order-with-slots.html b/testing/web-platform/tests/shadow-dom/focus-navigation/reading-order/tentative/grid-order-with-slots.html new file mode 100644 index 0000000000..3045001e1d --- /dev/null +++ b/testing/web-platform/tests/shadow-dom/focus-navigation/reading-order/tentative/grid-order-with-slots.html @@ -0,0 +1,164 @@ + + +CSS Display: reading-order-items with value grid-order in Shadow DOM + + + + + + + + + + + + + + +
+ + + +
+
+
+ + + + + + + +
+ + + + + + + +
+ + + + + + +
+ + + +
+
+
+ + +
+ + + + + +
+ + + + + +
+
+ + + + + + +
+ + + + + + +
+ + diff --git a/testing/web-platform/tests/shadow-dom/focus-navigation/reading-order/tentative/grid-order.html b/testing/web-platform/tests/shadow-dom/focus-navigation/reading-order/tentative/grid-order.html new file mode 100644 index 0000000000..1b86ab0b25 --- /dev/null +++ b/testing/web-platform/tests/shadow-dom/focus-navigation/reading-order/tentative/grid-order.html @@ -0,0 +1,89 @@ + + +CSS Display: reading-order-items with value grid-order + + + + + + + + + + + + +
+
+ + + +
+
+ + +
+
+ +
+
+ + + +
+
+ + +
+
+ +
+
+ + + +
+
+ + + +
+
+ +
+
+
+ + +
+ + +
+
+
+
+ +
+
+ +
+ + +
+ +
+
+ + diff --git a/testing/web-platform/tests/shadow-dom/focus-navigation/resources/focus-utils.js b/testing/web-platform/tests/shadow-dom/focus-navigation/resources/focus-utils.js index f593267cc3..f4056dc168 100644 --- a/testing/web-platform/tests/shadow-dom/focus-navigation/resources/focus-utils.js +++ b/testing/web-platform/tests/shadow-dom/focus-navigation/resources/focus-utils.js @@ -1,17 +1,27 @@ 'use strict'; -function navigateFocusForward() { - // TAB = '\ue004' - return test_driver.send_keys(document.body, "\ue004"); +function waitForRender() { + return new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve))); +} + +async function navigateFocusForward() { + await waitForRender(); + const kTab = '\uE004'; + await new test_driver.send_keys(document.documentElement,kTab); + await waitForRender(); } async function navigateFocusBackward() { - return new test_driver.Actions() - .keyDown('\uE050') - .keyDown('\uE004') - .keyUp('\uE004') - .keyUp('\uE050') + await waitForRender(); + const kShift = '\uE008'; + const kTab = '\uE004'; + await new test_driver.Actions() + .keyDown(kShift) + .keyDown(kTab) + .keyUp(kTab) + .keyUp(kShift) .send(); + await waitForRender(); } // If shadow root is open, can find element using element path @@ -162,3 +172,18 @@ async function assert_focus_navigation_bidirectional_with_shadow_root(elements) await assert_focus_navigation_backward_with_shadow_root(elements); } +// This Promise will run each test case that is: +// 1. Wrapped in an element with class name "test-case". +// 2. Has data-expect attribute be an ordered list of elements to focus. +// 3. Has data-description attribute be a string explaining the test. +// e.g
+async function runFocusTestCases() { + const testCases = Array.from(document.querySelectorAll('.test-case')); + for (let testCase of testCases) { + promise_test(async () => { + const expected = testCase.dataset.expect.split(','); + await assert_focus_navigation_forward(expected); + }, testCase.dataset.description); + } +} -- cgit v1.2.3