Skip to content
This repository was archived by the owner on Jan 31, 2025. It is now read-only.

Commit 62616be

Browse files
author
Daniel Brain
committed
Explicitly specify domain and window in internal listeners/senders
1 parent 78adb36 commit 62616be

File tree

7 files changed

+10
-6
lines changed

7 files changed

+10
-6
lines changed

src/bridge/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ global.openTunnel = function openTunnel(remoteWindow, { name, sendMessage }) {
244244
sendMessage() {
245245
return sendMessage.apply(this, arguments);
246246
}
247-
});
247+
}, { domain: '*' });
248248
};
249249

250250

src/conf/config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { CONSTANTS } from './constants';
33

44
export let CONFIG = {
55

6-
ALLOW_POSTMESSAGE_POPUP: false,
6+
ALLOW_POSTMESSAGE_POPUP: true,
77

88
LOG_LEVEL: 'info',
99

src/drivers/listeners.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function getRequestListener(name, win) {
2020
continue;
2121
}
2222

23-
if (!requestListener.win) {
23+
if (!requestListener.win || requestListener.win === '*') {
2424
return requestListener.options;
2525
}
2626

src/lib/methods.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { global } from '../global';
99
global.methods = global.methods || {};
1010

1111
export let listenForMethods = util.once(() => {
12-
on(CONSTANTS.POST_MESSAGE_NAMES.METHOD, ({ source, origin, data }) => {
12+
on(CONSTANTS.POST_MESSAGE_NAMES.METHOD, { window: '*', origin: '*' }, ({ source, origin, data }) => {
1313

1414
let meth = global.methods[data.id];
1515

src/lib/ready.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ global.readyPromises = global.readyPromises || [];
1010

1111
export function initOnReady() {
1212

13-
on(CONSTANTS.POST_MESSAGE_NAMES.READY, ({ source, data }) => {
13+
on(CONSTANTS.POST_MESSAGE_NAMES.READY, { window: '*', domain: '*' }, ({ source, data }) => {
1414

1515
for (let item of global.readyPromises) {
1616
if (item.win === source) {
@@ -28,7 +28,7 @@ export function initOnReady() {
2828
let parent = getAncestor();
2929

3030
if (parent) {
31-
send(parent, CONSTANTS.POST_MESSAGE_NAMES.READY, {}).catch(err => {
31+
send(parent, CONSTANTS.POST_MESSAGE_NAMES.READY, {}, { domain: '*' }).catch(err => {
3232
log.debug(err.stack || err.toString());
3333
});
3434
}

test/child.js

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import './common';
33
import postRobot from 'src/index';
44

5+
postRobot.CONFIG.ALLOW_POSTMESSAGE_POPUP = false;
6+
57
window.postRobot = postRobot;
68

79
postRobot.on('sendMessageToParent', function({ source, data }) {

test/test.js

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import './common';
33
import postRobot from 'src/index';
44

5+
postRobot.CONFIG.ALLOW_POSTMESSAGE_POPUP = false;
6+
57
import { onWindowReady, promise } from 'src/lib';
68

79
postRobot.CONFIG.LOG_TO_PAGE = true;

0 commit comments

Comments
 (0)