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

Side by Side Diff: LayoutTests/imported/web-platform-tests/shadow-dom/events/retargeting-focus-events/test-001.html

Issue 560893005: First checked-in import of the W3C's test suites. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add new expectations for newly failing w3c tests Created 6 years, 3 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 <!--
3 Distributed under both the W3C Test Suite License [1] and the W3C
4 3-clause BSD License [2]. To contribute to a W3C Test Suite, see the
5 policies and contribution forms [3].
6
7 [1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license
8 [2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license
9 [3] http://www.w3.org/2004/10/27-testcases
10 -->
11 <html>
12 <head>
13 <title>Shadow DOM Test: A_05_03_01</title>
14 <link rel="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
15 <link rel="help" href="http://www.w3.org/TR/2013/WD-shadow-dom-20130514/#retarge ting-focus-events">
16 <meta name="assert" content="Retargeting focus events:The focus, DOMFocusIn, blu r, and DOMFocusOut events must be treated in the same way as events with a relat edTarget, where the corresponding node that is losing focus as a result of targe t gaining focus or the node that is gaining focus, and thus causing the blurring of target acts as the related target">
17 <script src="../../../../../resources/testharness.js"></script>
18 <script src="../../../../../resources/testharnessreport.js"></script>
19 <script src="../../testcommon.js"></script>
20 <link rel="stylesheet" href="../../../../../resources/testharness.css">
21 </head>
22 <body>
23 <div id="log"></div>
24 <script>
25 //blur and focus events are not bubbling. So this test tests only DOMFocusIn and DOMFocusOut
26 //which do bubble
27
28 //test DOMFocusOut event
29 var A_05_03_01_T01 = async_test('A_05_03_01_T01');
30
31 A_05_03_01_T01.step(unit(function (ctx) {
32
33 var d = newRenderedHTMLDocument(ctx);
34
35 var host = d.createElement('div');
36 host.setAttribute('style', 'height:50%; width:100%');
37 host.setAttribute('id', 'host');
38 d.body.appendChild(host);
39
40 //Shadow root to play with
41 var s = host.createShadowRoot();
42
43 var inp1 = d.createElement('input');
44 inp1.setAttribute('id', 'inp1');
45 inp1.setAttribute('type', 'checkbox');
46 s.appendChild(inp1);
47
48 var inp2 = d.createElement('input');
49 inp2.setAttribute('id', 'inp2');
50 inp2.setAttribute('type', 'checkbox');
51 d.body.appendChild(inp2);
52
53 s.addEventListener('DOMFocusOut', A_05_03_01_T01.step_func(function(event) {
54 assert_equals(event.target.getAttribute('id'), 'inp1', 'Inside shadow tr ee: Wrong target');
55 }), false);
56
57 d.body.addEventListener('DOMFocusOut', A_05_03_01_T01.step_func(function(eve nt) {
58 assert_equals(event.target.getAttribute('id'), 'host', 'Inside shadow tr ee: Wrong target');
59 }), false);
60
61 inp1.focus();
62 inp2.focus();
63
64 A_05_03_01_T01.done();
65 }));
66
67
68 //test DOMFocusIn event
69 var A_05_03_01_T02 = async_test('A_05_03_01_T02');
70
71 A_05_03_01_T02.step(unit(function (ctx) {
72
73 var d = newRenderedHTMLDocument(ctx);
74
75 var host = d.createElement('div');
76 host.setAttribute('style', 'height:50%; width:100%');
77 host.setAttribute('id', 'host');
78 d.body.appendChild(host);
79
80 //Shadow root to play with
81 var s = host.createShadowRoot();
82
83 var inp1 = d.createElement('input');
84 inp1.setAttribute('id', 'inp1');
85 inp1.setAttribute('type', 'checkbox');
86 s.appendChild(inp1);
87
88 var inp2 = d.createElement('input');
89 inp2.setAttribute('id', 'inp2');
90 inp2.setAttribute('type', 'checkbox');
91 d.body.appendChild(inp2);
92
93 inp2.focus();
94
95 s.addEventListener('DOMFocusIn', A_05_03_01_T02.step_func(function(event) {
96 assert_equals(event.target.getAttribute('id'), 'inp1', 'Inside shadoe tr ee: Wrong target');
97 }), false);
98
99 d.body.addEventListener('DOMFocusIn', A_05_03_01_T02.step_func(function(even t) {
100 assert_equals(event.target.getAttribute('id'), 'host', 'Outside shadow t ree: Wrong target');
101 }), false);
102
103 inp1.focus();
104
105 A_05_03_01_T02.done();
106 }));
107
108
109 //gaining and loosing focus elements are in the same tree.
110 //DOMFocusIn event should be stopped at shadow boundary
111 var A_05_03_01_T03 = async_test('A_05_03_01_T03');
112
113
114 A_05_03_01_T03.step(unit(function (ctx) {
115
116 var d = newRenderedHTMLDocument(ctx);
117
118 var host = d.createElement('div');
119 host.setAttribute('style', 'height:50%; width:100%');
120 host.setAttribute('id', 'host');
121 d.body.appendChild(host);
122
123 //Shadow root to play with
124 var s = host.createShadowRoot();
125
126 var inp1 = d.createElement('input');
127 inp1.setAttribute('id', 'inp1');
128 inp1.setAttribute('type', 'checkbox');
129 s.appendChild(inp1);
130
131 var inp2 = d.createElement('input');
132 inp2.setAttribute('id', 'inp2');
133 inp2.setAttribute('type', 'checkbox');
134 s.appendChild(inp2);
135
136 inp1.focus();
137
138 d.body.addEventListener('DOMFocusIn', A_05_03_01_T03.step_func(function(even t) {
139 assert_true(false, 'Event should be stopped at Shadow boundary');
140 }), false);
141
142 inp2.focus();
143
144 A_05_03_01_T03.done();
145 }));
146
147
148
149
150 //gaining and loosing focus elements are in the same tree.
151 //DOMFocusOut event should be stopped at shadow boundary
152 var A_05_03_01_T04 = async_test('A_05_03_01_T04');
153
154 A_05_03_01_T04.step(unit(function (ctx) {
155
156 var d = newRenderedHTMLDocument(ctx);
157
158 var host = d.createElement('div');
159 host.setAttribute('style', 'height:50%; width:100%');
160 host.setAttribute('id', 'host');
161 d.body.appendChild(host);
162
163 //Shadow root to play with
164 var s = host.createShadowRoot();
165
166 var inp1 = d.createElement('input');
167 inp1.setAttribute('id', 'inp1');
168 inp1.setAttribute('type', 'checkbox');
169 s.appendChild(inp1);
170
171 var inp2 = d.createElement('input');
172 inp2.setAttribute('id', 'inp2');
173 inp2.setAttribute('type', 'checkbox');
174 s.appendChild(inp2);
175
176 inp1.focus();
177
178 d.body.addEventListener('DOMFocusOut', A_05_03_01_T04.step_func(functio n(event) {
179 assert_true(false, 'Event should be stopped at Shadow boundary') ;
180 }), false);
181
182 inp2.focus();
183
184 A_05_03_01_T04.done();
185 }));
186
187
188
189
190 //Retargeting shouldn't occur for DOM tree nodes distributed
191 //among insertion point. Check DOMFocusOut
192 var A_05_03_01_T05 = async_test('A_05_03_01_T05');
193
194 A_05_03_01_T05.step(unit(function (ctx) {
195
196 var d = newRenderedHTMLDocument(ctx);
197
198 var host = d.createElement('div');
199 host.setAttribute('id', 'host');
200 d.body.appendChild(host);
201
202 var inp1 = d.createElement('input');
203 inp1.setAttribute('id', 'inp1');
204 inp1.setAttribute('type', 'checkbox');
205 inp1.setAttribute('class', 'clazz1');
206 host.appendChild(inp1);
207
208 var inp2 = d.createElement('input');
209 inp2.setAttribute('id', 'inp2');
210 inp2.setAttribute('type', 'checkbox');
211 inp2.setAttribute('class', 'clazz2');
212 host.appendChild(inp2);
213
214 var inp3 = d.createElement('input');
215 inp3.setAttribute('id', 'inp3');
216 inp3.setAttribute('type', 'checkbox');
217 inp3.setAttribute('class', 'clazz1');
218 host.appendChild(inp3);
219
220
221 //Shadow root to play with
222 var s = host.createShadowRoot();
223
224 var shadowDiv = document.createElement('div');
225 shadowDiv.innerHTML = '<content select=".clazz1"></content>';
226 s.appendChild(shadowDiv);
227
228 //element outside the shadow tree
229 var inp4 = d.createElement('input');
230 inp4.setAttribute('id', 'inp4');
231 inp4.setAttribute('type', 'checkbox');
232 inp4.setAttribute('class', 'clazz1');
233 d.body.appendChild(inp4);
234
235 inp1.focus();
236
237 s.addEventListener('DOMFocusOut', A_05_03_01_T05.step_func(function(even t) {
238 assert_equals(event.target.getAttribute('id'), 'inp1', 'Inside s hadow tree: ' +
239 'Event for nodes, distributed ' +
240 'agains insertion points shouldn\'t be retargete d');
241 }), false);
242
243
244 d.body.addEventListener('DOMFocusOut', A_05_03_01_T05.step_func(function (event) {
245 assert_equals(event.target.getAttribute('id'), 'inp1', 'Outside shadow tree: ' +
246 'Event for nodes, distributed ' +
247 'agains insertion points shouldn\'t be retargete d');
248 }), false);
249
250 inp4.focus();
251
252 A_05_03_01_T05.done();
253 }));
254
255
256 //Retargeting shouldn't occur for DOM tree nodes distributed
257 //among insertion points. Check DOMFocusIn
258 var A_05_03_01_T06 = async_test('A_05_03_01_T06');
259
260 A_05_03_01_T06.step(unit(function (ctx) {
261
262 var d = newRenderedHTMLDocument(ctx);
263
264 var host = d.createElement('div');
265 host.setAttribute('id', 'host');
266 d.body.appendChild(host);
267
268 var inp1 = d.createElement('input');
269 inp1.setAttribute('id', 'inp1');
270 inp1.setAttribute('type', 'checkbox');
271 inp1.setAttribute('class', 'clazz1');
272 host.appendChild(inp1);
273
274 var inp2 = d.createElement('input');
275 inp2.setAttribute('id', 'inp2');
276 inp2.setAttribute('type', 'checkbox');
277 inp2.setAttribute('class', 'clazz2');
278 host.appendChild(inp2);
279
280 var inp3 = d.createElement('input');
281 inp3.setAttribute('id', 'inp3');
282 inp3.setAttribute('type', 'checkbox');
283 inp3.setAttribute('class', 'clazz1');
284 host.appendChild(inp3);
285
286
287 //Shadow root to play with
288 var s = host.createShadowRoot();
289
290 var shadowDiv = document.createElement('div');
291 shadowDiv.innerHTML = '<content select=".clazz1"></content>';
292 s.appendChild(shadowDiv);
293
294 //element outside the shadow tree
295 var inp4 = d.createElement('input');
296 inp4.setAttribute('id', 'inp4');
297 inp4.setAttribute('type', 'checkbox');
298 inp4.setAttribute('class', 'clazz1');
299 d.body.appendChild(inp4);
300
301 inp4.focus();
302
303 s.addEventListener('DOMFocusIn', A_05_03_01_T06.step_func(function(event ) {
304 assert_equals(event.target.getAttribute('id'), 'inp1', 'Inside s hadow tree: ' +
305 'Event for nodes, distributed ' +
306 'agains insertion points shouldn\'t be retargete d');
307 }), false);
308
309
310 d.body.addEventListener('DOMFocusIn', A_05_03_01_T05.step_func(function( event) {
311 assert_equals(event.target.getAttribute('id'), 'inp1', 'Outside shadow tree: ' +
312 'Event for nodes, distributed ' +
313 'agains insertion points shouldn\'t be retargete d');
314 }), false);
315
316 inp1.focus();
317
318 A_05_03_01_T06.done();
319 }));
320 </script>
321 </body>
322 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698