OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <script src="../../../resources/testharness.js"></script> |
| 5 <script src="../../../resources/testharnessreport.js"></script> |
| 6 </head> |
| 7 <body> |
| 8 |
| 9 <div id="shadow-host"> |
| 10 <button slot="slot-1" id="button-1">Button 1 (inert)</button> |
| 11 <button slot="slot-2" id="button-2">Button 2 (not inert)</button> |
| 12 </div> |
| 13 <script> |
| 14 const shadowHost = document.getElementById('shadow-host'); |
| 15 const shadowRoot = shadowHost.attachShadow({ mode: 'open' }); |
| 16 const inertDiv = document.createElement('div'); |
| 17 inertDiv.inert = true; |
| 18 shadowRoot.appendChild(inertDiv); |
| 19 const slot1 = document.createElement('slot'); |
| 20 slot1.name = 'slot-1'; |
| 21 inertDiv.appendChild(slot1); |
| 22 const slot2 = document.createElement('slot'); |
| 23 slot2.name = 'slot-2'; |
| 24 shadowRoot.appendChild(slot2); |
| 25 |
| 26 function testCanFocus(selector, canFocus) { |
| 27 const element = document.querySelector(selector); |
| 28 let focusedElement = null; |
| 29 element.addEventListener('focus', function() { focusedElement = element; }
, false); |
| 30 element.focus(); |
| 31 if (canFocus) |
| 32 assert_true(focusedElement === element); |
| 33 else |
| 34 assert_false(focusedElement === element); |
| 35 } |
| 36 |
| 37 testCanFocus('#button-1', false); |
| 38 testCanFocus('#button-2', true); |
| 39 done(); |
| 40 </script> |
| 41 </body> |
| 42 </html> |
OLD | NEW |