From 8fb580217c2a7710c042685d1fa4ccbc278dafd3 Mon Sep 17 00:00:00 2001 From: Long Ho Date: Mon, 25 Jan 2021 13:33:56 -0500 Subject: [PATCH] fix: avoid ES6+ syntax in client scripts (#3629) * remove template literals and arrow functions that break in IE11 Fixes #3630 --- client/karma.js | 7 ++++--- client/updater.js | 22 +++++++++++----------- static/karma.js | 29 +++++++++++++++-------------- 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/client/karma.js b/client/karma.js index 0734822ff..20a5e19e0 100644 --- a/client/karma.js +++ b/client/karma.js @@ -191,7 +191,7 @@ function Karma (updater, socket, iframe, opener, navigator, location, document) } socket.emit('karma_error', message) - self.updater.updateTestStatus(`karma_error ${message}`) + self.updater.updateTestStatus('karma_error ' + message) this.complete() return false } @@ -240,8 +240,9 @@ function Karma (updater, socket, iframe, opener, navigator, location, document) // A test could have incorrectly issued a navigate. Wait one turn // to ensure the error from an incorrect navigate is processed. - setTimeout(() => { - if (this.config.clearContext) { + var config = this.config + setTimeout(function () { + if (config.clearContext) { navigateContextTo('about:blank') } diff --git a/client/updater.js b/client/updater.js index 3365b5253..569709e3d 100644 --- a/client/updater.js +++ b/client/updater.js @@ -29,7 +29,7 @@ function StatusUpdater (socket, titleElement, bannerElement, browsersElement) { if (!titleElement || !bannerElement) { return } - titleElement.textContent = `Karma v ${VERSION} - ${connectionText}; test: ${testText}; ${pingText}` + titleElement.textContent = 'Karma v ' + VERSION + ' - ' + connectionText + '; test: ' + testText + '; ' + pingText bannerElement.className = connectionText === 'connected' ? 'online' : 'offline' } @@ -46,32 +46,32 @@ function StatusUpdater (socket, titleElement, bannerElement, browsersElement) { updateBanner() } - socket.on('connect', () => { + socket.on('connect', function () { updateConnectionStatus('connected') }) - socket.on('disconnect', () => { + socket.on('disconnect', function () { updateConnectionStatus('disconnected') }) - socket.on('reconnecting', (sec) => { - updateConnectionStatus(`reconnecting in ${sec} seconds`) + socket.on('reconnecting', function (sec) { + updateConnectionStatus('reconnecting in ' + sec + ' seconds') }) - socket.on('reconnect', () => { + socket.on('reconnect', function () { updateConnectionStatus('reconnected') }) - socket.on('reconnect_failed', () => { + socket.on('reconnect_failed', function () { updateConnectionStatus('reconnect_failed') }) socket.on('info', updateBrowsersInfo) - socket.on('disconnect', () => { + socket.on('disconnect', function () { updateBrowsersInfo([]) }) - socket.on('ping', () => { + socket.on('ping', function () { updatePingStatus('ping...') }) - socket.on('pong', (latency) => { - updatePingStatus(`ping ${latency}ms`) + socket.on('pong', function (latency) { + updatePingStatus('ping ' + latency + 'ms') }) return { updateTestStatus: updateTestStatus } diff --git a/static/karma.js b/static/karma.js index 8c08d3fca..1c1111450 100644 --- a/static/karma.js +++ b/static/karma.js @@ -201,7 +201,7 @@ function Karma (updater, socket, iframe, opener, navigator, location, document) } socket.emit('karma_error', message) - self.updater.updateTestStatus(`karma_error ${message}`) + self.updater.updateTestStatus('karma_error ' + message) this.complete() return false } @@ -250,8 +250,9 @@ function Karma (updater, socket, iframe, opener, navigator, location, document) // A test could have incorrectly issued a navigate. Wait one turn // to ensure the error from an incorrect navigate is processed. - setTimeout(() => { - if (this.config.clearContext) { + var config = this.config + setTimeout(function () { + if (config.clearContext) { navigateContextTo('about:blank') } @@ -384,7 +385,7 @@ function StatusUpdater (socket, titleElement, bannerElement, browsersElement) { if (!titleElement || !bannerElement) { return } - titleElement.textContent = `Karma v ${VERSION} - ${connectionText}; test: ${testText}; ${pingText}` + titleElement.textContent = 'Karma v ' + VERSION + ' - ' + connectionText + '; test: ' + testText + '; ' + pingText bannerElement.className = connectionText === 'connected' ? 'online' : 'offline' } @@ -401,32 +402,32 @@ function StatusUpdater (socket, titleElement, bannerElement, browsersElement) { updateBanner() } - socket.on('connect', () => { + socket.on('connect', function () { updateConnectionStatus('connected') }) - socket.on('disconnect', () => { + socket.on('disconnect', function () { updateConnectionStatus('disconnected') }) - socket.on('reconnecting', (sec) => { - updateConnectionStatus(`reconnecting in ${sec} seconds`) + socket.on('reconnecting', function (sec) { + updateConnectionStatus('reconnecting in ' + sec + ' seconds') }) - socket.on('reconnect', () => { + socket.on('reconnect', function () { updateConnectionStatus('reconnected') }) - socket.on('reconnect_failed', () => { + socket.on('reconnect_failed', function () { updateConnectionStatus('reconnect_failed') }) socket.on('info', updateBrowsersInfo) - socket.on('disconnect', () => { + socket.on('disconnect', function () { updateBrowsersInfo([]) }) - socket.on('ping', () => { + socket.on('ping', function () { updatePingStatus('ping...') }) - socket.on('pong', (latency) => { - updatePingStatus(`ping ${latency}ms`) + socket.on('pong', function (latency) { + updatePingStatus('ping ' + latency + 'ms') }) return { updateTestStatus: updateTestStatus }