focus-navigation-slots.html (2069B)
1 <!DOCTYPE html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <script src="/resources/testdriver.js"></script> 5 <script src="/resources/testdriver-vendor.js"></script> 6 <script src="/resources/testdriver-actions.js"></script> 7 <script src="resources/shadow-dom.js"></script> 8 <script src="resources/focus-utils.js"></script> 9 <div id="log"></div> 10 <p> 11 document tree: [i0 -> [x-foo]]<br> 12 x-foo's shadow tree: [j1 -> [s1] -> [s2] -> j2 ->[x-bar]]<br> 13 x-bar's shadow tree: [k1 -> [s3]]<br> 14 slot #s1: [i1 -> i2]<br> 15 slot #s2: [i3]<br> 16 slot #s3: [[s4]]<br> 17 slot #s4: [i4 -> i5]<br><br> 18 <b>v1 ideal nav forward: [i0 -> j1 -> i1 -> i2 -> i3 -> j2 -> x-bar -> k1 -> i4 -> i5]</b><br> 19 </p> 20 21 <input id="i0" tabindex=0 value="i0"> 22 <div id="x-foo"> 23 <input id="i2" slot="s1" tabindex=2 value="i2"> 24 <input id="i1" slot="s1" tabindex=1 value="i1"> 25 <input id="i3" slot="s2" tabindex=3 value="i3"> 26 <input id="i4" slot="s4" tabindex=4 value="i4"> 27 <input id="i5" slot="s4" tabindex=5 value="i5"> 28 <template data-mode="open"> 29 <div id="x-bar" tabindex=5> 30 <slot id="s4" name="s4" slot="s3"></slot> 31 <template data-mode="open"> 32 <slot id="s3" name="s3" tabindex=2></slot> 33 <input id="k1" tabindex=1 value="k1"> 34 </template> 35 </div> 36 <input id="j1" tabindex=1 value="j1"> 37 <slot id="s2" name="s2" tabindex=3></slot> 38 <slot id="s1" name="s1" tabindex=2></slot> 39 <input id="j2" tabindex=4 value="j2"> 40 </template> 41 </div> 42 43 <script> 44 'use strict'; 45 46 promise_test(async () => { 47 let xfoo = document.getElementById('x-foo'); 48 convertTemplatesToShadowRootsWithin(xfoo); 49 50 let elements = [ 51 'i0', 52 'x-foo/j1', 53 'i1', 54 'i2', 55 'i3', 56 'x-foo/j2', 57 'x-foo/x-bar', 58 'x-foo/x-bar/k1', 59 'i4', 60 'i5' 61 ]; 62 63 await assert_focus_navigation_bidirectional(elements); 64 }, 'Focus should cover assigned elements of an assigned slot, as well as elements that are directly assigned to a slot.'); 65 </script>