Add failing spec for sandboxed window.open

This commit is contained in:
Kevin Sawicki 2017-01-10 15:34:29 -08:00
parent 070bbcfc3d
commit c5da330cdf
2 changed files with 24 additions and 0 deletions

View file

@ -1012,6 +1012,25 @@ describe('BrowserWindow module', function () {
})
})
})
it('supports calling preventDefault on new-window events', (done) => {
w.destroy()
w = new BrowserWindow({
show: false,
webPreferences: {
sandbox: true,
}
})
const initialWebContents = webContents.getAllWebContents()
ipcRenderer.send('prevent-next-new-window', w.webContents.id)
w.webContents.once('new-window', () => {
process.nextTick(() => {
assert.deepEqual(webContents.getAllWebContents().length, initialWebContents.length)
done()
})
})
w.loadURL('file://' + path.join(fixtures, 'pages', 'window-open.html'))
})
})
})

View file

@ -245,3 +245,8 @@ ipcMain.on('create-window-with-options-cycle', (event) => {
const window = new BrowserWindow({show: false, foo: foo})
event.returnValue = window.id
})
ipcMain.on('prevent-next-new-window', (event, id) => {
webContents.fromId(id).once('new-window', event => event.preventDefault())
})