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 --> |
(...skipping 12 matching lines...) Expand all Loading... |
23 <link rel="import" href="../../test-fixture/test-fixture.html"> | 23 <link rel="import" href="../../test-fixture/test-fixture.html"> |
24 <link rel="import" href="../iron-a11y-keys-behavior.html"> | 24 <link rel="import" href="../iron-a11y-keys-behavior.html"> |
25 </head> | 25 </head> |
26 <body> | 26 <body> |
27 <test-fixture id="BasicKeys"> | 27 <test-fixture id="BasicKeys"> |
28 <template> | 28 <template> |
29 <x-a11y-basic-keys></x-a11y-basic-keys> | 29 <x-a11y-basic-keys></x-a11y-basic-keys> |
30 </template> | 30 </template> |
31 </test-fixture> | 31 </test-fixture> |
32 | 32 |
| 33 <test-fixture id="NonPropagatingKeys"> |
| 34 <template> |
| 35 <x-a11y-basic-keys stop-keyboard-event-propagation></x-a11y-basic-keys> |
| 36 </template> |
| 37 </test-fixture> |
| 38 |
33 <test-fixture id="ComboKeys"> | 39 <test-fixture id="ComboKeys"> |
34 <template> | 40 <template> |
35 <x-a11y-combo-keys></x-a11y-combo-keys> | 41 <x-a11y-combo-keys></x-a11y-combo-keys> |
36 </template> | 42 </template> |
37 </test-fixture> | 43 </test-fixture> |
38 | 44 |
39 <test-fixture id="AlternativeEventKeys"> | 45 <test-fixture id="AlternativeEventKeys"> |
40 <template> | 46 <template> |
41 <x-a11y-alternate-event-keys></x-a11y-alternate-event-keys> | 47 <x-a11y-alternate-event-keys></x-a11y-alternate-event-keys> |
42 </template> | 48 </template> |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 keys.addOwnKeyBinding('enter', '_keyHandler'); | 160 keys.addOwnKeyBinding('enter', '_keyHandler'); |
155 keys.removeOwnKeyBindings(); | 161 keys.removeOwnKeyBindings(); |
156 | 162 |
157 MockInteractions.pressEnter(keys); | 163 MockInteractions.pressEnter(keys); |
158 expect(keys.keyCount).to.be.equal(0); | 164 expect(keys.keyCount).to.be.equal(0); |
159 | 165 |
160 MockInteractions.pressSpace(keys); | 166 MockInteractions.pressSpace(keys); |
161 expect(keys.keyCount).to.be.equal(1); | 167 expect(keys.keyCount).to.be.equal(1); |
162 }); | 168 }); |
163 | 169 |
| 170 test('allows propagation beyond the key combo handler', function() { |
| 171 var keySpy = sinon.spy(); |
| 172 document.addEventListener('keydown', keySpy); |
| 173 |
| 174 MockInteractions.pressEnter(keys); |
| 175 |
| 176 expect(keySpy.callCount).to.be.equal(1); |
| 177 }); |
| 178 |
164 suite('edge cases', function() { | 179 suite('edge cases', function() { |
165 test('knows that `spacebar` is the same as `space`', function() { | 180 test('knows that `spacebar` is the same as `space`', function() { |
166 var event = new CustomEvent('keydown'); | 181 var event = new CustomEvent('keydown'); |
167 event.key = 'spacebar'; | 182 event.key = 'spacebar'; |
168 expect(keys.keyboardEventMatchesKeys(event, 'space')).to.be.equal(true); | 183 expect(keys.keyboardEventMatchesKeys(event, 'space')).to.be.equal(true); |
169 }); | 184 }); |
170 }); | 185 }); |
171 | 186 |
172 suite('matching keyboard events to keys', function() { | 187 suite('matching keyboard events to keys', function() { |
173 test('can be done imperatively', function() { | 188 test('can be done imperatively', function() { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 }); | 250 }); |
236 | 251 |
237 test('bindings in other behaviors are transitive', function() { | 252 test('bindings in other behaviors are transitive', function() { |
238 MockInteractions.pressEnter(keys); | 253 MockInteractions.pressEnter(keys); |
239 MockInteractions.pressSpace(keys); | 254 MockInteractions.pressSpace(keys); |
240 | 255 |
241 expect(keys.keyCount).to.be.equal(2); | 256 expect(keys.keyCount).to.be.equal(2); |
242 }); | 257 }); |
243 }); | 258 }); |
244 | 259 |
| 260 suite('stopping propagation automatically', function() { |
| 261 setup(function() { |
| 262 keys = fixture('NonPropagatingKeys'); |
| 263 }); |
| 264 |
| 265 test('does not propagate key events beyond the combo handler', function() { |
| 266 var keySpy = sinon.spy(); |
| 267 |
| 268 document.addEventListener('keydown', keySpy); |
| 269 |
| 270 MockInteractions.pressEnter(keys); |
| 271 |
| 272 expect(keySpy.callCount).to.be.equal(0); |
| 273 }); |
| 274 }); |
| 275 |
245 }); | 276 }); |
246 </script> | 277 </script> |
247 </body> | 278 </body> |
248 </html> | 279 </html> |
OLD | NEW |