Merge pull request #12228 from electron/fix-window-open-not-showing

Parent's visibility trumps inherited 'show' option
This commit is contained in:
Samuel Attard 2018-03-13 17:41:00 +09:00 committed by GitHub
commit 8e07e7483f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 1 deletions

View file

@ -47,8 +47,16 @@ const mergeBrowserWindowOptions = function (embedder, options) {
options.webPreferences = {}
}
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.
mergeOptions(options, embedder.browserWindowOptions)
mergeOptions(options, parentOptions)
} else {
// Or only inherit webPreferences if it is a webview.
mergeOptions(options.webPreferences, embedder.getWebPreferences())

View file

@ -223,6 +223,26 @@ describe('chromium feature', () => {
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) => {
let b
listener = (event) => {