diff --git a/lib/renderer/window-setup.js b/lib/renderer/window-setup.js index 31767a290d4d..b94eace5aeca 100644 --- a/lib/renderer/window-setup.js +++ b/lib/renderer/window-setup.js @@ -127,6 +127,10 @@ module.exports = (ipcRenderer, guestInstanceId, openerId, hiddenPage, usesNative return null } } + + if (openerId != null) { + window.opener = getOrCreateProxy(ipcRenderer, openerId) + } } window.alert = function (message, title) { @@ -142,10 +146,6 @@ module.exports = (ipcRenderer, guestInstanceId, openerId, hiddenPage, usesNative throw new Error('prompt() is and will not be supported.') } - if (openerId != null) { - window.opener = getOrCreateProxy(ipcRenderer, openerId) - } - ipcRenderer.on('ELECTRON_GUEST_WINDOW_POSTMESSAGE', function (event, sourceId, message, sourceOrigin) { // Manually dispatch event instead of using postMessage because we also need to // set event.source.