summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/test.helper.js8
-rw-r--r--tests/test.keyboard.js24
-rw-r--r--tests/test.localization.js4
-rw-r--r--tests/test.webutil.js4
4 files changed, 30 insertions, 10 deletions
diff --git a/tests/test.helper.js b/tests/test.helper.js
index 0232819..b1f438e 100644
--- a/tests/test.helper.js
+++ b/tests/test.helper.js
@@ -86,7 +86,9 @@ describe('Helpers', function () {
window.navigator.platform = "Mac x86_64";
});
afterEach(function () {
- Object.defineProperty(window, "navigator", origNavigator);
+ if (origNavigator !== undefined) {
+ Object.defineProperty(window, "navigator", origNavigator);
+ }
});
it('should respect ContextMenu on modern browser', function () {
@@ -150,7 +152,9 @@ describe('Helpers', function () {
}
});
afterEach(function () {
- Object.defineProperty(window, "navigator", origNavigator);
+ if (origNavigator !== undefined) {
+ Object.defineProperty(window, "navigator", origNavigator);
+ }
});
it('should ignore printable character key on IE', function () {
diff --git a/tests/test.keyboard.js b/tests/test.keyboard.js
index b49312d..3571d39 100644
--- a/tests/test.keyboard.js
+++ b/tests/test.keyboard.js
@@ -272,7 +272,9 @@ describe('Key Event Handling', function () {
window.navigator.platform = "Mac x86_64";
});
afterEach(function () {
- Object.defineProperty(window, "navigator", origNavigator);
+ if (origNavigator !== undefined) {
+ Object.defineProperty(window, "navigator", origNavigator);
+ }
});
it('should change Alt to AltGraph', function () {
@@ -336,7 +338,9 @@ describe('Key Event Handling', function () {
});
afterEach(function () {
- Object.defineProperty(window, "navigator", origNavigator);
+ if (origNavigator !== undefined) {
+ Object.defineProperty(window, "navigator", origNavigator);
+ }
});
it('should toggle caps lock on key press on iOS', function (done) {
@@ -413,8 +417,12 @@ describe('Key Event Handling', function () {
this.clock = sinon.useFakeTimers();
});
afterEach(function () {
- Object.defineProperty(window, "navigator", origNavigator);
- this.clock.restore();
+ if (origNavigator !== undefined) {
+ Object.defineProperty(window, "navigator", origNavigator);
+ }
+ if (this.clock !== undefined) {
+ this.clock.restore();
+ }
});
it('should supress ControlLeft until it knows if it is AltGr', function () {
@@ -559,8 +567,12 @@ describe('Key Event Handling', function () {
this.clock = sinon.useFakeTimers();
});
afterEach(function () {
- Object.defineProperty(window, "navigator", origNavigator);
- this.clock.restore();
+ if (origNavigator !== undefined) {
+ Object.defineProperty(window, "navigator", origNavigator);
+ }
+ if (this.clock !== undefined) {
+ this.clock.restore();
+ }
});
it('should fake a left Shift keyup', function () {
diff --git a/tests/test.localization.js b/tests/test.localization.js
index 9570c17..301ab79 100644
--- a/tests/test.localization.js
+++ b/tests/test.localization.js
@@ -27,7 +27,9 @@ describe('Localization', function () {
window.navigator.languages = [];
});
afterEach(function () {
- Object.defineProperty(window, "navigator", origNavigator);
+ if (origNavigator !== undefined) {
+ Object.defineProperty(window, "navigator", origNavigator);
+ }
});
it('should use English by default', function () {
diff --git a/tests/test.webutil.js b/tests/test.webutil.js
index 72e1942..2a166ee 100644
--- a/tests/test.webutil.js
+++ b/tests/test.webutil.js
@@ -42,7 +42,9 @@ describe('WebUtil', function () {
return WebUtil.initSettings();
});
afterEach(function () {
- Object.defineProperty(window, "localStorage", origLocalStorage);
+ if (origLocalStorage !== undefined) {
+ Object.defineProperty(window, "localStorage", origLocalStorage);
+ }
});
describe('writeSetting', function () {