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.github.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/CONTRIBUTORS.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/PATENTS.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 20 <link rel="import" href="../../iron-icons/iron-icons.html"> 21 <link rel="import" href="../paper-icon-button.html"> 22 23 </head> 24 <body> 25 26 <test-fixture id="A11yIconButtons"> 27 <template> 28 <paper-icon-button id="iconButton1" icon="add"></paper-icon-button> 29 <paper-icon-button id="iconButton2" icon="add" disabled></paper-icon-button> 30 <paper-icon-button id="iconButton3" icon="add" aria-label="custom"></paper-icon-button> 31 <paper-icon-button id="iconButton4" icon="add" alt="alt text"></paper-icon-button> 32 <paper-icon-button id="iconButton5" icon="add" aria-label="custom" alt="alt text" ></paper-icon-button> 33 </template> 34 </test-fixture> 35 36 <script> 37 38 var b1; 39 var b2; 40 var b3; 41 var b4; 42 var b5; 43 44 setup(function() { 45 var iconButtons = fixture('A11yIconButtons'); 46 47 b1 = iconButtons[0]; 48 b2 = iconButtons[1]; 49 b3 = iconButtons[2]; 50 b4 = iconButtons[3]; 51 b5 = iconButtons[4]; 52 }); 53 54 test('aria role is a button', function() { 55 assert.strictEqual(b1.getAttribute('role'), 'button'); 56 }); 57 58 test('aria-disabled is set', function() { 59 assert.strictEqual(b2.getAttribute('aria-disabled'), 'true'); 60 b2.removeAttribute('disabled'); 61 assert.strictEqual(b2.getAttribute('aria-disabled'), 'false'); 62 }); 63 64 test('user-defined aria-label is preserved', function() { 65 assert.strictEqual(b3.getAttribute('aria-label'), 'custom'); 66 b3.icon = 'arrow-forward'; 67 assert.strictEqual(b3.getAttribute('aria-label'), 'custom'); 68 }); 69 70 test('alt attribute is used for the aria-label', function() { 71 assert.strictEqual(b4.getAttribute('aria-label'), 'alt text'); 72 b4.icon = 'arrow-forward'; 73 assert.strictEqual(b4.getAttribute('aria-label'), 'alt text'); 74 }); 75 76 test('aria-label wins over alt attribute', function() { 77 assert.strictEqual(b5.getAttribute('aria-label'), 'custom'); 78 b5.icon = 'arrow-forward'; 79 b5.alt = 'other alt' 80 assert.strictEqual(b5.getAttribute('aria-label'), 'custom'); 81 }); 82 83 test('alt attribute can be updated', function() { 84 assert.strictEqual(b4.getAttribute('aria-label'), 'alt text'); 85 b4.alt = 'alt again'; 86 assert.strictEqual(b4.getAttribute('aria-label'), 'alt again'); 87 }); 88 89 </script> 90 91 </body> 92 </html> 93