| OLD | NEW |
| 1 <!doctype html> | 1 <!doctype html> |
| 2 <!-- | 2 <!-- |
| 3 @license | 3 @license |
| 4 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. | 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 | 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 | 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 | 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 | 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 | 9 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
| 10 --> | 10 --> |
| 11 <html> | 11 <html> |
| 12 <head> | 12 <head> |
| 13 | 13 |
| 14 <title>iron-menu-behavior tests</title> | 14 <title>iron-menu-behavior tests</title> |
| 15 | 15 |
| 16 <meta charset="utf-8"> | 16 <meta charset="utf-8"> |
| 17 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | 17 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
| 18 <meta name="viewport" content="width=device-width, minimum-scale=1.0, initia
l-scale=1, user-scalable=yes"> | 18 <meta name="viewport" content="width=device-width, minimum-scale=1.0, initia
l-scale=1, user-scalable=yes"> |
| 19 | 19 |
| 20 |
| 20 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> | 21 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> |
| 21 | |
| 22 <script src="../../web-component-tester/browser.js"></script> | 22 <script src="../../web-component-tester/browser.js"></script> |
| 23 <script src="../../test-fixture/test-fixture-mocha.js"></script> | 23 <script src="../../iron-test-helpers/mock-interactions.js"></script> |
| 24 | |
| 25 <link rel="import" href="../../test-fixture/test-fixture.html"> | |
| 26 <link rel="import" href="test-menu.html"> | 24 <link rel="import" href="test-menu.html"> |
| 27 | 25 |
| 28 </head> | 26 </head> |
| 29 <body> | 27 <body> |
| 30 | 28 |
| 31 <test-fixture id="basic"> | 29 <test-fixture id="basic"> |
| 32 <template> | 30 <template> |
| 33 <test-menu> | 31 <test-menu> |
| 34 <div>item 1</div> | 32 <div>item 1</div> |
| 35 <div>item 2</div> | 33 <div>item 2</div> |
| 36 <div>item 3</div> | 34 <div>item 3</div> |
| 37 </test-menu> | 35 </test-menu> |
| 38 </template> | 36 </template> |
| 39 </test-fixture> | 37 </test-fixture> |
| 40 | 38 |
| 41 <test-fixture id="multi"> | 39 <test-fixture id="multi"> |
| 42 <template> | 40 <template> |
| 43 <test-menu multi> | 41 <test-menu multi> |
| 44 <div>item 1</div> | 42 <div>item 1</div> |
| 45 <div>item 2</div> | 43 <div>item 2</div> |
| 46 <div>item 3</div> | 44 <div>item 3</div> |
| 47 </test-menu> | 45 </test-menu> |
| 48 </template> | 46 </template> |
| 49 </test-fixture> | 47 </test-fixture> |
| 50 | 48 |
| 49 |
| 50 <test-fixture id="nested"> |
| 51 <template> |
| 52 <test-menu> |
| 53 <test-menu> |
| 54 <div>item 1</div> |
| 55 <div>item 2</div> |
| 56 <div>item 3</div> |
| 57 </test-menu> |
| 58 </test-menu> |
| 59 </template> |
| 60 </test-fixture> |
| 61 |
| 51 <script> | 62 <script> |
| 52 | 63 |
| 53 suite('menu a11y tests', function() { | 64 suite('menu a11y tests', function() { |
| 54 | 65 |
| 55 test('menu has role="menu"', function() { | 66 test('menu has role="menu"', function() { |
| 56 var menu = fixture('basic'); | 67 var menu = fixture('basic'); |
| 57 assert.equal(menu.getAttribute('role'), 'menu', 'has role="menu"'); | 68 assert.equal(menu.getAttribute('role'), 'menu', 'has role="menu"'); |
| 58 }); | 69 }); |
| 59 | 70 |
| 60 test('first item gets focus when menu is focused', function(done) { | 71 test('first item gets focus when menu is focused', function(done) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 var menu = fixture('multi'); | 104 var menu = fixture('multi'); |
| 94 menu.selected = 0; | 105 menu.selected = 0; |
| 95 menu.items[0].click(); | 106 menu.items[0].click(); |
| 96 setTimeout(function() { | 107 setTimeout(function() { |
| 97 assert.equal(document.activeElement, menu.items[0], 'document.active
Element is last activated item'); | 108 assert.equal(document.activeElement, menu.items[0], 'document.active
Element is last activated item'); |
| 98 done(); | 109 done(); |
| 99 // wait for async in _onFocus | 110 // wait for async in _onFocus |
| 100 }, 200); | 111 }, 200); |
| 101 }); | 112 }); |
| 102 | 113 |
| 114 test('keyboard events should not bubble', function(done) { |
| 115 var menu = fixture('nested'); |
| 116 var keyCounter = 0; |
| 117 |
| 118 menu.addEventListener('keydown', function(event) { |
| 119 if (menu.keyboardEventMatchesKeys(event, 'esc')) { |
| 120 keyCounter++; |
| 121 } |
| 122 if (menu.keyboardEventMatchesKeys(event, 'up')) { |
| 123 keyCounter++; |
| 124 } |
| 125 if (menu.keyboardEventMatchesKeys(event, 'down')) { |
| 126 keyCounter++; |
| 127 } |
| 128 }); |
| 129 |
| 130 // up |
| 131 MockInteractions.keyDownOn(menu.firstElementChild, 38); |
| 132 // down |
| 133 MockInteractions.keyDownOn(menu.firstElementChild, 40); |
| 134 // esc |
| 135 MockInteractions.keyDownOn(menu.firstElementChild, 27); |
| 136 |
| 137 setTimeout(function() { |
| 138 assert.equal(menu.firstElementChild.tagName, 'TEST-MENU'); |
| 139 assert.equal(keyCounter, 0); |
| 140 done(); |
| 141 }, 200); |
| 142 }); |
| 143 |
| 103 }); | 144 }); |
| 104 | 145 |
| 105 </script> | 146 </script> |
| 106 | 147 |
| 107 </body> | 148 </body> |
| 108 </html> | 149 </html> |
| OLD | NEW |