зеркало из https://github.com/electron/electron.git
Add spec for closing from will-navigate listener
This commit is contained in:
Родитель
1308f790ad
Коммит
abea1196de
|
@ -267,6 +267,16 @@ describe('BrowserWindow module', function () {
|
|||
})
|
||||
})
|
||||
|
||||
describe('will-navigate event', function () {
|
||||
it('allows the window to be closed from the event listener', (done) => {
|
||||
ipcRenderer.send('close-on-will-navigate', w.id)
|
||||
ipcRenderer.once('closed-on-will-navigate', () => {
|
||||
done()
|
||||
})
|
||||
w.loadURL('file://' + fixtures + '/pages/will-navigate.html')
|
||||
})
|
||||
})
|
||||
|
||||
describe('BrowserWindow.show()', function () {
|
||||
if (isCI) {
|
||||
return
|
||||
|
|
|
@ -221,3 +221,12 @@ ipcMain.on('set-client-certificate-option', function (event, skip) {
|
|||
})
|
||||
event.returnValue = 'done'
|
||||
})
|
||||
|
||||
ipcMain.on('close-on-will-navigate', (event, id) => {
|
||||
const contents = event.sender
|
||||
const window = BrowserWindow.fromId(id)
|
||||
window.webContents.once('will-navigate', (event, input) => {
|
||||
window.close()
|
||||
contents.send('closed-on-will-navigate')
|
||||
})
|
||||
})
|
||||
|
|
Загрузка…
Ссылка в новой задаче