OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <!-- | 2 <!-- |
3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. | 3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | 4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
7 Code distributed by Google as part of the polymer project is also | 7 Code distributed by Google as part of the polymer project is also |
8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt | 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
9 --> | 9 --> |
10 | 10 |
11 <html> | 11 <html> |
12 <head> | 12 <head> |
13 <title>iron-collapse-horizontal</title> | 13 |
| 14 <title>iron-collapse-a11y</title> |
14 <meta charset="utf-8"> | 15 <meta charset="utf-8"> |
15 <meta name="viewport" content="width=device-width, initial-scale=1.0"> | 16 <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
16 | 17 |
17 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> | 18 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> |
18 <script src="../../web-component-tester/browser.js"></script> | 19 <script src="../../web-component-tester/browser.js"></script> |
19 <script src="../../test-fixture/test-fixture-mocha.js"></script> | 20 <script src="../../test-fixture/test-fixture-mocha.js"></script> |
20 | 21 |
21 <link rel="import" href="../../test-fixture/test-fixture.html"> | 22 <link rel="import" href="../../test-fixture/test-fixture.html"> |
22 <link rel="import" href="../iron-collapse.html"> | 23 <link rel="import" href="../iron-collapse.html"> |
| 24 |
23 </head> | 25 </head> |
24 <body> | 26 <body> |
25 | 27 |
26 <test-fixture id="test"> | 28 <test-fixture id="trivialCollapse"> |
27 <template> | 29 <template> |
28 <iron-collapse id="collapse" opened horizontal> | 30 <iron-collapse id="collapse" tabindex="0"> |
29 <div> | 31 <div> |
30 Forma temperiemque cornua sidera dissociata cornua recessit innabili
s ligavit: solidumque coeptis nullus caelum sponte phoebe di regat mentisque tan
ta austro capacius amphitrite sui quin postquam semina fossae liquidum umor gale
ae coeptis caligine liberioris quin liquidum matutinis invasit posset: flexi glo
meravit radiis certis invasit oppida postquam onerosior inclusum dominari opifex
terris pace finxit quam aquae nunc sine altae auroram quam habentem homo totide
mque scythiam in pondus ensis tegit caecoque poena lapidosos humanas coeperunt p
oena aetas totidem nec natura aethera locavit caelumque distinxit animalibus pho
ebe cingebant moderantum porrexerat terrae possedit sua sole diu summaque obliqu
is melioris orbem | 32 Forma temperiemque cornua sidera dissociata cornua recessit innabili
s ligavit: solidumque coeptis nullus caelum sponte phoebe di regat mentisque tan
ta austro capacius amphitrite sui quin postquam semina fossae liquidum umor gale
ae coeptis caligine liberioris quin liquidum matutinis invasit posset: flexi glo
meravit radiis certis invasit oppida postquam onerosior inclusum dominari opifex
terris pace finxit quam aquae nunc sine altae auroram quam habentem homo totide
mque scythiam in pondus ensis tegit caecoque poena lapidosos humanas coeperunt p
oena aetas totidem nec natura aethera locavit caelumque distinxit animalibus pho
ebe cingebant moderantum porrexerat terrae possedit sua sole diu summaque obliqu
is melioris orbem |
31 </div> | 33 </div> |
32 </iron-collapse> | 34 </iron-collapse> |
33 </template> | 35 </template> |
34 </test-fixture> | 36 </test-fixture> |
35 | 37 |
36 <script> | 38 <script> |
37 | 39 |
38 suite('horizontal', function() { | 40 suite('a11y', function() { |
39 | |
40 var collapse; | 41 var collapse; |
41 var delay = 500; | |
42 var collapseHeight; | |
43 | 42 |
44 setup(function () { | 43 setup(function () { |
45 collapse = fixture('test'); | 44 collapse = fixture('trivialCollapse'); |
46 }); | 45 }); |
47 | 46 |
48 test('opened attribute', function() { | 47 test('aria attributes', function() { |
49 assert.equal(collapse.opened, true); | 48 assert.equal(collapse.getAttribute('role'), 'group'); |
| 49 assert.equal(collapse.getAttribute('aria-expanded'), 'false'); |
| 50 assert.equal(collapse.getAttribute('aria-hidden'), 'true'); |
50 }); | 51 }); |
51 | 52 |
52 test('horizontal attribute', function() { | 53 test('set opened to true', function() { |
53 assert.equal(collapse.horizontal, true); | 54 collapse.opened = true; |
| 55 assert.equal(collapse.getAttribute('aria-expanded'), 'true'); |
| 56 assert.equal(collapse.getAttribute('aria-hidden'), 'false'); |
54 }); | 57 }); |
55 | 58 |
56 test('default opened width', function(done) { | 59 test('focus the collapse when opened', function() { |
57 setTimeout(function() { | 60 assert.notEqual(document.activeElement, collapse); |
58 // store actual width | 61 collapse.opened = true; |
59 width = getComputedStyle(collapse).width; | 62 assert.equal(document.activeElement, collapse); |
60 // verify width not 0px | |
61 assert.notEqual(width, '0px'); | |
62 done(); | |
63 }, delay); | |
64 }); | 63 }); |
65 | 64 |
66 test('set opened to false', function(done) { | 65 a11ySuite('trivialCollapse'); |
67 collapse.opened = false; | |
68 setTimeout(function() { | |
69 var h = getComputedStyle(collapse).width; | |
70 // verify width is 0px | |
71 assert.equal(h, '0px'); | |
72 done(); | |
73 }, delay); | |
74 }); | |
75 | |
76 test('set opened to true', function(done) { | |
77 collapse.opened = true; | |
78 setTimeout(function() { | |
79 var h = getComputedStyle(collapse).width; | |
80 // verify width | |
81 assert.equal(h, width); | |
82 done(); | |
83 }, delay); | |
84 }); | |
85 | 66 |
86 }); | 67 }); |
87 | 68 |
88 </script> | 69 </script> |
89 | 70 |
90 </body> | 71 </body> |
91 </html> | 72 </html> |
| 73 |
OLD | NEW |