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].
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
13 <title>Shadow DOM Test: A_07_02_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/#focus-navigation">
16 <meta name="assert" content="User Interaction: The navigation order within a shadow tree must be computed as a list of focusable elements in tree order as-rendered">
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">
25 var A_07_02_01_T01 = async_test('A_07_02_01_T01');
27 A_07_02_01_T01.step(unit(function (ctx) {
31 var d = newRenderedHTMLDocument(ctx);
33 var chb1 = d.createElement('input');
34 chb1.setAttribute('type', 'checkbox');
35 chb1.setAttribute('id', 'chb1');
36 chb1.addEventListener('focus', A_07_02_01_T01.step_func(function(event) {
37 assert_equals(counter++, 0, 'Point 1: wrong focus navigation order');
39 d.body.appendChild(chb1);
41 var host = d.createElement('div');
42 d.body.appendChild(host);
43 var s = host.createShadowRoot();
45 var inp1 = d.createElement('input');
46 inp1.setAttribute('type', 'text');
47 inp1.setAttribute('id', 'shInp1');
48 inp1.setAttribute('value', 'Input 1');
49 inp1.addEventListener('focus', A_07_02_01_T01.step_func(function(event) {
50 assert_equals(counter++, 1, 'Point 2: wrong focus navigation order');
54 var inp2 = d.createElement('input');
55 inp2.setAttribute('type', 'text');
56 inp2.setAttribute('id', 'shInp2');
57 inp2.setAttribute('value', 'Input 2');
58 inp2.addEventListener('focus', A_07_02_01_T01.step_func(function(event) {
59 assert_equals(counter++, 2, 'Point 3: wrong focus navigation order');
63 var chb2 = d.createElement('input');
64 chb2.setAttribute('type', 'checkbox');
65 chb2.setAttribute('id', 'chb2');
66 chb2.addEventListener('focus', A_07_02_01_T01.step_func(function(event) {
67 assert_equals(counter++, 3, 'Point 4: wrong focus navigation order');
69 d.body.appendChild(chb2);
74 fireKeyboardEvent(d, chb1, 'U+0009');
76 fireKeyboardEvent(d, inp1, 'U+0009');
78 fireKeyboardEvent(d, inp2, 'U+0009');
80 fireKeyboardEvent(d, chb2, 'U+0009');
82 A_07_02_01_T01.done();