focus-within-shadow.html (853B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <link rel="author" href="mailto:masonf@chromium.org"> 4 <link rel="help" href="https://crbug.com/1300584"> 5 <script src='/resources/testharness.js'></script> 6 <script src='/resources/testharnessreport.js'></script> 7 8 <div id=host> 9 <template shadowrootmode=open> 10 <button><slot></slot></button> 11 </template> 12 <span>Content</span> 13 </div> 14 15 <script> 16 const host = document.getElementById('host'); 17 test(() => { 18 const shadowButton = host.shadowRoot.querySelector('button'); 19 shadowButton.focus(); 20 assert_equals(document.activeElement,host,'nodes within shadow DOM aren\'t exposed'); 21 host.textContent = 'New Content'; 22 assert_equals(document.activeElement,host,'Clearing light DOM shouldn\'t clear focus'); 23 },'Don\'t clear focus within shadow root if light DOM children are cleared'); 24 </script>