Index: third_party/polymer/components/iron-a11y-keys-behavior/test/basic-test.html |
diff --git a/third_party/polymer/components/iron-a11y-keys-behavior/test/basic-test.html b/third_party/polymer/components/iron-a11y-keys-behavior/test/basic-test.html |
index d53b6009fc2677fa1bb94e0ccfc635a9d5b772fc..d0c2dc35f95289255027ae27eff6c76d24021a1c 100644 |
--- a/third_party/polymer/components/iron-a11y-keys-behavior/test/basic-test.html |
+++ b/third_party/polymer/components/iron-a11y-keys-behavior/test/basic-test.html |
@@ -171,15 +171,13 @@ suite('Polymer.IronA11yKeysBehavior', function() { |
MockInteractions.pressSpace(keys); |
expect(keys.keyCount).to.be.equal(1); |
+ }); |
- MockInteractions.pressAndReleaseKeyOn(keys, 27, [], 'Esc'); |
- expect(keys.keyCount).to.be.equal(2); |
- |
- MockInteractions.pressAndReleaseKeyOn(keys, 27, [], 'Escape'); |
- expect(keys.keyCount).to.be.equal(3); |
+ test('keyEventTarget can be null, and disables listeners', function() { |
+ keys.keyEventTarget = null; |
+ MockInteractions.pressSpace(keys); |
- MockInteractions.pressAndReleaseKeyOn(keys, 27, []); |
- expect(keys.keyCount).to.be.equal(4); |
+ expect(keys.keyCount).to.be.equal(0); |
}); |
test('trigger the handler when the specified key is pressed together with a modifier', function() { |
@@ -191,12 +189,22 @@ suite('Polymer.IronA11yKeysBehavior', function() { |
}); |
test('handles special character @', function() { |
- var event = new CustomEvent('keydown'); |
- event.key = '@'; |
- keys.dispatchEvent(event); |
+ MockInteractions.pressAndReleaseKeyOn(keys, undefined, [], '@'); |
+ |
expect(keys.keyCount).to.be.equal(1); |
}); |
+ test('handles variations of Esc key', function() { |
+ MockInteractions.pressAndReleaseKeyOn(keys, undefined, [], 'Esc'); |
+ expect(keys.keyCount).to.be.equal(1); |
+ |
+ MockInteractions.pressAndReleaseKeyOn(keys, undefined, [], 'Escape'); |
+ expect(keys.keyCount).to.be.equal(2); |
+ |
+ MockInteractions.pressAndReleaseKeyOn(keys, 27, [], ''); |
+ expect(keys.keyCount).to.be.equal(3); |
+ }); |
+ |
test('do not trigger the handler for non-specified keys', function() { |
MockInteractions.pressEnter(keys); |
@@ -423,6 +431,15 @@ suite('Polymer.IronA11yKeysBehavior', function() { |
}); |
}); |
+ suite('remove key behavior with null target', function () { |
+ test('add and remove a iron-a11y-keys-behavior', function () { |
+ var element = document.createElement('x-a11y-basic-keys'); |
+ element.keyEventTarget = null; |
+ document.body.appendChild(element); |
+ document.body.removeChild(element); |
+ }); |
+ }); |
+ |
}); |
</script> |
</body> |