From dafc9fb4637f478c07b19a70faad4b8fb2e1123b Mon Sep 17 00:00:00 2001 From: johnjbarton Date: Thu, 1 Oct 2020 16:47:40 -0700 Subject: [PATCH] fix(context): do not error when karma is navigating Change the flag name to karmaNavigating and set it along all paths where karma deliberately navigates. Other paths must be wrong. Fixes #3560 --- client/karma.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/client/karma.js b/client/karma.js index 2bd4f2cf3..2d8cb8275 100644 --- a/client/karma.js +++ b/client/karma.js @@ -4,7 +4,7 @@ var util = require('../common/util') function Karma (socket, iframe, opener, navigator, location, document) { var startEmitted = false - var reloadingContext = false + var karmaNavigating = false var self = this var queryParams = util.parseQueryParams(location.search) var browserId = queryParams.id || util.generateId('manual-') @@ -80,6 +80,7 @@ function Karma (socket, iframe, opener, navigator, location, document) { var childWindow = null function navigateContextTo (url) { + karmaNavigating = true if (self.config.useIframe === false) { // run in new window if (self.config.runInParent === false) { @@ -115,6 +116,7 @@ function Karma (socket, iframe, opener, navigator, location, document) { } document.body.appendChild(ele) } else { + karmaNavigating = false window.__karma__.loaded() } } @@ -127,16 +129,14 @@ function Karma (socket, iframe, opener, navigator, location, document) { } this.onbeforeunload = function () { - if (!reloadingContext) { + if (!karmaNavigating) { // TODO(vojta): show what test (with explanation about jasmine.UPDATE_INTERVAL) self.error('Some of your tests did a full page reload!') } - reloadingContext = false + karmaNavigating = false } function clearContext () { - reloadingContext = true - navigateContextTo('about:blank') }