import sinon from '../vendor/sinon.js';
import Keyboard from '../core/input/keyboard.js';
-
-function isIE() {
- return navigator && !!(/trident/i).exec(navigator.userAgent);
-}
-function isEdge() {
- return navigator && !!(/edge/i).exec(navigator.userAgent);
-}
+import * as browser from '../core/util/browser.js';
describe('Key Event Handling', function() {
"use strict";
describe('Decode Keyboard Events', function() {
it('should decode keydown events', function(done) {
- if (isIE() || isEdge()) this.skip();
+ if (browser.isIE() || browser.isEdge()) this.skip();
var kbd = new Keyboard(document);
kbd.onkeyevent = function(keysym, code, down) {
expect(keysym).to.be.equal(0x61);
kbd._handleKeyDown(keyevent('keydown', {code: 'KeyA', key: 'a'}));
});
it('should decode keyup events', function(done) {
- if (isIE() || isEdge()) this.skip();
+ if (browser.isIE() || browser.isEdge()) this.skip();
var calls = 0;
var kbd = new Keyboard(document);
kbd.onkeyevent = function(keysym, code, down) {
describe('suppress the right events at the right time', function() {
beforeEach(function () {
- if (isIE() || isEdge()) this.skip();
+ if (browser.isIE() || browser.isEdge()) this.skip();
});
it('should suppress anything with a valid key', function() {
var kbd = new Keyboard(document, {});
describe('Fake keyup', function() {
it('should fake keyup events for virtual keyboards', function(done) {
- if (isIE() || isEdge()) this.skip();
+ if (browser.isIE() || browser.isEdge()) this.skip();
var count = 0;
var kbd = new Keyboard(document);
kbd.onkeyevent = function(keysym, code, down) {
});
it('should fake keyup events on iOS', function(done) {
- if (isIE() || isEdge()) this.skip();
+ if (browser.isIE() || browser.isEdge()) this.skip();
var count = 0;
var kbd = new Keyboard(document);
kbd.onkeyevent = function(keysym, code, down) {
describe('Track Key State', function() {
beforeEach(function () {
- if (isIE() || isEdge()) this.skip();
+ if (browser.isIE() || browser.isEdge()) this.skip();
});
it('should send release using the same keysym as the press', function(done) {
var kbd = new Keyboard(document);