focus-navigation-slot-fallback.html (2175B)
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 -> j2 -> [s1]]<br> 13 <b>slot #s1: [k1 -> [x-bar] -> k0 -> [s2] -> [s3]]</b><br> 14 x-bar's shadow tree: [m1 -> m2]<br> 15 slot #s2: [i1 -> i2]<br> 16 <b>slot #s3: [l1]<b><br><br> 17 <b>v1 ideal nav forward: [i0 -> j1 -> j2 -> k1 -> x-bar -> m1 -> m2 -> k0 -> i1 -> i2 -> l1]</b><br> 18 </p> 19 20 <input id='i0' tabindex=0 value='i0'> 21 <div id='x-foo'> 22 <input id='i2' slot='s2' tabindex=2 value='i2'> 23 <input id='i1' slot='s2' tabindex=1 value='i1'> 24 <template data-mode='open'> 25 <input id='j1' tabindex=1 value='j1'> 26 <slot id='s1' name='s1'> <!-- This slot does not have any assigned elements --> 27 <input id='k0' tabindex=0 value='k0'> 28 <input id='k1' tabindex=1 value='k1'> 29 <slot id='s2' name='s2'> 30 <input id='should-be-ignored'> 31 </slot> 32 <slot id='s3' name='s3'> <!-- This slot does not have any assigned elements --> 33 <input id='l1' value='l1'> 34 </slot> 35 <div id='x-bar' tabindex=2> 36 <template data-mode='open'> 37 <input id='m2' value='m2' tabindex=2> 38 <input id='m1' value='m1' tabindex=1> 39 </template> 40 </div> 41 </slot> 42 <input id='j2' tabindex=2 value='j2'> 43 </template> 44 </div> 45 46 <script> 47 'use strict'; 48 49 promise_test(async () => { 50 let xfoo = document.getElementById('x-foo'); 51 convertTemplatesToShadowRootsWithin(xfoo); 52 53 let elements = [ 54 'i0', 55 'x-foo/j1', 56 'x-foo/j2', 57 'x-foo/k1', 58 'x-foo/x-bar', 59 'x-foo/x-bar/m1', 60 'x-foo/x-bar/m2', 61 'x-foo/k0', 62 'i1', 63 'i2', 64 'x-foo/l1' 65 ]; 66 67 await assert_focus_navigation_bidirectional(elements); 68 }, 'Focus should jump to fallback elements when a slot does not have any assigned nodes.'); 69 </script>