OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../../../resources/js-test.js"></script> | 2 <script src="../../../resources/js-test.js"></script> |
3 <template id="ShadowTemplate"> | 3 <template id="ShadowTemplate"> |
4 <ul> | 4 <ul> |
5 <li tabindex="0" id="one">One</li> | 5 <li tabindex="0" id="one">One</li> |
6 <li tabindex="0" id="two">Two</li> | 6 <li tabindex="0" id="two">Two</li> |
7 <li id="three">Three</li> | 7 <li id="three">Three</li> |
8 </ul> | 8 </ul> |
9 </template> | 9 </template> |
10 <template id="NoFocusableShadowTemplate"> | 10 <template id="NoFocusableShadowTemplate"> |
(...skipping 11 matching lines...) Expand all Loading... |
22 <x-shadow-nofocus id="xshadow3"></x-shadow-nofocus> | 22 <x-shadow-nofocus id="xshadow3"></x-shadow-nofocus> |
23 <x-shadow-nofocus id="xshadow4" tabindex="0"></x-shadow-nofocus> | 23 <x-shadow-nofocus id="xshadow4" tabindex="0"></x-shadow-nofocus> |
24 <x-shadow-nofocus id="xshadow5" tabindex="0" delegatesFocus></x-shadow-nofocus> | 24 <x-shadow-nofocus id="xshadow5" tabindex="0" delegatesFocus></x-shadow-nofocus> |
25 </body> | 25 </body> |
26 <script> | 26 <script> |
27 function registerShadow(templateId, tagName) { | 27 function registerShadow(templateId, tagName) { |
28 var template = document.getElementById(templateId); | 28 var template = document.getElementById(templateId); |
29 var proto = Object.create(HTMLElement.prototype); | 29 var proto = Object.create(HTMLElement.prototype); |
30 proto.createdCallback = function() { | 30 proto.createdCallback = function() { |
31 var delegatesFocus = this.hasAttribute('delegatesFocus'); | 31 var delegatesFocus = this.hasAttribute('delegatesFocus'); |
32 this.createShadowRoot({'delegatesFocus': delegatesFocus}).appendChild( | 32 this.attachShadow({'delegatesFocus': delegatesFocus}).appendChild( |
33 document.importNode(template.content, true)); | 33 document.importNode(template.content, true)); |
34 }; | 34 }; |
35 document.registerElement(tagName, { prototype: proto }); | 35 document.registerElement(tagName, { prototype: proto }); |
36 } | 36 } |
37 | 37 |
38 registerShadow('ShadowTemplate', 'x-shadow'); | 38 registerShadow('ShadowTemplate', 'x-shadow'); |
39 registerShadow('NoFocusableShadowTemplate', 'x-shadow-nofocus'); | 39 registerShadow('NoFocusableShadowTemplate', 'x-shadow-nofocus'); |
40 | 40 |
41 debug('xshadow0 is not focusable without tabindex.'); | 41 debug('xshadow0 is not focusable without tabindex.'); |
42 xshadow0.focus(); | 42 xshadow0.focus(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 debug('If any element including shadow host is not focusable, focus doesn\'t cha
nge.'); | 76 debug('If any element including shadow host is not focusable, focus doesn\'t cha
nge.'); |
77 xshadow3.focus(); | 77 xshadow3.focus(); |
78 shouldBeEqualToString('document.activeElement.id', 'input0'); | 78 shouldBeEqualToString('document.activeElement.id', 'input0'); |
79 | 79 |
80 debug('If no element is focusable within shadow root, but the shadow host is foc
usable, then the host gets focus regardless of delegatesFocus.'); | 80 debug('If no element is focusable within shadow root, but the shadow host is foc
usable, then the host gets focus regardless of delegatesFocus.'); |
81 xshadow4.focus(); | 81 xshadow4.focus(); |
82 shouldBeEqualToString('document.activeElement.id', 'xshadow4'); | 82 shouldBeEqualToString('document.activeElement.id', 'xshadow4'); |
83 xshadow5.focus(); | 83 xshadow5.focus(); |
84 shouldBeEqualToString('document.activeElement.id', 'xshadow5'); | 84 shouldBeEqualToString('document.activeElement.id', 'xshadow5'); |
85 </script> | 85 </script> |
OLD | NEW |