OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 2 * Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
3 * for details. All rights reserved. Use of this source code is governed by a | 3 * for details. All rights reserved. Use of this source code is governed by a |
4 * BSD-style license that can be found in the LICENSE file. | 4 * BSD-style license that can be found in the LICENSE file. |
5 */ | 5 */ |
6 /* | 6 /* |
7 * Portions of this test are derived from code under the following license: | 7 * Portions of this test are derived from code under the following license: |
8 * | 8 * |
9 * Web-platform-tests are covered by the dual-licensing approach described in: | 9 * Web-platform-tests are covered by the dual-licensing approach described in: |
10 * http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html | 10 * http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html |
11 */ | 11 */ |
12 /** | 12 /** |
13 * @assertion Retargeting focus events: The blur event must be treated in the | 13 * @assertion Retargeting focus events: The blur event must be treated in the |
14 * same way as events with a relatedTarget, where the node that is gaining | 14 * same way as events with a relatedTarget, where the node that is gaining |
15 * focus causing the blurring of target acts as the related target | 15 * focus causing the blurring of target acts as the related target |
16 */ | 16 */ |
17 | 17 |
18 import 'dart:html'; | 18 import 'dart:html'; |
19 import 'package:unittest/unittest.dart' as unittest; | 19 import "../../../../Utils/expect.dart"; |
20 import 'package:unittest/html_individual_config.dart'; | 20 import "../../../../Utils/async_utils.dart"; |
21 import '../../testcommon.dart'; | 21 import '../../testcommon.dart'; |
22 | 22 |
23 main() { | 23 main() { |
| 24 var d = document; |
24 | 25 |
25 useHtmlIndividualConfiguration(); | 26 var invoked = false; |
26 unittest.test("focus retargeting", () { | |
27 var d = document; | |
28 | 27 |
29 var invoked = false; | 28 var roots = createTestMediaPlayer(d); |
30 | 29 |
31 var roots = createTestMediaPlayer(d); | 30 roots.playerShadowRoot.querySelector('.volume-slider').focus(); |
32 | 31 |
33 roots.playerShadowRoot.querySelector('.volume-slider').focus(); | 32 asyncStart(); |
34 | 33 |
35 //expected result of what relative target should be see | 34 //expected result of what relative target should be see |
36 //see at http://www.w3.org/TR/shadow-dom/#event-retargeting-example | 35 //see at http://www.w3.org/TR/shadow-dom/#event-retargeting-example |
37 | 36 |
38 //For #volume-slider relative target is #volume-slider | 37 //For #volume-slider relative target is #volume-slider |
39 roots.playerShadowRoot.querySelector('.volume-slider') | 38 roots.playerShadowRoot.querySelector('.volume-slider') |
40 .addEventListener('blur', unittest.expectAsync((event) { | 39 .addEventListener('blur', (event) { |
41 invoked = true; | 40 invoked = true; |
42 unittest.expect(event.target.getAttribute('id'), 'volume-slider', | 41 assert_equals(event.target.getAttribute('id'), 'volume-slider', |
43 reason: 'Wrong target'); | 42 'Wrong target'); |
44 })); | 43 asyncEnd(); |
| 44 }, false); |
45 | 45 |
46 // move focus out of shadow tree. blur should be fired | 46 // move focus out of shadow tree. blur should be fired |
47 d.querySelector('#outside-control').focus(); | 47 d.querySelector('#outside-control').focus(); |
48 }); | 48 |
| 49 assert_true(invoked, 'Event listener was not invoked'); |
49 } | 50 } |
OLD | NEW |