Skip to content

Commit 571191c

Browse files
Curquhartjohnjbarton
authored andcommitted
fix(client): fix issue with loaded on safari 10 (#3252)
Safari 10 supports type=module but ignores nomodule which causes loaded() to execute twice. Fixes #3198
1 parent 376142e commit 571191c

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

context/karma.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ function ContextKarma (callParentKarmaMethod) {
66
// Define local variables
77
var hasError = false
88
var self = this
9+
var isLoaded = false
910

1011
// Define our loggers
1112
// DEV: These are intentionally repeated in client and context
@@ -36,7 +37,8 @@ function ContextKarma (callParentKarmaMethod) {
3637
// all files loaded, let's start the execution
3738
this.loaded = function () {
3839
// has error -> cancel
39-
if (!hasError) {
40+
if (!hasError && !isLoaded) {
41+
isLoaded = true
4042
try {
4143
this.start(this.config)
4244
} catch (error) {

test/client/karma.spec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,5 +433,20 @@ describe('Karma', function () {
433433

434434
assert.equal(iframe.src, CURRENT_URL)
435435
})
436+
437+
it('should accept multiple calls to loaded', function () {
438+
// support for Safari 10 since it supports type=module but not nomodule.
439+
var config = ck.config = {
440+
useIframe: true
441+
}
442+
443+
socket.emit('execute', config)
444+
assert(!startSpy.called)
445+
446+
ck.loaded()
447+
ck.loaded()
448+
assert(startSpy.calledWith(config))
449+
assert(startSpy.getCalls().length === 1)
450+
})
436451
})
437452
})

0 commit comments

Comments
 (0)