How to use the cross-domain-utils/src.isSameTopWindow function in cross-domain-utils

To help you get started, we’ve selected a few cross-domain-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github krakenjs / post-robot / src / drivers / send / strategies.js View on Github external
SEND_MESSAGE_STRATEGIES[SEND_STRATEGY.GLOBAL] = (win : CrossDomainWindowType, serializedMessage : string) => {

        if (!needsGlobalMessagingForBrowser()) {
            throw new Error(`Global messaging not needed for browser`);
        }

        if (!isSameDomain(win)) {
            throw new Error(`Post message through global disabled between different domain windows`);
        }

        if (isSameTopWindow(window, win) !== false) {
            throw new Error(`Can only use global to communicate between two different windows, not between frames`);
        }

        // $FlowFixMe
        const foreignGlobal = getGlobal(win);

        if (!foreignGlobal) {
            throw new Error(`Can not find postRobot global on foreign window`);
        }

        foreignGlobal.receiveMessage({
            source: window,
            origin: getDomain(),
            data:   serializedMessage
        });
    };
github krakenjs / post-robot / src / drivers / receive / index.js View on Github external
const data = event.data;

    if (origin === 'null') {
        origin = `${ PROTOCOL.FILE }//`;
    }

    if (!source) {
        return;
    }

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

    if (__TEST__) {
        if (needsGlobalMessagingForBrowser() && isSameTopWindow(source, window) === false) {
            return;
        }
    }

    receiveMessage({ source, origin, data }, { on, send });
}
github krakenjs / zoid / src / component / component.js View on Github external
checkAllowRender(target : CrossDomainWindowType, domain : string | RegExp, container : string | HTMLElement) {
        if (target === window) {
            return;
        }

        if (!isSameTopWindow(window, target)) {
            throw new Error(`Can only renderTo an adjacent frame`);
        }

        const origin = getDomain();

        if (!matchDomain(domain, origin) && !isSameDomain(target)) {
            throw new Error(`Can not render remotely to ${ domain.toString() } - can only render to ${ origin }`);
        }

        if (container && typeof container !== 'string') {
            throw new Error(`Container passed to renderTo must be a string selector, got ${ typeof container } }`);
        }
    }
github krakenjs / post-robot / dist / module / compat / ie.js View on Github external
export function emulateIERestrictions(sourceWindow, targetWindow) {
    if (!CONFIG.ALLOW_POSTMESSAGE_POPUP) {

        if (isSameTopWindow(sourceWindow, targetWindow) === false) {
            throw new Error('Can not send and receive post messages between two different windows (disabled to emulate IE)');
        }
    }
}
github krakenjs / post-robot / src / drivers / send / strategies.js View on Github external
SEND_MESSAGE_STRATEGIES[SEND_STRATEGY.POST_MESSAGE] = (win : CrossDomainWindowType, serializedMessage : string, domain : DomainMatcher) => {

    if (__TEST__) {
        if (needsGlobalMessagingForBrowser() && isSameTopWindow(window, win) === false) {
            return;
        }
    }

    let domains;

    if (Array.isArray(domain)) {
        domains = domain;
    } else if (typeof domain === 'string') {
        domains = [ domain ];
    } else {
        domains = [ WILDCARD ];
    }

    domains = domains.map(dom => {
github krakenjs / zoid / src / component / parent / index.js View on Github external
checkAllowRemoteRender(target : CrossDomainWindowType) {

        if (!target) {
            throw this.component.createError(`Must pass window to renderTo`);
        }

        if (!isSameTopWindow(window, target)) {
            throw new Error(`Can only renderTo an adjacent frame`);
        }

        let origin = getDomain();
        let domain = this.getDomain();

        if (!matchDomain(domain, origin) && !isSameDomain(target)) {
            throw new Error(`Can not render remotely to ${ domain.toString() } - can only render to ${ origin }`);
        }
    }
github krakenjs / zoid / dist / module / component / parent / index.js View on Github external
ParentComponent.prototype.checkAllowRemoteRender = function checkAllowRemoteRender(target) {

        if (!target) {
            throw this.component.createError('Must pass window to renderTo');
        }

        if (!isSameTopWindow(window, target)) {
            throw new Error('Can only renderTo an adjacent frame');
        }

        var origin = getDomain();
        var domain = this.getDomain();

        if (!matchDomain(domain, origin) && !isSameDomain(target)) {
            throw new Error('Can not render remotely to ' + domain.toString() + ' - can only render to ' + origin);
        }
    };
github krakenjs / post-robot / src / bridge / common.js View on Github external
export function needsBridgeForWin(win : CrossDomainWindowType) : boolean {

    if (!isSameTopWindow(window, win)) {
        return true;
    }

    return false;
}
github krakenjs / post-robot / src / compat / ie.js View on Github external
export function emulateIERestrictions(sourceWindow : CrossDomainWindowType, targetWindow : CrossDomainWindowType) {
    if (!CONFIG.ALLOW_POSTMESSAGE_POPUP) {

        if (isSameTopWindow(sourceWindow, targetWindow) === false) {
            throw new Error(`Can not send and receive post messages between two different windows (disabled to emulate IE)`);
        }
    }
}