| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src='../../resources/testharness.js'></script> |
| 3 <script src='../../resources/testharnessreport.js'></script> |
| 4 <!-- This test is testing unspecified behavior of using Shadow DOM in <dialog>. |
| 5 See crbug/383230 and https://github.com/whatwg/html/issue/2393 . --> |
| 6 <input id="outer"> |
| 7 |
| 8 <dialog id="dlg"> |
| 9 <div id="host"></div> |
| 10 <button id="btn"></button> |
| 11 </dialog> |
| 12 |
| 13 <dialog id="dlg2"> |
| 14 <div id="host2"><input id="inner2"></div> |
| 15 <button id="btn2"></button> |
| 16 </dialog> |
| 17 <script> |
| 18 'use strict'; |
| 19 |
| 20 host.attachShadow({mode: 'open'}).innerHTML = '<input id="inner">'; |
| 21 let inner = host.shadowRoot.querySelector('#inner'); |
| 22 |
| 23 test(() => { |
| 24 outer.focus(); |
| 25 assert_equals(document.activeElement, outer); |
| 26 |
| 27 dlg.show(); |
| 28 assert_equals(document.activeElement, host); |
| 29 assert_equals(host.shadowRoot.activeElement, inner); |
| 30 dlg.close(); |
| 31 |
| 32 outer.focus(); |
| 33 assert_equals(document.activeElement, outer); |
| 34 |
| 35 dlg.showModal(); |
| 36 assert_equals(document.activeElement, host); |
| 37 assert_equals(host.shadowRoot.activeElement, inner); |
| 38 dlg.close(); |
| 39 }, "Dialog focusing steps should be applied to elements inside ShadowRoot."); |
| 40 |
| 41 |
| 42 host2.attachShadow({mode: 'open'}).innerHTML = '<slot></slot>'; |
| 43 |
| 44 test(() => { |
| 45 outer.focus(); |
| 46 assert_equals(document.activeElement, outer); |
| 47 |
| 48 dlg2.show(); |
| 49 assert_equals(document.activeElement, inner2); |
| 50 dlg2.close(); |
| 51 |
| 52 outer.focus(); |
| 53 assert_equals(document.activeElement, outer); |
| 54 |
| 55 dlg2.showModal(); |
| 56 assert_equals(document.activeElement, inner2); |
| 57 dlg2.close(); |
| 58 }, "Dialog focusing steps should be applied to slotted elements in Shadow DOM.")
; |
| 59 </script> |
| OLD | NEW |