| OLD | NEW |
| (Empty) | |
| 1 <!doctype html> |
| 2 <!-- |
| 3 @license |
| 4 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
| 5 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
| 6 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
| 7 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
| 8 Code distributed by Google as part of the polymer project is also |
| 9 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
| 10 --> |
| 11 <html> |
| 12 <head> |
| 13 <meta charset="UTF-8"> |
| 14 <title>paper-icon-button a11y tests</title> |
| 15 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-
scale=1.0"> |
| 16 |
| 17 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> |
| 18 <script src="../../web-component-tester/browser.js"></script> |
| 19 <script src="../../test-fixture/test-fixture-mocha.js"></script> |
| 20 |
| 21 <link rel="import" href="../../iron-icons/iron-icons.html"> |
| 22 <link rel="import" href="../../test-fixture/test-fixture.html"> |
| 23 <link rel="import" href="../paper-icon-button.html"> |
| 24 |
| 25 </head> |
| 26 <body> |
| 27 |
| 28 <test-fixture id="A11yIconButtons"> |
| 29 <template> |
| 30 <paper-icon-button id="iconButton1" icon="add"></paper-icon-button> |
| 31 <paper-icon-button id="iconButton2" icon="add" disabled></paper-icon-butto
n> |
| 32 <paper-icon-button id="iconButton3" icon="add" aria-label="custom"></paper
-icon-button> |
| 33 <paper-icon-button id="iconButton4" icon="add" alt="alt text"></paper-icon
-button> |
| 34 <paper-icon-button id="iconButton5" icon="add" aria-label="custom" alt="al
t text" ></paper-icon-button> |
| 35 </template> |
| 36 </test-fixture> |
| 37 |
| 38 <script> |
| 39 |
| 40 var b1; |
| 41 var b2; |
| 42 var b3; |
| 43 var b4; |
| 44 var b5; |
| 45 |
| 46 setup(function() { |
| 47 var iconButtons = fixture('A11yIconButtons'); |
| 48 |
| 49 b1 = iconButtons[0]; |
| 50 b2 = iconButtons[1]; |
| 51 b3 = iconButtons[2]; |
| 52 b4 = iconButtons[3]; |
| 53 b5 = iconButtons[4]; |
| 54 }); |
| 55 |
| 56 test('aria role is a button', function() { |
| 57 assert.strictEqual(b1.getAttribute('role'), 'button'); |
| 58 }); |
| 59 |
| 60 test('aria-disabled is set', function() { |
| 61 assert.strictEqual(b2.getAttribute('aria-disabled'), 'true'); |
| 62 b2.removeAttribute('disabled'); |
| 63 assert.strictEqual(b2.getAttribute('aria-disabled'), 'false'); |
| 64 }); |
| 65 |
| 66 test('user-defined aria-label is preserved', function() { |
| 67 assert.strictEqual(b3.getAttribute('aria-label'), 'custom'); |
| 68 b3.icon = 'arrow-forward'; |
| 69 assert.strictEqual(b3.getAttribute('aria-label'), 'custom'); |
| 70 }); |
| 71 |
| 72 test('alt attribute is used for the aria-label', function() { |
| 73 assert.strictEqual(b4.getAttribute('aria-label'), 'alt text'); |
| 74 b4.icon = 'arrow-forward'; |
| 75 assert.strictEqual(b4.getAttribute('aria-label'), 'alt text'); |
| 76 }); |
| 77 |
| 78 test('aria-label wins over alt attribute', function() { |
| 79 assert.strictEqual(b5.getAttribute('aria-label'), 'custom'); |
| 80 b5.icon = 'arrow-forward'; |
| 81 b5.alt = 'other alt' |
| 82 assert.strictEqual(b5.getAttribute('aria-label'), 'custom'); |
| 83 }); |
| 84 |
| 85 test('alt attribute can be updated', function() { |
| 86 assert.strictEqual(b4.getAttribute('aria-label'), 'alt text'); |
| 87 b4.alt = 'alt again'; |
| 88 assert.strictEqual(b4.getAttribute('aria-label'), 'alt again'); |
| 89 }); |
| 90 |
| 91 </script> |
| 92 |
| 93 </body> |
| 94 </html> |
| OLD | NEW |