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

Side by Side Diff: LayoutTests/fast/dom/shadow/focus-slide-on-shadow-host.html

Issue 1144953007: Remove tabStop feature (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 5 years, 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../../../resources/js-test.js"></script>
3 <script src="resources/shadow-dom.js"></script>
4 <body>
5 <pre id="console"></pre>
6 <input id="defaultFocus">
7 <div id="sandbox"></div>
8 </body>
9 <script>
10 description('Click inside focusable shadow host should focus the host.');
11
12 function prepareDOMTree(parent)
13 {
14 parent.appendChild(
15 createDOM('div', {'id': 'shadowHost', 'tabindex': '0'},
16 createShadowRoot(
17 createDOM('div', {'id': 'innerDiv'},
18 document.createTextNode('Blink')),
19 createDOM('input', {'id': 'inputA'}),
20 createDOM('input', {'id': 'inputB'}))));
21
22 parent.offsetLeft;
23 }
24
25 var host;
26 var innerDiv;
27 var inputA;
28 var inputB;
29
30 function clickOn(el) {
31 eventSender.mouseMoveTo(el.offsetLeft + 8, el.offsetTop + 8);
32 eventSender.mouseDown();
33 eventSender.mouseUp();
34 }
35
36 function resetFocus() {
37 document.querySelector('#defaultFocus').focus();
38 }
39
40 function checkInnermostActiveElement(id) {
41 if (isInnermostActiveElement(id))
42 debug('PASS innermost active element is ' + id);
43 }
44
45 function runTest() {
46 var sandbox = document.querySelector('#sandbox');
47 prepareDOMTree(sandbox);
48 resetFocus();
49
50 host = getNodeInTreeOfTrees('shadowHost');
51 innerDiv = getNodeInTreeOfTrees('shadowHost/innerDiv');
52 inputA = getNodeInTreeOfTrees('shadowHost/inputA');
53 inputB = getNodeInTreeOfTrees('shadowHost/inputB');
54
55 debug('click on inner div should focus shadow host');
56 clickOn(innerDiv);
57 checkInnermostActiveElement('shadowHost');
58
59 inputA.focus();
60 checkInnermostActiveElement('shadowHost/inputA');
61 clickOn(innerDiv);
62 checkInnermostActiveElement('shadowHost');
63
64 inputB.focus();
65 clickOn(innerDiv);
66 checkInnermostActiveElement('shadowHost');
67
68 debug('click on inner div should focus inner focusable (with tabStop = false )');
69 host.tabStop = false;
70 resetFocus();
71
72 inputA.value = 'wonderful'; // len = 9
73 inputB.value = 'beautiful';
74
75 clickOn(innerDiv);
76 checkInnermostActiveElement('shadowHost/inputA');
77
78 // If focus slides from shadow host, all the content will be selected.
79 shouldBe('inputA.selectionStart', '0');
80 shouldBe('inputA.selectionEnd', '9');
81
82 // Clicking on non-focusable area inside shadow should not change the focus state.
83 clickOn(innerDiv);
84 checkInnermostActiveElement('shadowHost/inputA');
85 shouldBe('inputA.selectionStart', '0');
86 shouldBe('inputA.selectionEnd', '9');
87
88 // Clicking on focusable directly will cause the element to be focused.
89 clickOn(inputA);
90 checkInnermostActiveElement('shadowHost/inputA');
91 clickOn(innerDiv);
92 checkInnermostActiveElement('shadowHost/inputA');
93 shouldBe('inputA.selectionStart', '1');
94 shouldBe('inputA.selectionEnd', '1');
95
96 clickOn(inputB);
97 checkInnermostActiveElement('shadowHost/inputB');
98 clickOn(innerDiv);
99 checkInnermostActiveElement('shadowHost/inputB');
100 shouldBe('inputB.selectionStart', '1');
101 shouldBe('inputB.selectionEnd', '1');
102 }
103
104 if (!window.eventSender)
105 testFailed('');
106
107 window.onload = runTest;
108 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698