Merge pull request #12228 from electron/fix-window-open-not-showing
Parent's visibility trumps inherited 'show' option
This commit is contained in:
commit
8e07e7483f
2 changed files with 29 additions and 1 deletions
|
@ -47,8 +47,16 @@ const mergeBrowserWindowOptions = function (embedder, options) {
|
||||||
options.webPreferences = {}
|
options.webPreferences = {}
|
||||||
}
|
}
|
||||||
if (embedder.browserWindowOptions != null) {
|
if (embedder.browserWindowOptions != null) {
|
||||||
|
let parentOptions = embedder.browserWindowOptions
|
||||||
|
|
||||||
|
// if parent's visibility is available, that overrides 'show' flag (#12125)
|
||||||
|
const win = BrowserWindow.fromWebContents(embedder.webContents)
|
||||||
|
if (win != null) {
|
||||||
|
parentOptions = {...embedder.browserWindowOptions, show: win.isVisible()}
|
||||||
|
}
|
||||||
|
|
||||||
// Inherit the original options if it is a BrowserWindow.
|
// Inherit the original options if it is a BrowserWindow.
|
||||||
mergeOptions(options, embedder.browserWindowOptions)
|
mergeOptions(options, parentOptions)
|
||||||
} else {
|
} else {
|
||||||
// Or only inherit webPreferences if it is a webview.
|
// Or only inherit webPreferences if it is a webview.
|
||||||
mergeOptions(options.webPreferences, embedder.getWebPreferences())
|
mergeOptions(options.webPreferences, embedder.getWebPreferences())
|
||||||
|
|
|
@ -223,6 +223,26 @@ describe('chromium feature', () => {
|
||||||
b = window.open(`file://${fixtures}/pages/window-open-size.html`, '', 'show=no')
|
b = window.open(`file://${fixtures}/pages/window-open-size.html`, '', 'show=no')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
for (const show of [true, false]) {
|
||||||
|
it(`inherits parent visibility over parent {show=${show}} option`, (done) => {
|
||||||
|
const w = new BrowserWindow({show})
|
||||||
|
|
||||||
|
// toggle visibility
|
||||||
|
if (show) {
|
||||||
|
w.hide()
|
||||||
|
} else {
|
||||||
|
w.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
w.webContents.once('new-window', (e, url, frameName, disposition, options) => {
|
||||||
|
assert.equal(options.show, w.isVisible())
|
||||||
|
w.close()
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
w.loadURL(`file://${fixtures}/pages/window-open.html`)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
it('disables node integration when it is disabled on the parent window', (done) => {
|
it('disables node integration when it is disabled on the parent window', (done) => {
|
||||||
let b
|
let b
|
||||||
listener = (event) => {
|
listener = (event) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue