Skip to content

Commit 306e565

Browse files
committed
fix(context): Updated postMessage listener to stop validating non-Karma messages
1 parent 1e526e3 commit 306e565

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

client/karma.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ var Karma = function (socket, iframe, opener, navigator, location) {
3535
}
3636

3737
// Take action based on the message type
38-
var method = evt.data.method
39-
if (!self[method]) {
40-
self.error('Received `postMessage` for "' + method + '" but the method doesn\'t exist')
41-
return
38+
var method = evt.data.__karmaMethod
39+
if (method) {
40+
if (!self[method]) {
41+
self.error('Received `postMessage` for "' + method + '" but the method doesn\'t exist')
42+
return
43+
}
44+
self[method].apply(self, evt.data.__karmaArguments)
4245
}
43-
self[method].apply(self, evt.data.arguments)
4446
}, false)
4547
}
4648

context/karma.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ ContextKarma.getDirectCallParentKarmaMethod = function (parentWindow) {
130130
}
131131
ContextKarma.getPostMessageCallParentKarmaMethod = function (parentWindow) {
132132
return function postMessageCallParentKarmaMethod (method, args) {
133-
parentWindow.postMessage({method: method, arguments: args}, window.location.origin)
133+
parentWindow.postMessage({__karmaMethod: method, __karmaArguments: args}, window.location.origin)
134134
}
135135
}
136136

0 commit comments

Comments
 (0)