Add failing spec for sandboxed window.open
This commit is contained in:
parent
070bbcfc3d
commit
c5da330cdf
2 changed files with 24 additions and 0 deletions
|
@ -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'))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -245,3 +245,8 @@ ipcMain.on('create-window-with-options-cycle', (event) => {
|
||||||
const window = new BrowserWindow({show: false, foo: foo})
|
const window = new BrowserWindow({show: false, foo: foo})
|
||||||
event.returnValue = window.id
|
event.returnValue = window.id
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
ipcMain.on('prevent-next-new-window', (event, id) => {
|
||||||
|
webContents.fromId(id).once('new-window', event => event.preventDefault())
|
||||||
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue