| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src='../resources/testharness.js'></script> |
| 3 <script src='../resources/testharnessreport.js'></script> |
| 4 <script src="resources/shadow-dom.js"></script> |
| 5 <div id='wrapper'> |
| 6 <div id='node-in-document' tabindex=1></div> |
| 7 <div id='shadow-host-1'> |
| 8 <template data-mode='open'> |
| 9 <div id='shadow-host-2'> |
| 10 <template data-mode='open'> |
| 11 <div id='child-in-shadow-root-2' tabindex=1></div> |
| 12 </template> |
| 13 </div> |
| 14 <div id='child-in-shadow-root-1' tabindex=1></div> |
| 15 <slot></slot> |
| 16 </template> |
| 17 <div id='slotted-child' tabindex=1></div> |
| 18 </div> |
| 19 </div> |
| 20 <script> |
| 21 'use strict'; |
| 22 convertTemplatesToShadowRootsWithin(wrapper); |
| 23 |
| 24 const nodeInDocument = document.querySelector('#node-in-document'); |
| 25 const slottedChild = document.querySelector('#slotted-child'); |
| 26 |
| 27 const shadowHost1 = document.querySelector('#shadow-host-1'); |
| 28 const shadowRoot1 = shadowHost1.shadowRoot; |
| 29 const childInShadowRoot1 = shadowRoot1.querySelector('#child-in-shadow-root-1'); |
| 30 |
| 31 const shadowHost2 = shadowRoot1.querySelector('#shadow-host-2'); |
| 32 const shadowRoot2 = shadowHost2.shadowRoot; |
| 33 const childInShadowRoot2 = shadowRoot2.querySelector('#child-in-shadow-root-2'); |
| 34 |
| 35 test(() => { |
| 36 nodeInDocument.focus(); |
| 37 assert_equals(document.activeElement, nodeInDocument); |
| 38 assert_equals(shadowRoot1.activeElement, null); |
| 39 assert_equals(shadowRoot2.activeElement, null); |
| 40 }, "activeElement for a node in a document"); |
| 41 |
| 42 test(() => { |
| 43 slottedChild.focus(); |
| 44 assert_equals(document.activeElement, slottedChild); |
| 45 assert_equals(shadowRoot1.activeElement, null); |
| 46 assert_equals(shadowRoot2.activeElement, null); |
| 47 }, "activeElement for a slotted child"); |
| 48 |
| 49 test(() => { |
| 50 childInShadowRoot1.focus(); |
| 51 assert_equals(document.activeElement, shadowHost1); |
| 52 assert_equals(shadowRoot1.activeElement, childInShadowRoot1); |
| 53 assert_equals(shadowRoot2.activeElement, null); |
| 54 }, "activeElement for a node in a shadow tree"); |
| 55 |
| 56 test(() => { |
| 57 childInShadowRoot2.focus(); |
| 58 assert_equals(document.activeElement, shadowHost1); |
| 59 assert_equals(shadowRoot1.activeElement, shadowHost2); |
| 60 assert_equals(shadowRoot2.activeElement, childInShadowRoot2); |
| 61 }, "activeElement for a node in a nested shadow tree"); |
| 62 </script> |
| OLD | NEW |