diff --git a/src/bridge/common.js b/src/bridge/common.js index b6f716d6..c88b1759 100644 --- a/src/bridge/common.js +++ b/src/bridge/common.js @@ -23,28 +23,43 @@ export function needsBridgeForBrowser() : boolean { export function needsBridgeForWin(win : any) : boolean { - if (win && isSameTopWindow(window, win)) { - return false; + if (!isSameTopWindow(window, win)) { + return true; } - if (win && isSameDomain(win)) { - return false; + return false; +} + +export function needsBridgeForDomain(domain : ?string, win : any) : boolean { + + if (domain) { + if (getDomain() !== getDomainFromUrl(domain)) { + return true; + } + } else if (win) { + if (!isSameDomain(win)) { + return true; + } } - return true; + return false; } -export function needsBridgeForDomain(domain : ?string) : boolean { +export function needsBridge({ win, domain } : { win : any, domain? : string }) : boolean { - if (domain && getDomain() === getDomainFromUrl(domain)) { + if (!needsBridgeForBrowser()) { return false; } - return true; -} + if (domain && !needsBridgeForDomain(domain, win)) { + return false; + } -export function needsBridge({ win, domain } : { win : any, domain? : string }) : boolean { - return needsBridgeForBrowser() && needsBridgeForWin(win) && needsBridgeForDomain(domain); + if (win && !needsBridgeForWin(win)) { + return false; + } + + return true; } export function getBridgeName(domain : string) : string {