Skip to content

Commit

Permalink
Extra safety around getting source window from post message
Browse files Browse the repository at this point in the history
  • Loading branch information
bluepnume committed Jan 2, 2019
1 parent 02c36e4 commit 11eb25e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/drivers/receive/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,19 @@ export function messageListener(event : { source : CrossDomainWindowType, origin

// $FlowFixMe
let messageEvent : MessageEvent = {
source: event.source || event.sourceElement,
source: event.source || event.sourceElement || event.srcElement,
origin: event.origin || (event.originalEvent && event.originalEvent.origin),
data: event.data
};

if (!messageEvent.source) {
throw new Error(`Post message did not have source window`);
}

if (!messageEvent.origin) {
throw new Error(`Post message did not have origin domain`);
}

if (__TEST__) {
if (needsGlobalMessagingForBrowser() && isSameTopWindow(messageEvent.source, window) === false) {
return;
Expand Down

0 comments on commit 11eb25e

Please # to comment.