summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2020-12-10 09:43:49 +0100
committerPierre Ossman <ossman@cendio.se>2020-12-10 10:00:44 +0100
commit146258291ad546a18b05a6c3704a26b8c5d819d4 (patch)
tree978cdfd2ec0e298d4dab205bfce22176256939e9 /tests
parent3e55d5d71af51eaa1d960bbd67b744ec61df9aba (diff)
downloadnovnc-146258291ad546a18b05a6c3704a26b8c5d819d4.tar.gz
Send combination keysyms for some Japanese keys
Windows doesn't give us stable symbols for a bunch of Japanese IM keys, instead alternating between two symbols. This state is not synchronised with the IM running on the remote server so to have stable behaviour we have to collapse these multiple symbols in to a single keysym.
Diffstat (limited to 'tests')
-rw-r--r--tests/test.helper.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/test.helper.js b/tests/test.helper.js
index 5552ec4..ed65770 100644
--- a/tests/test.helper.js
+++ b/tests/test.helper.js
@@ -186,5 +186,38 @@ describe('Helpers', function () {
expect(KeyboardUtil.getKeysym({code: 'NumpadDecimal', key: ',', location: 3})).to.be.equal(0xFFAC);
});
});
+
+ describe('Japanese IM keys on Windows', function () {
+ let origNavigator;
+ beforeEach(function () {
+ // window.navigator is a protected read-only property in many
+ // environments, so we need to redefine it whilst running these
+ // tests.
+ origNavigator = Object.getOwnPropertyDescriptor(window, "navigator");
+
+ Object.defineProperty(window, "navigator", {value: {}});
+ if (window.navigator.platform !== undefined) {
+ // Object.defineProperty() doesn't work properly in old
+ // versions of Chrome
+ this.skip();
+ }
+
+ window.navigator.platform = "Windows";
+ });
+
+ afterEach(function () {
+ if (origNavigator !== undefined) {
+ Object.defineProperty(window, "navigator", origNavigator);
+ }
+ });
+
+ const keys = { 'Zenkaku': 0xff2a, 'Hankaku': 0xff2a,
+ 'Romaji': 0xff24, 'KanaMode': 0xff24 };
+ for (let [key, keysym] of Object.entries(keys)) {
+ it(`should fake combined key for ${key} on Windows`, function () {
+ expect(KeyboardUtil.getKeysym({code: 'FakeIM', key: key})).to.be.equal(keysym);
+ });
+ }
+ });
});
});