diff --git a/.eslintrc b/.eslintrc index 951b4fc5..2c2c08e9 100644 --- a/.eslintrc +++ b/.eslintrc @@ -40,5 +40,8 @@ "no-trailing-spaces": ["error"], "semi": ["error"], "space-before-blocks": ["error"], + "space-before-function-paren": ["error", { "anonymous": "always", + "named": "never", + "asyncArrow": "always" }], } } diff --git a/app/error-handler.js b/app/error-handler.js index f02f5355..8e294166 100644 --- a/app/error-handler.js +++ b/app/error-handler.js @@ -9,7 +9,7 @@ "use strict"; // Fallback for all uncought errors - function handleError (event, err) { + function handleError(event, err) { try { const msg = document.getElementById('noVNC_fallback_errormsg'); diff --git a/app/webutil.js b/app/webutil.js index 278f10e4..db76de60 100644 --- a/app/webutil.js +++ b/app/webutil.js @@ -10,7 +10,7 @@ import { init_logging as main_init_logging } from '../core/util/logging.js'; // init log level reading the logging HTTP param -export function init_logging (level) { +export function init_logging(level) { "use strict"; if (typeof level !== "undefined") { main_init_logging(level); @@ -21,7 +21,7 @@ export function init_logging (level) { } // Read a query string variable -export function getQueryVar (name, defVal) { +export function getQueryVar(name, defVal) { "use strict"; const re = new RegExp('.*[?&]' + name + '=([^&#]*)'), match = document.location.href.match(re); @@ -35,7 +35,7 @@ export function getQueryVar (name, defVal) { } // Read a hash fragment variable -export function getHashVar (name, defVal) { +export function getHashVar(name, defVal) { "use strict"; const re = new RegExp('.*[&#]' + name + '=([^&]*)'), match = document.location.hash.match(re); @@ -50,7 +50,7 @@ export function getHashVar (name, defVal) { // Read a variable from the fragment or the query string // Fragment takes precedence -export function getConfigVar (name, defVal) { +export function getConfigVar(name, defVal) { "use strict"; const val = getHashVar(name); @@ -66,7 +66,7 @@ export function getConfigVar (name, defVal) { */ // No days means only for this browser session -export function createCookie (name, value, days) { +export function createCookie(name, value, days) { "use strict"; let date, expires; if (days) { @@ -86,7 +86,7 @@ export function createCookie (name, value, days) { document.cookie = name + "=" + value + expires + "; path=/" + secure; } -export function readCookie (name, defaultValue) { +export function readCookie(name, defaultValue) { "use strict"; const nameEQ = name + "="; const ca = document.cookie.split(';'); @@ -104,7 +104,7 @@ export function readCookie (name, defaultValue) { return (typeof defaultValue !== 'undefined') ? defaultValue : null; } -export function eraseCookie (name) { +export function eraseCookie(name) { "use strict"; createCookie(name, "", -1); } @@ -115,7 +115,7 @@ export function eraseCookie (name) { let settings = {}; -export function initSettings (callback /*, ...callbackArgs */) { +export function initSettings(callback /*, ...callbackArgs */) { "use strict"; const callbackArgs = Array.prototype.slice.call(arguments, 1); if (window.chrome && window.chrome.storage) { @@ -134,12 +134,12 @@ export function initSettings (callback /*, ...callbackArgs */) { } // Update the settings cache, but do not write to permanent storage -export function setSetting (name, value) { +export function setSetting(name, value) { settings[name] = value; } // No days means only for this browser session -export function writeSetting (name, value) { +export function writeSetting(name, value) { "use strict"; if (settings[name] === value) return; settings[name] = value; @@ -150,7 +150,7 @@ export function writeSetting (name, value) { } } -export function readSetting (name, defaultValue) { +export function readSetting(name, defaultValue) { "use strict"; let value; if ((name in settings) || (window.chrome && window.chrome.storage)) { @@ -170,7 +170,7 @@ export function readSetting (name, defaultValue) { return value; } -export function eraseSetting (name) { +export function eraseSetting(name) { "use strict"; // Deleting here means that next time the setting is read when using local // storage, it will be pulled from local storage again. @@ -185,7 +185,7 @@ export function eraseSetting (name) { } } -export function injectParamIfMissing (path, param, value) { +export function injectParamIfMissing(path, param, value) { // force pretend that we're dealing with a relative path // (assume that we wanted an extra if we pass one in) path = "/" + path; diff --git a/core/util/browser.js b/core/util/browser.js index 3eca5bc0..965ba3cf 100644 --- a/core/util/browser.js +++ b/core/util/browser.js @@ -28,7 +28,7 @@ export let dragThreshold = 10 * (window.devicePixelRatio || 1); let _cursor_uris_supported = null; -export function supportsCursorURIs () { +export function supportsCursorURIs() { if (_cursor_uris_supported === null) { try { const target = document.createElement('canvas'); diff --git a/core/util/events.js b/core/util/events.js index 93cdd2bc..4669aa47 100644 --- a/core/util/events.js +++ b/core/util/events.js @@ -10,11 +10,11 @@ * Cross-browser event and position routines */ -export function getPointerEvent (e) { +export function getPointerEvent(e) { return e.changedTouches ? e.changedTouches[0] : e.touches ? e.touches[0] : e; } -export function stopEvent (e) { +export function stopEvent(e) { e.stopPropagation(); e.preventDefault(); } @@ -57,7 +57,7 @@ const _captureObserver = new MutationObserver(_captureElemChanged); let _captureIndex = 0; -export function setCapture (elem) { +export function setCapture(elem) { if (elem.setCapture) { elem.setCapture(); @@ -108,7 +108,7 @@ export function setCapture (elem) { } } -export function releaseCapture () { +export function releaseCapture() { if (document.releaseCapture) { document.releaseCapture(); diff --git a/core/util/logging.js b/core/util/logging.js index 1f6a71e0..fb2d417d 100644 --- a/core/util/logging.js +++ b/core/util/logging.js @@ -17,7 +17,7 @@ let Info = () => {}; let Warn = () => {}; let Error = () => {}; -export function init_logging (level) { +export function init_logging(level) { if (typeof level === 'undefined') { level = _log_level; } else { @@ -46,7 +46,7 @@ export function init_logging (level) { } } -export function get_logging () { +export function get_logging() { return _log_level; } diff --git a/core/util/polyfill.js b/core/util/polyfill.js index 1971edf8..3e9cbaa3 100644 --- a/core/util/polyfill.js +++ b/core/util/polyfill.js @@ -39,7 +39,7 @@ if (typeof Object.assign != 'function') { /* CustomEvent constructor (taken from MDN) */ (() => { - function CustomEvent (event, params) { + function CustomEvent(event, params) { params = params || { bubbles: false, cancelable: false, detail: undefined }; const evt = document.createEvent( 'CustomEvent' ); evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail ); diff --git a/core/util/strings.js b/core/util/strings.js index b3de5476..1af6c463 100644 --- a/core/util/strings.js +++ b/core/util/strings.js @@ -9,6 +9,6 @@ /* * Decode from UTF-8 */ -export function decodeUTF8 (utf8string) { +export function decodeUTF8(utf8string) { return decodeURIComponent(escape(utf8string)); } diff --git a/tests/test.base64.js b/tests/test.base64.js index a9724489..04bd207b 100644 --- a/tests/test.base64.js +++ b/tests/test.base64.js @@ -2,7 +2,7 @@ const expect = chai.expect; import Base64 from '../core/base64.js'; -describe('Base64 Tools', function() { +describe('Base64 Tools', function () { "use strict"; const BIN_ARR = new Array(256); @@ -13,20 +13,20 @@ describe('Base64 Tools', function() { const B64_STR = "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w=="; - describe('encode', function() { - it('should encode a binary string into Base64', function() { + describe('encode', function () { + it('should encode a binary string into Base64', function () { const encoded = Base64.encode(BIN_ARR); expect(encoded).to.equal(B64_STR); }); }); - describe('decode', function() { - it('should decode a Base64 string into a normal string', function() { + describe('decode', function () { + it('should decode a Base64 string into a normal string', function () { const decoded = Base64.decode(B64_STR); expect(decoded).to.deep.equal(BIN_ARR); }); - it('should throw an error if we have extra characters at the end of the string', function() { + it('should throw an error if we have extra characters at the end of the string', function () { expect(() => Base64.decode(B64_STR+'abcdef')).to.throw(Error); }); }); diff --git a/tests/test.display.js b/tests/test.display.js index 843f75e8..b3595503 100644 --- a/tests/test.display.js +++ b/tests/test.display.js @@ -13,7 +13,7 @@ describe('Display/Canvas Helper', function () { const basic_data = new Uint8Array([0xff, 0x00, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0xff, 0xff, 0xff, 255]); - function make_image_canvas (input_data) { + function make_image_canvas(input_data) { const canvas = document.createElement('canvas'); canvas.width = 4; canvas.height = 4; @@ -24,7 +24,7 @@ describe('Display/Canvas Helper', function () { return canvas; } - function make_image_png (input_data) { + function make_image_png(input_data) { const canvas = make_image_canvas(input_data); const url = canvas.toDataURL(); const data = url.split(",")[1]; @@ -53,13 +53,13 @@ describe('Display/Canvas Helper', function () { expect(display).to.have.displayed(expected); }); - it('should resize the target canvas when resizing the viewport', function() { + it('should resize the target canvas when resizing the viewport', function () { display.viewportChangeSize(2, 2); expect(display._target.width).to.equal(2); expect(display._target.height).to.equal(2); }); - it('should move the viewport if necessary', function() { + it('should move the viewport if necessary', function () { display.viewportChangeSize(5, 5); expect(display.absX(0)).to.equal(0); expect(display.absY(0)).to.equal(0); @@ -67,7 +67,7 @@ describe('Display/Canvas Helper', function () { expect(display._target.height).to.equal(5); }); - it('should limit the viewport to the framebuffer size', function() { + it('should limit the viewport to the framebuffer size', function () { display.viewportChangeSize(6, 6); expect(display._target.width).to.equal(5); expect(display._target.height).to.equal(5); @@ -85,7 +85,7 @@ describe('Display/Canvas Helper', function () { expect(display.flip).to.have.been.calledOnce; }); - it('should show the entire framebuffer when disabling the viewport', function() { + it('should show the entire framebuffer when disabling the viewport', function () { display.clipViewport = false; expect(display.absX(0)).to.equal(0); expect(display.absY(0)).to.equal(0); @@ -93,7 +93,7 @@ describe('Display/Canvas Helper', function () { expect(display._target.height).to.equal(5); }); - it('should ignore viewport changes when the viewport is disabled', function() { + it('should ignore viewport changes when the viewport is disabled', function () { display.clipViewport = false; display.viewportChangeSize(2, 2); display.viewportChangePos(1, 1); @@ -103,7 +103,7 @@ describe('Display/Canvas Helper', function () { expect(display._target.height).to.equal(5); }); - it('should show the entire framebuffer just after enabling the viewport', function() { + it('should show the entire framebuffer just after enabling the viewport', function () { display.clipViewport = false; display.clipViewport = true; expect(display.absX(0)).to.equal(0); diff --git a/tests/test.helper.js b/tests/test.helper.js index 4aff0936..d44bab0f 100644 --- a/tests/test.helper.js +++ b/tests/test.helper.js @@ -4,66 +4,66 @@ import keysyms from '../core/input/keysymdef.js'; import * as KeyboardUtil from "../core/input/util.js"; import * as browser from '../core/util/browser.js'; -describe('Helpers', function() { +describe('Helpers', function () { "use strict"; - describe('keysyms.lookup', function() { - it('should map ASCII characters to keysyms', function() { + describe('keysyms.lookup', function () { + it('should map ASCII characters to keysyms', function () { expect(keysyms.lookup('a'.charCodeAt())).to.be.equal(0x61); expect(keysyms.lookup('A'.charCodeAt())).to.be.equal(0x41); }); - it('should map Latin-1 characters to keysyms', function() { + it('should map Latin-1 characters to keysyms', function () { expect(keysyms.lookup('ø'.charCodeAt())).to.be.equal(0xf8); expect(keysyms.lookup('é'.charCodeAt())).to.be.equal(0xe9); }); - it('should map characters that are in Windows-1252 but not in Latin-1 to keysyms', function() { + it('should map characters that are in Windows-1252 but not in Latin-1 to keysyms', function () { expect(keysyms.lookup('Š'.charCodeAt())).to.be.equal(0x01a9); }); - it('should map characters which aren\'t in Latin1 *or* Windows-1252 to keysyms', function() { + it('should map characters which aren\'t in Latin1 *or* Windows-1252 to keysyms', function () { expect(keysyms.lookup('ũ'.charCodeAt())).to.be.equal(0x03fd); }); - it('should map unknown codepoints to the Unicode range', function() { + it('should map unknown codepoints to the Unicode range', function () { expect(keysyms.lookup('\n'.charCodeAt())).to.be.equal(0x100000a); expect(keysyms.lookup('\u262D'.charCodeAt())).to.be.equal(0x100262d); }); // This requires very recent versions of most browsers... skipping for now - it.skip('should map UCS-4 codepoints to the Unicode range', function() { + it.skip('should map UCS-4 codepoints to the Unicode range', function () { //expect(keysyms.lookup('\u{1F686}'.codePointAt())).to.be.equal(0x101f686); }); }); - describe('getKeycode', function() { - it('should pass through proper code', function() { + describe('getKeycode', function () { + it('should pass through proper code', function () { expect(KeyboardUtil.getKeycode({code: 'Semicolon'})).to.be.equal('Semicolon'); }); - it('should map legacy values', function() { + it('should map legacy values', function () { expect(KeyboardUtil.getKeycode({code: ''})).to.be.equal('Unidentified'); expect(KeyboardUtil.getKeycode({code: 'OSLeft'})).to.be.equal('MetaLeft'); }); - it('should map keyCode to code when possible', function() { + it('should map keyCode to code when possible', function () { expect(KeyboardUtil.getKeycode({keyCode: 0x14})).to.be.equal('CapsLock'); expect(KeyboardUtil.getKeycode({keyCode: 0x5b})).to.be.equal('MetaLeft'); expect(KeyboardUtil.getKeycode({keyCode: 0x35})).to.be.equal('Digit5'); expect(KeyboardUtil.getKeycode({keyCode: 0x65})).to.be.equal('Numpad5'); }); - it('should map keyCode left/right side', function() { + it('should map keyCode left/right side', function () { expect(KeyboardUtil.getKeycode({keyCode: 0x10, location: 1})).to.be.equal('ShiftLeft'); expect(KeyboardUtil.getKeycode({keyCode: 0x10, location: 2})).to.be.equal('ShiftRight'); expect(KeyboardUtil.getKeycode({keyCode: 0x11, location: 1})).to.be.equal('ControlLeft'); expect(KeyboardUtil.getKeycode({keyCode: 0x11, location: 2})).to.be.equal('ControlRight'); }); - it('should map keyCode on numpad', function() { + it('should map keyCode on numpad', function () { expect(KeyboardUtil.getKeycode({keyCode: 0x0d, location: 0})).to.be.equal('Enter'); expect(KeyboardUtil.getKeycode({keyCode: 0x0d, location: 3})).to.be.equal('NumpadEnter'); expect(KeyboardUtil.getKeycode({keyCode: 0x23, location: 0})).to.be.equal('End'); expect(KeyboardUtil.getKeycode({keyCode: 0x23, location: 3})).to.be.equal('Numpad1'); }); - it('should return Unidentified when it cannot map the keyCode', function() { + it('should return Unidentified when it cannot map the keyCode', function () { expect(KeyboardUtil.getKeycode({keycode: 0x42})).to.be.equal('Unidentified'); }); - describe('Fix Meta on macOS', function() { + describe('Fix Meta on macOS', function () { let origNavigator; beforeEach(function () { // window.navigator is a protected read-only property in many @@ -89,44 +89,44 @@ describe('Helpers', function() { Object.defineProperty(window, "navigator", origNavigator); }); - it('should respect ContextMenu on modern browser', function() { + it('should respect ContextMenu on modern browser', function () { expect(KeyboardUtil.getKeycode({code: 'ContextMenu', keyCode: 0x5d})).to.be.equal('ContextMenu'); }); - it('should translate legacy ContextMenu to MetaRight', function() { + it('should translate legacy ContextMenu to MetaRight', function () { expect(KeyboardUtil.getKeycode({keyCode: 0x5d})).to.be.equal('MetaRight'); }); }); }); - describe('getKey', function() { - it('should prefer key', function() { + describe('getKey', function () { + it('should prefer key', function () { if (browser.isIE() || browser.isEdge()) this.skip(); expect(KeyboardUtil.getKey({key: 'a', charCode: 'Š'.charCodeAt(), keyCode: 0x42, which: 0x43})).to.be.equal('a'); }); - it('should map legacy values', function() { + it('should map legacy values', function () { expect(KeyboardUtil.getKey({key: 'Spacebar'})).to.be.equal(' '); expect(KeyboardUtil.getKey({key: 'Left'})).to.be.equal('ArrowLeft'); expect(KeyboardUtil.getKey({key: 'OS'})).to.be.equal('Meta'); expect(KeyboardUtil.getKey({key: 'Win'})).to.be.equal('Meta'); expect(KeyboardUtil.getKey({key: 'UIKeyInputLeftArrow'})).to.be.equal('ArrowLeft'); }); - it('should use code if no key', function() { + it('should use code if no key', function () { expect(KeyboardUtil.getKey({code: 'NumpadBackspace'})).to.be.equal('Backspace'); }); - it('should not use code fallback for character keys', function() { + it('should not use code fallback for character keys', function () { expect(KeyboardUtil.getKey({code: 'KeyA'})).to.be.equal('Unidentified'); expect(KeyboardUtil.getKey({code: 'Digit1'})).to.be.equal('Unidentified'); expect(KeyboardUtil.getKey({code: 'Period'})).to.be.equal('Unidentified'); expect(KeyboardUtil.getKey({code: 'Numpad1'})).to.be.equal('Unidentified'); }); - it('should use charCode if no key', function() { + it('should use charCode if no key', function () { expect(KeyboardUtil.getKey({charCode: 'Š'.charCodeAt(), keyCode: 0x42, which: 0x43})).to.be.equal('Š'); }); - it('should return Unidentified when it cannot map the key', function() { + it('should return Unidentified when it cannot map the key', function () { expect(KeyboardUtil.getKey({keycode: 0x42})).to.be.equal('Unidentified'); }); - describe('Broken key AltGraph on IE/Edge', function() { + describe('Broken key AltGraph on IE/Edge', function () { let origNavigator; beforeEach(function () { // window.navigator is a protected read-only property in many @@ -150,28 +150,28 @@ describe('Helpers', function() { Object.defineProperty(window, "navigator", origNavigator); }); - it('should ignore printable character key on IE', function() { + it('should ignore printable character key on IE', function () { window.navigator.userAgent = "Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko"; expect(KeyboardUtil.getKey({key: 'a'})).to.be.equal('Unidentified'); }); - it('should ignore printable character key on Edge', function() { + it('should ignore printable character key on Edge', function () { window.navigator.userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393"; expect(KeyboardUtil.getKey({key: 'a'})).to.be.equal('Unidentified'); }); - it('should allow non-printable character key on IE', function() { + it('should allow non-printable character key on IE', function () { window.navigator.userAgent = "Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko"; expect(KeyboardUtil.getKey({key: 'Shift'})).to.be.equal('Shift'); }); - it('should allow non-printable character key on Edge', function() { + it('should allow non-printable character key on Edge', function () { window.navigator.userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393"; expect(KeyboardUtil.getKey({key: 'Shift'})).to.be.equal('Shift'); }); }); }); - describe('getKeysym', function() { - describe('Non-character keys', function() { - it('should recognize the right keys', function() { + describe('getKeysym', function () { + describe('Non-character keys', function () { + it('should recognize the right keys', function () { expect(KeyboardUtil.getKeysym({key: 'Enter'})).to.be.equal(0xFF0D); expect(KeyboardUtil.getKeysym({key: 'Backspace'})).to.be.equal(0xFF08); expect(KeyboardUtil.getKeysym({key: 'Tab'})).to.be.equal(0xFF09); @@ -182,38 +182,38 @@ describe('Helpers', function() { expect(KeyboardUtil.getKeysym({key: 'Escape'})).to.be.equal(0xFF1B); expect(KeyboardUtil.getKeysym({key: 'ArrowUp'})).to.be.equal(0xFF52); }); - it('should map left/right side', function() { + it('should map left/right side', function () { expect(KeyboardUtil.getKeysym({key: 'Shift', location: 1})).to.be.equal(0xFFE1); expect(KeyboardUtil.getKeysym({key: 'Shift', location: 2})).to.be.equal(0xFFE2); expect(KeyboardUtil.getKeysym({key: 'Control', location: 1})).to.be.equal(0xFFE3); expect(KeyboardUtil.getKeysym({key: 'Control', location: 2})).to.be.equal(0xFFE4); }); - it('should handle AltGraph', function() { + it('should handle AltGraph', function () { expect(KeyboardUtil.getKeysym({code: 'AltRight', key: 'Alt', location: 2})).to.be.equal(0xFFEA); expect(KeyboardUtil.getKeysym({code: 'AltRight', key: 'AltGraph', location: 2})).to.be.equal(0xFE03); }); - it('should return null for unknown keys', function() { + it('should return null for unknown keys', function () { expect(KeyboardUtil.getKeysym({key: 'Semicolon'})).to.be.null; expect(KeyboardUtil.getKeysym({key: 'BracketRight'})).to.be.null; }); - it('should handle remappings', function() { + it('should handle remappings', function () { expect(KeyboardUtil.getKeysym({code: 'ControlLeft', key: 'Tab'})).to.be.equal(0xFF09); }); }); - describe('Numpad', function() { - it('should handle Numpad numbers', function() { + describe('Numpad', function () { + it('should handle Numpad numbers', function () { if (browser.isIE() || browser.isEdge()) this.skip(); expect(KeyboardUtil.getKeysym({code: 'Digit5', key: '5', location: 0})).to.be.equal(0x0035); expect(KeyboardUtil.getKeysym({code: 'Numpad5', key: '5', location: 3})).to.be.equal(0xFFB5); }); - it('should handle Numpad non-character keys', function() { + it('should handle Numpad non-character keys', function () { expect(KeyboardUtil.getKeysym({code: 'Home', key: 'Home', location: 0})).to.be.equal(0xFF50); expect(KeyboardUtil.getKeysym({code: 'Numpad5', key: 'Home', location: 3})).to.be.equal(0xFF95); expect(KeyboardUtil.getKeysym({code: 'Delete', key: 'Delete', location: 0})).to.be.equal(0xFFFF); expect(KeyboardUtil.getKeysym({code: 'NumpadDecimal', key: 'Delete', location: 3})).to.be.equal(0xFF9F); }); - it('should handle Numpad Decimal key', function() { + it('should handle Numpad Decimal key', function () { if (browser.isIE() || browser.isEdge()) this.skip(); expect(KeyboardUtil.getKeysym({code: 'NumpadDecimal', key: '.', location: 3})).to.be.equal(0xFFAE); expect(KeyboardUtil.getKeysym({code: 'NumpadDecimal', key: ',', location: 3})).to.be.equal(0xFFAC); diff --git a/tests/test.keyboard.js b/tests/test.keyboard.js index a2eed901..77fe3f6f 100644 --- a/tests/test.keyboard.js +++ b/tests/test.keyboard.js @@ -3,7 +3,7 @@ const expect = chai.expect; import Keyboard from '../core/input/keyboard.js'; import * as browser from '../core/util/browser.js'; -describe('Key Event Handling', function() { +describe('Key Event Handling', function () { "use strict"; // The real KeyboardEvent constructor might not work everywhere we @@ -18,8 +18,8 @@ describe('Key Event Handling', function() { return e; } - describe('Decode Keyboard Events', function() { - it('should decode keydown events', function(done) { + describe('Decode Keyboard Events', function () { + it('should decode keydown events', function (done) { if (browser.isIE() || browser.isEdge()) this.skip(); const kbd = new Keyboard(document); kbd.onkeyevent = (keysym, code, down) => { @@ -30,7 +30,7 @@ describe('Key Event Handling', function() { }; kbd._handleKeyDown(keyevent('keydown', {code: 'KeyA', key: 'a'})); }); - it('should decode keyup events', function(done) { + it('should decode keyup events', function (done) { if (browser.isIE() || browser.isEdge()) this.skip(); let calls = 0; const kbd = new Keyboard(document); @@ -46,14 +46,14 @@ describe('Key Event Handling', function() { kbd._handleKeyUp(keyevent('keyup', {code: 'KeyA', key: 'a'})); }); - describe('Legacy keypress Events', function() { - it('should wait for keypress when needed', function() { + describe('Legacy keypress Events', function () { + it('should wait for keypress when needed', function () { const kbd = new Keyboard(document); kbd.onkeyevent = sinon.spy(); kbd._handleKeyDown(keyevent('keydown', {code: 'KeyA', keyCode: 0x41})); expect(kbd.onkeyevent).to.not.have.been.called; }); - it('should decode keypress events', function(done) { + it('should decode keypress events', function (done) { const kbd = new Keyboard(document); kbd.onkeyevent = (keysym, code, down) => { expect(keysym).to.be.equal(0x61); @@ -64,14 +64,14 @@ describe('Key Event Handling', function() { kbd._handleKeyDown(keyevent('keydown', {code: 'KeyA', keyCode: 0x41})); kbd._handleKeyPress(keyevent('keypress', {code: 'KeyA', charCode: 0x61})); }); - it('should ignore keypress with different code', function() { + it('should ignore keypress with different code', function () { const kbd = new Keyboard(document); kbd.onkeyevent = sinon.spy(); kbd._handleKeyDown(keyevent('keydown', {code: 'KeyA', keyCode: 0x41})); kbd._handleKeyPress(keyevent('keypress', {code: 'KeyB', charCode: 0x61})); expect(kbd.onkeyevent).to.not.have.been.called; }); - it('should handle keypress with missing code', function(done) { + it('should handle keypress with missing code', function (done) { const kbd = new Keyboard(document); kbd.onkeyevent = (keysym, code, down) => { expect(keysym).to.be.equal(0x61); @@ -82,7 +82,7 @@ describe('Key Event Handling', function() { kbd._handleKeyDown(keyevent('keydown', {code: 'KeyA', keyCode: 0x41})); kbd._handleKeyPress(keyevent('keypress', {charCode: 0x61})); }); - it('should guess key if no keypress and numeric key', function(done) { + it('should guess key if no keypress and numeric key', function (done) { const kbd = new Keyboard(document); kbd.onkeyevent = (keysym, code, down) => { expect(keysym).to.be.equal(0x32); @@ -92,7 +92,7 @@ describe('Key Event Handling', function() { }; kbd._handleKeyDown(keyevent('keydown', {code: 'Digit2', keyCode: 0x32})); }); - it('should guess key if no keypress and alpha key', function(done) { + it('should guess key if no keypress and alpha key', function (done) { const kbd = new Keyboard(document); kbd.onkeyevent = (keysym, code, down) => { expect(keysym).to.be.equal(0x61); @@ -102,7 +102,7 @@ describe('Key Event Handling', function() { }; kbd._handleKeyDown(keyevent('keydown', {code: 'KeyA', keyCode: 0x41, shiftKey: false})); }); - it('should guess key if no keypress and alpha key (with shift)', function(done) { + it('should guess key if no keypress and alpha key (with shift)', function (done) { const kbd = new Keyboard(document); kbd.onkeyevent = (keysym, code, down) => { expect(keysym).to.be.equal(0x41); @@ -112,7 +112,7 @@ describe('Key Event Handling', function() { }; kbd._handleKeyDown(keyevent('keydown', {code: 'KeyA', keyCode: 0x41, shiftKey: true})); }); - it('should not guess key if no keypress and unknown key', function(done) { + it('should not guess key if no keypress and unknown key', function (done) { const kbd = new Keyboard(document); kbd.onkeyevent = (keysym, code, down) => { expect(keysym).to.be.equal(0); @@ -124,11 +124,11 @@ describe('Key Event Handling', function() { }); }); - describe('suppress the right events at the right time', function() { + describe('suppress the right events at the right time', function () { beforeEach(function () { if (browser.isIE() || browser.isEdge()) this.skip(); }); - it('should suppress anything with a valid key', function() { + it('should suppress anything with a valid key', function () { const kbd = new Keyboard(document, {}); const evt1 = keyevent('keydown', {code: 'KeyA', key: 'a'}); kbd._handleKeyDown(evt1); @@ -137,13 +137,13 @@ describe('Key Event Handling', function() { kbd._handleKeyUp(evt2); expect(evt2.preventDefault).to.have.been.called; }); - it('should not suppress keys without key', function() { + it('should not suppress keys without key', function () { const kbd = new Keyboard(document, {}); const evt = keyevent('keydown', {code: 'KeyA', keyCode: 0x41}); kbd._handleKeyDown(evt); expect(evt.preventDefault).to.not.have.been.called; }); - it('should suppress the following keypress event', function() { + it('should suppress the following keypress event', function () { const kbd = new Keyboard(document, {}); const evt1 = keyevent('keydown', {code: 'KeyA', keyCode: 0x41}); kbd._handleKeyDown(evt1); @@ -154,8 +154,8 @@ describe('Key Event Handling', function() { }); }); - describe('Fake keyup', function() { - it('should fake keyup events for virtual keyboards', function(done) { + describe('Fake keyup', function () { + it('should fake keyup events for virtual keyboards', function (done) { if (browser.isIE() || browser.isEdge()) this.skip(); let count = 0; const kbd = new Keyboard(document); @@ -176,7 +176,7 @@ describe('Key Event Handling', function() { kbd._handleKeyDown(keyevent('keydown', {code: 'Unidentified', key: 'a'})); }); - describe('iOS', function() { + describe('iOS', function () { let origNavigator; beforeEach(function () { // window.navigator is a protected read-only property in many @@ -202,7 +202,7 @@ describe('Key Event Handling', function() { Object.defineProperty(window, "navigator", origNavigator); }); - it('should fake keyup events on iOS', function(done) { + it('should fake keyup events on iOS', function (done) { if (browser.isIE() || browser.isEdge()) this.skip(); let count = 0; const kbd = new Keyboard(document); @@ -225,11 +225,11 @@ describe('Key Event Handling', function() { }); }); - describe('Track Key State', function() { + describe('Track Key State', function () { beforeEach(function () { if (browser.isIE() || browser.isEdge()) this.skip(); }); - it('should send release using the same keysym as the press', function(done) { + it('should send release using the same keysym as the press', function (done) { const kbd = new Keyboard(document); kbd.onkeyevent = (keysym, code, down) => { expect(keysym).to.be.equal(0x61); @@ -241,7 +241,7 @@ describe('Key Event Handling', function() { kbd._handleKeyDown(keyevent('keydown', {code: 'KeyA', key: 'a'})); kbd._handleKeyUp(keyevent('keyup', {code: 'KeyA', key: 'b'})); }); - it('should send the same keysym for multiple presses', function() { + it('should send the same keysym for multiple presses', function () { let count = 0; const kbd = new Keyboard(document); kbd.onkeyevent = (keysym, code, down) => { @@ -254,15 +254,15 @@ describe('Key Event Handling', function() { kbd._handleKeyDown(keyevent('keydown', {code: 'KeyA', key: 'b'})); expect(count).to.be.equal(2); }); - it('should do nothing on keyup events if no keys are down', function() { + it('should do nothing on keyup events if no keys are down', function () { const kbd = new Keyboard(document); kbd.onkeyevent = sinon.spy(); kbd._handleKeyUp(keyevent('keyup', {code: 'KeyA', key: 'a'})); expect(kbd.onkeyevent).to.not.have.been.called; }); - describe('Legacy Events', function() { - it('should track keys using keyCode if no code', function(done) { + describe('Legacy Events', function () { + it('should track keys using keyCode if no code', function (done) { const kbd = new Keyboard(document); kbd.onkeyevent = (keysym, code, down) => { expect(keysym).to.be.equal(0x61); @@ -274,7 +274,7 @@ describe('Key Event Handling', function() { kbd._handleKeyDown(keyevent('keydown', {keyCode: 65, key: 'a'})); kbd._handleKeyUp(keyevent('keyup', {keyCode: 65, key: 'b'})); }); - it('should ignore compositing code', function() { + it('should ignore compositing code', function () { const kbd = new Keyboard(document); kbd.onkeyevent = (keysym, code, down) => { expect(keysym).to.be.equal(0x61); @@ -282,7 +282,7 @@ describe('Key Event Handling', function() { }; kbd._handleKeyDown(keyevent('keydown', {keyCode: 229, key: 'a'})); }); - it('should track keys using keyIdentifier if no code', function(done) { + it('should track keys using keyIdentifier if no code', function (done) { const kbd = new Keyboard(document); kbd.onkeyevent = (keysym, code, down) => { expect(keysym).to.be.equal(0x61); @@ -297,7 +297,7 @@ describe('Key Event Handling', function() { }); }); - describe('Shuffle modifiers on macOS', function() { + describe('Shuffle modifiers on macOS', function () { let origNavigator; beforeEach(function () { // window.navigator is a protected read-only property in many @@ -323,7 +323,7 @@ describe('Key Event Handling', function() { Object.defineProperty(window, "navigator", origNavigator); }); - it('should change Alt to AltGraph', function() { + it('should change Alt to AltGraph', function () { let count = 0; const kbd = new Keyboard(document); kbd.onkeyevent = (keysym, code, down) => { @@ -342,7 +342,7 @@ describe('Key Event Handling', function() { kbd._handleKeyDown(keyevent('keydown', {code: 'AltRight', key: 'Alt', location: 2})); expect(count).to.be.equal(2); }); - it('should change left Super to Alt', function(done) { + it('should change left Super to Alt', function (done) { const kbd = new Keyboard(document); kbd.onkeyevent = (keysym, code, down) => { expect(keysym).to.be.equal(0xFFE9); @@ -351,7 +351,7 @@ describe('Key Event Handling', function() { }; kbd._handleKeyDown(keyevent('keydown', {code: 'MetaLeft', key: 'Meta', location: 1})); }); - it('should change right Super to left Super', function(done) { + it('should change right Super to left Super', function (done) { const kbd = new Keyboard(document); kbd.onkeyevent = (keysym, code, down) => { expect(keysym).to.be.equal(0xFFEB); @@ -362,7 +362,7 @@ describe('Key Event Handling', function() { }); }); - describe('Escape AltGraph on Windows', function() { + describe('Escape AltGraph on Windows', function () { let origNavigator; beforeEach(function () { // window.navigator is a protected read-only property in many diff --git a/tests/test.localization.js b/tests/test.localization.js index 7ea11d66..9570c179 100644 --- a/tests/test.localization.js +++ b/tests/test.localization.js @@ -1,7 +1,7 @@ const expect = chai.expect; import { l10n } from '../app/localization.js'; -describe('Localization', function() { +describe('Localization', function () { "use strict"; describe('language selection', function () { @@ -30,40 +30,40 @@ describe('Localization', function() { Object.defineProperty(window, "navigator", origNavigator); }); - it('should use English by default', function() { + it('should use English by default', function () { expect(l10n.language).to.equal('en'); }); - it('should use English if no user language matches', function() { + it('should use English if no user language matches', function () { window.navigator.languages = ["nl", "de"]; l10n.setup(["es", "fr"]); expect(l10n.language).to.equal('en'); }); - it('should use the most preferred user language', function() { + it('should use the most preferred user language', function () { window.navigator.languages = ["nl", "de", "fr"]; l10n.setup(["es", "fr", "de"]); expect(l10n.language).to.equal('de'); }); - it('should prefer sub-languages languages', function() { + it('should prefer sub-languages languages', function () { window.navigator.languages = ["pt-BR"]; l10n.setup(["pt", "pt-BR"]); expect(l10n.language).to.equal('pt-BR'); }); - it('should fall back to language "parents"', function() { + it('should fall back to language "parents"', function () { window.navigator.languages = ["pt-BR"]; l10n.setup(["fr", "pt", "de"]); expect(l10n.language).to.equal('pt'); }); - it('should not use specific language when user asks for a generic language', function() { + it('should not use specific language when user asks for a generic language', function () { window.navigator.languages = ["pt", "de"]; l10n.setup(["fr", "pt-BR", "de"]); expect(l10n.language).to.equal('de'); }); - it('should handle underscore as a separator', function() { + it('should handle underscore as a separator', function () { window.navigator.languages = ["pt-BR"]; l10n.setup(["pt_BR"]); expect(l10n.language).to.equal('pt_BR'); }); - it('should handle difference in case', function() { + it('should handle difference in case', function () { window.navigator.languages = ["pt-br"]; l10n.setup(["pt-BR"]); expect(l10n.language).to.equal('pt-BR'); diff --git a/tests/test.mouse.js b/tests/test.mouse.js index 9630706e..78c74f15 100644 --- a/tests/test.mouse.js +++ b/tests/test.mouse.js @@ -2,7 +2,7 @@ const expect = chai.expect; import Mouse from '../core/input/mouse.js'; -describe('Mouse Event Handling', function() { +describe('Mouse Event Handling', function () { "use strict"; let target; @@ -36,8 +36,8 @@ describe('Mouse Event Handling', function() { }; const touchevent = mouseevent; - describe('Decode Mouse Events', function() { - it('should decode mousedown events', function(done) { + describe('Decode Mouse Events', function () { + it('should decode mousedown events', function (done) { const mouse = new Mouse(target); mouse.onmousebutton = (x, y, down, bmask) => { expect(bmask).to.be.equal(0x01); @@ -46,7 +46,7 @@ describe('Mouse Event Handling', function() { }; mouse._handleMouseDown(mouseevent('mousedown', { button: '0x01' })); }); - it('should decode mouseup events', function(done) { + it('should decode mouseup events', function (done) { let calls = 0; const mouse = new Mouse(target); mouse.onmousebutton = (x, y, down, bmask) => { @@ -59,7 +59,7 @@ describe('Mouse Event Handling', function() { mouse._handleMouseDown(mouseevent('mousedown', { button: '0x01' })); mouse._handleMouseUp(mouseevent('mouseup', { button: '0x01' })); }); - it('should decode mousemove events', function(done) { + it('should decode mousemove events', function (done) { const mouse = new Mouse(target); mouse.onmousemove = (x, y) => { // Note that target relative coordinates are sent @@ -70,7 +70,7 @@ describe('Mouse Event Handling', function() { mouse._handleMouseMove(mouseevent('mousemove', { clientX: 50, clientY: 20 })); }); - it('should decode mousewheel events', function(done) { + it('should decode mousewheel events', function (done) { let calls = 0; const mouse = new Mouse(target); mouse.onmousebutton = (x, y, down, bmask) => { @@ -89,12 +89,12 @@ describe('Mouse Event Handling', function() { }); }); - describe('Double-click for Touch', function() { + describe('Double-click for Touch', function () { beforeEach(function () { this.clock = sinon.useFakeTimers(); }); afterEach(function () { this.clock.restore(); }); - it('should use same pos for 2nd tap if close enough', function(done) { + it('should use same pos for 2nd tap if close enough', function (done) { let calls = 0; const mouse = new Mouse(target); mouse.onmousebutton = (x, y, down, bmask) => { @@ -125,7 +125,7 @@ describe('Mouse Event Handling', function() { 'touchend', { touches: [{ clientX: 66, clientY: 36 }]})); }); - it('should not modify 2nd tap pos if far apart', function(done) { + it('should not modify 2nd tap pos if far apart', function (done) { let calls = 0; const mouse = new Mouse(target); mouse.onmousebutton = (x, y, down, bmask) => { @@ -154,7 +154,7 @@ describe('Mouse Event Handling', function() { 'touchend', { touches: [{ clientX: 56, clientY: 36 }]})); }); - it('should not modify 2nd tap pos if not soon enough', function(done) { + it('should not modify 2nd tap pos if not soon enough', function (done) { let calls = 0; const mouse = new Mouse(target); mouse.onmousebutton = (x, y, down, bmask) => { @@ -183,7 +183,7 @@ describe('Mouse Event Handling', function() { 'touchend', { touches: [{ clientX: 66, clientY: 36 }]})); }); - it('should not modify 2nd tap pos if not touch', function(done) { + it('should not modify 2nd tap pos if not touch', function (done) { let calls = 0; const mouse = new Mouse(target); mouse.onmousebutton = (x, y, down, bmask) => { @@ -214,7 +214,7 @@ describe('Mouse Event Handling', function() { }); - describe('Accumulate mouse wheel events with small delta', function() { + describe('Accumulate mouse wheel events with small delta', function () { beforeEach(function () { this.clock = sinon.useFakeTimers(); }); afterEach(function () { this.clock.restore(); }); diff --git a/tests/test.rfb.js b/tests/test.rfb.js index 70859da2..9b787f23 100644 --- a/tests/test.rfb.js +++ b/tests/test.rfb.js @@ -10,7 +10,7 @@ import FakeWebSocket from './fake.websocket.js'; (() => { if (typeof window.UIEvent === "function") return; - function UIEvent ( event, params ) { + function UIEvent( event, params ) { params = params || { bubbles: false, cancelable: false, view: window, detail: undefined }; const evt = document.createEvent( 'UIEvent' ); evt.initUIEvent( event, params.bubbles, params.cancelable, params.view, params.detail ); @@ -41,7 +41,7 @@ function push32(arr, num) { num & 0xFF); } -describe('Remote Frame Buffer Protocol Client', function() { +describe('Remote Frame Buffer Protocol Client', function () { let clock; let raf; @@ -99,7 +99,7 @@ describe('Remote Frame Buffer Protocol Client', function() { container = null; }); - function make_rfb (url, options) { + function make_rfb(url, options) { url = url || 'wss://host:8675'; const rfb = new RFB(container, url, options); clock.tick(); @@ -931,7 +931,7 @@ describe('Remote Frame Buffer Protocol Client', function() { }); describe('ProtocolVersion', function () { - function send_ver (ver, client) { + function send_ver(ver, client) { const arr = new Uint8Array(12); for (let i = 0; i < ver.length; i++) { arr[i+4] = ver.charCodeAt(i); @@ -1192,7 +1192,7 @@ describe('Remote Frame Buffer Protocol Client', function() { expect(client._negotiate_std_vnc_auth).to.have.been.calledOnce; }); - it('should fire the credentialsrequired event if all credentials are missing', function() { + it('should fire the credentialsrequired event if all credentials are missing', function () { const spy = sinon.spy(); client.addEventListener("credentialsrequired", spy); client._rfb_credentials = {}; @@ -1203,7 +1203,7 @@ describe('Remote Frame Buffer Protocol Client', function() { expect(spy.args[0][0].detail.types).to.have.members(["username", "password", "target"]); }); - it('should fire the credentialsrequired event if some credentials are missing', function() { + it('should fire the credentialsrequired event if some credentials are missing', function () { const spy = sinon.spy(); client.addEventListener("credentialsrequired", spy); client._rfb_credentials = { username: 'user', @@ -1588,7 +1588,7 @@ describe('Remote Frame Buffer Protocol Client', function() { target_data_check = new Uint8Array(target_data_check_arr); }); - function send_fbu_msg (rect_info, rect_data, client, rect_cnt) { + function send_fbu_msg(rect_info, rect_data, client, rect_cnt) { let data = []; if (!rect_cnt || rect_cnt > -1) { @@ -1912,7 +1912,7 @@ describe('Remote Frame Buffer Protocol Client', function() { sinon.spy(client._display, 'resize'); }); - function make_screen_data (nr_of_screens) { + function make_screen_data(nr_of_screens) { const data = []; push8(data, nr_of_screens); // number-of-screens push8(data, 0); // padding diff --git a/tests/test.util.js b/tests/test.util.js index bbbf4c4f..201acc8b 100644 --- a/tests/test.util.js +++ b/tests/test.util.js @@ -3,7 +3,7 @@ const expect = chai.expect; import * as Log from '../core/util/logging.js'; -describe('Utils', function() { +describe('Utils', function () { "use strict"; describe('logging functions', function () { diff --git a/tests/test.websock.js b/tests/test.websock.js index 05b83f21..491d30d4 100644 --- a/tests/test.websock.js +++ b/tests/test.websock.js @@ -3,7 +3,7 @@ const expect = chai.expect; import Websock from '../core/websock.js'; import FakeWebSocket from './fake.websocket.js'; -describe('Websock', function() { +describe('Websock', function () { "use strict"; describe('Queue methods', function () { diff --git a/tests/test.webutil.js b/tests/test.webutil.js index 3d6f0a5d..27397041 100644 --- a/tests/test.webutil.js +++ b/tests/test.webutil.js @@ -4,23 +4,23 @@ const expect = chai.expect; import * as WebUtil from '../app/webutil.js'; -describe('WebUtil', function() { +describe('WebUtil', function () { "use strict"; describe('settings', function () { - describe('localStorage', function() { + describe('localStorage', function () { let chrome = window.chrome; - before(function() { + before(function () { chrome = window.chrome; window.chrome = null; }); - after(function() { + after(function () { window.chrome = chrome; }); let origLocalStorage; - beforeEach(function() { + beforeEach(function () { origLocalStorage = Object.getOwnPropertyDescriptor(window, "localStorage"); if (origLocalStorage === undefined) { // Object.getOwnPropertyDescriptor() doesn't work @@ -41,56 +41,56 @@ describe('WebUtil', function() { WebUtil.initSettings(); }); - afterEach(function() { + afterEach(function () { Object.defineProperty(window, "localStorage", origLocalStorage); }); - describe('writeSetting', function() { - it('should save the setting value to local storage', function() { + describe('writeSetting', function () { + it('should save the setting value to local storage', function () { WebUtil.writeSetting('test', 'value'); expect(window.localStorage.setItem).to.have.been.calledWithExactly('test', 'value'); expect(WebUtil.readSetting('test')).to.equal('value'); }); }); - describe('setSetting', function() { - it('should update the setting but not save to local storage', function() { + describe('setSetting', function () { + it('should update the setting but not save to local storage', function () { WebUtil.setSetting('test', 'value'); expect(window.localStorage.setItem).to.not.have.been.called; expect(WebUtil.readSetting('test')).to.equal('value'); }); }); - describe('readSetting', function() { - it('should read the setting value from local storage', function() { + describe('readSetting', function () { + it('should read the setting value from local storage', function () { localStorage.getItem.returns('value'); expect(WebUtil.readSetting('test')).to.equal('value'); }); - it('should return the default value when not in local storage', function() { + it('should return the default value when not in local storage', function () { expect(WebUtil.readSetting('test', 'default')).to.equal('default'); }); - it('should return the cached value even if local storage changed', function() { + it('should return the cached value even if local storage changed', function () { localStorage.getItem.returns('value'); expect(WebUtil.readSetting('test')).to.equal('value'); localStorage.getItem.returns('something else'); expect(WebUtil.readSetting('test')).to.equal('value'); }); - it('should cache the value even if it is not initially in local storage', function() { + it('should cache the value even if it is not initially in local storage', function () { expect(WebUtil.readSetting('test')).to.be.null; localStorage.getItem.returns('value'); expect(WebUtil.readSetting('test')).to.be.null; }); - it('should return the default value always if the first read was not in local storage', function() { + it('should return the default value always if the first read was not in local storage', function () { expect(WebUtil.readSetting('test', 'default')).to.equal('default'); localStorage.getItem.returns('value'); expect(WebUtil.readSetting('test', 'another default')).to.equal('another default'); }); - it('should return the last local written value', function() { + it('should return the last local written value', function () { localStorage.getItem.returns('value'); expect(WebUtil.readSetting('test')).to.equal('value'); WebUtil.writeSetting('test', 'something else'); @@ -99,18 +99,18 @@ describe('WebUtil', function() { }); // this doesn't appear to be used anywhere - describe('eraseSetting', function() { - it('should remove the setting from local storage', function() { + describe('eraseSetting', function () { + it('should remove the setting from local storage', function () { WebUtil.eraseSetting('test'); expect(window.localStorage.removeItem).to.have.been.calledWithExactly('test'); }); }); }); - describe('chrome.storage', function() { + describe('chrome.storage', function () { let chrome = window.chrome; let settings = {}; - before(function() { + before(function () { chrome = window.chrome; window.chrome = { storage: { @@ -122,49 +122,49 @@ describe('WebUtil', function() { } }; }); - after(function() { + after(function () { window.chrome = chrome; }); const csSandbox = sinon.createSandbox(); - beforeEach(function() { + beforeEach(function () { settings = {}; csSandbox.spy(window.chrome.storage.sync, 'set'); csSandbox.spy(window.chrome.storage.sync, 'remove'); WebUtil.initSettings(); }); - afterEach(function() { + afterEach(function () { csSandbox.restore(); }); - describe('writeSetting', function() { - it('should save the setting value to chrome storage', function() { + describe('writeSetting', function () { + it('should save the setting value to chrome storage', function () { WebUtil.writeSetting('test', 'value'); expect(window.chrome.storage.sync.set).to.have.been.calledWithExactly(sinon.match({ test: 'value' })); expect(WebUtil.readSetting('test')).to.equal('value'); }); }); - describe('setSetting', function() { - it('should update the setting but not save to chrome storage', function() { + describe('setSetting', function () { + it('should update the setting but not save to chrome storage', function () { WebUtil.setSetting('test', 'value'); expect(window.chrome.storage.sync.set).to.not.have.been.called; expect(WebUtil.readSetting('test')).to.equal('value'); }); }); - describe('readSetting', function() { - it('should read the setting value from chrome storage', function() { + describe('readSetting', function () { + it('should read the setting value from chrome storage', function () { settings.test = 'value'; expect(WebUtil.readSetting('test')).to.equal('value'); }); - it('should return the default value when not in chrome storage', function() { + it('should return the default value when not in chrome storage', function () { expect(WebUtil.readSetting('test', 'default')).to.equal('default'); }); - it('should return the last local written value', function() { + it('should return the last local written value', function () { settings.test = 'value'; expect(WebUtil.readSetting('test')).to.equal('value'); WebUtil.writeSetting('test', 'something else'); @@ -173,8 +173,8 @@ describe('WebUtil', function() { }); // this doesn't appear to be used anywhere - describe('eraseSetting', function() { - it('should remove the setting from chrome storage', function() { + describe('eraseSetting', function () { + it('should remove the setting from chrome storage', function () { WebUtil.eraseSetting('test'); expect(window.chrome.storage.sync.remove).to.have.been.calledWithExactly('test'); }); diff --git a/utils/use_require.js b/utils/use_require.js index c575010d..24879271 100755 --- a/utils/use_require.js +++ b/utils/use_require.js @@ -84,7 +84,7 @@ function walkDir(base_path, cb, filter) { }); } -function transform_html (legacy_scripts, only_legacy) { +function transform_html(legacy_scripts, only_legacy) { // write out the modified vnc.html file that works with the bundle const src_html_path = path.resolve(__dirname, '..', 'vnc.html'); const out_html_path = path.resolve(paths.out_dir_base, 'vnc.html');