Skip to content

Commit

Permalink
fix(context): Updated postMessage listener to stop validating non-Kar…
Browse files Browse the repository at this point in the history
…ma messages
  • Loading branch information
twolfson committed Jul 13, 2016
1 parent 1e526e3 commit 306e565
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions client/karma.js
Expand Up @@ -35,12 +35,14 @@ var Karma = function (socket, iframe, opener, navigator, location) {
}

// Take action based on the message type
var method = evt.data.method
if (!self[method]) {
self.error('Received `postMessage` for "' + method + '" but the method doesn\'t exist')
return
var method = evt.data.__karmaMethod
if (method) {
if (!self[method]) {
self.error('Received `postMessage` for "' + method + '" but the method doesn\'t exist')
return
}
self[method].apply(self, evt.data.__karmaArguments)
}
self[method].apply(self, evt.data.arguments)
}, false)
}

Expand Down
2 changes: 1 addition & 1 deletion context/karma.js
Expand Up @@ -130,7 +130,7 @@ ContextKarma.getDirectCallParentKarmaMethod = function (parentWindow) {
}
ContextKarma.getPostMessageCallParentKarmaMethod = function (parentWindow) {
return function postMessageCallParentKarmaMethod (method, args) {
parentWindow.postMessage({method: method, arguments: args}, window.location.origin)
parentWindow.postMessage({__karmaMethod: method, __karmaArguments: args}, window.location.origin)
}
}

Expand Down

0 comments on commit 306e565

Please sign in to comment.