Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
throw new Error(`Attempting to send messsage to mock domain ${dom}, but window is actually cross-domain`);
} // $FlowFixMe
const windowDomain = (0, _src.getDomain)(win);
if (windowDomain !== dom) {
throw new Error(`Mock domain target ${dom} does not match window domain ${windowDomain}`);
} // $FlowFixMe
return (0, _src.getActualDomain)(win);
}
}
if (dom.indexOf(_src.PROTOCOL.FILE) === 0) {
return _conf.WILDCARD;
}
return dom;
});
domains.forEach(dom => {
domains = domains.map(dom => {
if (__TEST__) {
if (dom.indexOf(_src.PROTOCOL.MOCK) === 0) {
if (window.location.protocol === _src.PROTOCOL.FILE) {
return _conf.WILDCARD;
}
if (!(0, _src.isActuallySameDomain)(win)) {
throw new Error(`Attempting to send messsage to mock domain ${dom}, but window is actually cross-domain`);
} // $FlowFixMe
const windowDomain = (0, _src.getDomain)(win);
if (windowDomain !== dom) {
throw new Error(`Mock domain target ${dom} does not match window domain ${windowDomain}`);
} // $FlowFixMe
return (0, _src.getActualDomain)(win);
}
(0, _lib.markWindowKnown)(source);
if (receivedMessages.has(message.id)) {
return;
}
receivedMessages.set(message.id, true);
if ((0, _src.isWindowClosed)(source) && !message.fireAndForget) {
return;
}
if (message.origin.indexOf(_src.PROTOCOL.FILE) === 0) {
origin = `${_src.PROTOCOL.FILE}//`;
}
_types.RECEIVE_MESSAGE_TYPES[message.type](source, origin, message, {
on,
send
});
}
function messageListener(event, {
on,
send
}) {
try {
(0, _src2.noop)(event.source);
} catch (err) {
return;
}
const source = event.source || event.sourceElement;
let origin = event.origin || event.originalEvent && event.originalEvent.origin;
const data = event.data;
if (origin === 'null') {
origin = `${_src.PROTOCOL.FILE}//`;
}
if (!source) {
return;
}
if (!origin) {
throw new Error(`Post message did not have origin domain`);
}
if (__TEST__) {
if ((0, _lib.needsGlobalMessagingForBrowser)() && (0, _src.isSameTopWindow)(source, window) === false) {
return;
}
}