Rebase with recent changes
This commit is contained in:
parent
22bd7c0271
commit
cc7f4fedf6
1 changed files with 25 additions and 25 deletions
|
@ -45,30 +45,7 @@ const mergeBrowserWindowOptions = function (embedder, options) {
|
||||||
|
|
||||||
// Setup a new guest with |embedder|
|
// Setup a new guest with |embedder|
|
||||||
const setupGuest = function (embedder, frameName, guest) {
|
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('<h1>hello</h1>')
|
|
||||||
//
|
|
||||||
// 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
|
// When |embedder| is destroyed we should also destroy attached guest, and if
|
||||||
// guest is closed by user then we should prevent |embedder| from double
|
// guest is closed by user then we should prevent |embedder| from double
|
||||||
// closing guest.
|
// closing guest.
|
||||||
|
@ -118,7 +95,30 @@ const createGuest = function (embedder, url, frameName, options) {
|
||||||
}
|
}
|
||||||
options.webPreferences.openerId = embedder.id
|
options.webPreferences.openerId = embedder.id
|
||||||
guest = new BrowserWindow(options)
|
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('<h1>hello</h1>')
|
||||||
|
//
|
||||||
|
// 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)
|
return setupGuest(embedder, frameName, guest)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue