Skip to content

Commit

Permalink
Throw useful error for post-message send to actual cross-domain windo…
Browse files Browse the repository at this point in the history
…w with mock domain specified
  • Loading branch information
bluepnume committed Mar 20, 2017
1 parent 39c1da4 commit a7d1008
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/drivers/send/strategies.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ export let SEND_MESSAGE_STRATEGIES = {
emulateIERestrictions(window, win);

if (domain && domain.indexOf(CONSTANTS.MOCK_PROTOCOL) === 0) {
domain = `${win.location.protocol}//${win.location.host}`;
try {
domain = `${win.location.protocol}//${win.location.host}`;
} catch (err) {
throw new Error(`Attempting to send messsage to mock domain ${domain}, but window is actually cross-domain`);
}
}

if (domain && domain.indexOf(CONSTANTS.FILE_PROTOCOL) === 0) {
Expand Down

0 comments on commit a7d1008

Please # to comment.