From cc7f4fedf6bb11fc009482f258318aec6256944f Mon Sep 17 00:00:00 2001 From: Michael Vasseur Date: Thu, 29 Sep 2016 15:37:28 +0200 Subject: [PATCH] Rebase with recent changes --- lib/browser/guest-window-manager.js | 50 ++++++++++++++--------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/lib/browser/guest-window-manager.js b/lib/browser/guest-window-manager.js index 88871dc58b8..2c869cc6515 100644 --- a/lib/browser/guest-window-manager.js +++ b/lib/browser/guest-window-manager.js @@ -45,30 +45,7 @@ const mergeBrowserWindowOptions = function (embedder, options) { // Setup a new guest with |embedder| const setupGuest = function (embedder, frameName, guest) { - if (!options.webContents || url !== 'about:blank') { - // We should not call `loadURL` if the window was constructed from an - // existing webContents(window.open in a sandboxed renderer) and if the url - // is not 'about:blank'. - // - // Navigating to the url when creating the window from an existing - // webContents would not be necessary(it will navigate there anyway), but - // apparently there's a bug that allows the child window to be scripted by - // the opener, even when the child window is from another origin. - // - // That's why the second condition(url !== "about:blank") is required: to - // force `OverrideSiteInstanceForNavigation` to be called and consequently - // spawn a new renderer if the new window is targeting a different origin. - // - // If the URL is "about:blank", then it is very likely that the opener just - // wants to synchronously script the popup, for example: - // - // let popup = window.open() - // popup.document.body.write('

hello

') - // - // The above code would not work if a navigation to "about:blank" is done - // here, since the window would be cleared of all changes in the next tick. - guest.loadURL(url) - } + // When |embedder| is destroyed we should also destroy attached guest, and if // guest is closed by user then we should prevent |embedder| from double // closing guest. @@ -118,7 +95,30 @@ const createGuest = function (embedder, url, frameName, options) { } options.webPreferences.openerId = embedder.id guest = new BrowserWindow(options) - guest.loadURL(url) + if (!options.webContents || url !== 'about:blank') { + // We should not call `loadURL` if the window was constructed from an + // existing webContents(window.open in a sandboxed renderer) and if the url + // is not 'about:blank'. + // + // Navigating to the url when creating the window from an existing + // webContents would not be necessary(it will navigate there anyway), but + // apparently there's a bug that allows the child window to be scripted by + // the opener, even when the child window is from another origin. + // + // That's why the second condition(url !== "about:blank") is required: to + // force `OverrideSiteInstanceForNavigation` to be called and consequently + // spawn a new renderer if the new window is targeting a different origin. + // + // If the URL is "about:blank", then it is very likely that the opener just + // wants to synchronously script the popup, for example: + // + // let popup = window.open() + // popup.document.body.write('

hello

') + // + // The above code would not work if a navigation to "about:blank" is done + // here, since the window would be cleared of all changes in the next tick. + guest.loadURL(url) + } return setupGuest(embedder, frameName, guest) }