From 27af5f758589da4327bcf593e9ddaec95c01c92c Mon Sep 17 00:00:00 2001
From: johnjbarton <johnjbarton@johnjbarton.com>
Date: Mon, 22 Feb 2021 11:05:00 -0800
Subject: [PATCH] fix(client): clearContext after complete sent

When useiframe false and clearContext true and IE11, the clearContext
blocks the complete event.
---
 client/karma.js | 7 +++----
 static/karma.js | 7 +++----
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/client/karma.js b/client/karma.js
index 5586bdc9e..0cc7556e0 100644
--- a/client/karma.js
+++ b/client/karma.js
@@ -236,13 +236,12 @@ function Karma (updater, socket, iframe, opener, navigator, location, document)
     // to ensure the error from an incorrect navigate is processed.
     var config = this.config
     setTimeout(function () {
+      socket.emit('complete', result || {})
       if (config.clearContext) {
         navigateContextTo('about:blank')
+      } else {
+        self.updater.updateTestStatus('complete')
       }
-
-      socket.emit('complete', result || {})
-      self.updater.updateTestStatus('complete')
-
       if (returnUrl) {
         location.href = returnUrl
       }
diff --git a/static/karma.js b/static/karma.js
index 23b7c1ae2..b630fe256 100644
--- a/static/karma.js
+++ b/static/karma.js
@@ -246,13 +246,12 @@ function Karma (updater, socket, iframe, opener, navigator, location, document)
     // to ensure the error from an incorrect navigate is processed.
     var config = this.config
     setTimeout(function () {
+      socket.emit('complete', result || {})
       if (config.clearContext) {
         navigateContextTo('about:blank')
+      } else {
+        self.updater.updateTestStatus('complete')
       }
-
-      socket.emit('complete', result || {})
-      self.updater.updateTestStatus('complete')
-
       if (returnUrl) {
         location.href = returnUrl
       }