Skip to content

Commit 0055bc5

Browse files
authoredMar 29, 2021
fix: fix running tests in IE9 (#3668)
So the symptom is that after Karma page is loaded in IE9 the tests don't run and Karma is stuck at the "starting" step. Reloading the page once or twice makes IE9 connect to the server and tests pass successfully. After an "exciting" debugging session I figured out that the problem is that on the first load (and sometimes after the page reload) [`io` variable](https://github.com/karma-runner/karma/blob/026fff870913fb6cd2858dd962935dc74c92b725/client/main.js#L14), which should be set by the `socket.io.js` script is undefined. It looks like IE9 silently stops executing `socket.io.js` script somewhere midway and switches to the next script causing the `io` variable to be undefined. I assume it hits some limit or threshold or whatnot. Couldn't find much information on the Internet, besides people experiencing similar issues when loading e.g. unminified jQuery and their own code firing before the `$` variable is available. No good solutions found. Checking the `socket.io.js` contents, I have noticed that v2 served the minified client script on that path, while v3 now serves the unminified code. Presumably the huge script size is what causing IE9 to choke. Switching back to the minified socket.io client bundle allows tests to pass in IE9. With the fix, tests passed 5 times in a row, while without it they fail every time, so I assume it does resolve the problem. Fixes #3665
1 parent 026fff8 commit 0055bc5

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed
 

‎static/client.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ <h1 id="title">Karma - starting</h1>
109109

110110
<iframe id="context" src="about:blank" width="100%" height="100%"></iframe>
111111

112-
<script src="socket.io/socket.io.js"></script>
112+
<script src="socket.io/socket.io.min.js"></script>
113113
<script src="karma.js"></script>
114114
</body>
115115
</html>

‎static/client_with_context.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
<div id="banner" class="offline">
105105
<h1 id="title">Karma - starting</h1>
106106
</div>
107-
<script src="socket.io/socket.io.js"></script>
107+
<script src="socket.io/socket.io.min.js"></script>
108108
<script src="karma.js"></script>
109109
<script src="context.js"></script>
110110
<!-- The scripts need to be at the end of body, so that some test running frameworks

‎test/client/karma.conf.js

+7
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ const launchers = {
2727
browser_version: '11.0',
2828
os: 'Windows',
2929
os_version: '10'
30+
},
31+
bs_ie9: {
32+
base: 'BrowserStack',
33+
browser: 'IE',
34+
browser_version: '9.0',
35+
os: 'Windows',
36+
os_version: '7'
3037
}
3138
}
3239

0 commit comments

Comments
 (0)
Please sign in to comment.