Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/shadow/focus-method-with-delegatesFocus.html

Issue 1408443003: Add Element.attachShadow under the ShadowDOMV1 runtime flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rewrite a test Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698