This commit is contained in:
deepak1556 2017-04-05 12:00:36 +05:30 committed by Cheng Zhao
parent 9e3b8ade12
commit e4524ce42e
3 changed files with 150 additions and 0 deletions

View file

@ -338,6 +338,27 @@ ipcMain.on('crash-service-pid', (event, pid) => {
event.returnValue = null
})
ipcMain.on('test-webcontents-navigation-observer', (event, options) => {
let contents = null
let destroy = () => {}
if (options.id) {
const w = BrowserWindow.fromId(options.id)
contents = w.webContents
destroy = () => w.close()
} else {
contents = webContents.create()
destroy = () => contents.destroy()
}
contents.once(options.name, () => destroy())
contents.once('destroyed', () => {
event.sender.send(options.responseEvent)
})
contents.loadURL(options.url)
})
// Suspend listeners until the next event and then restore them
const suspendListeners = (emitter, eventName, callback) => {
const listeners = emitter.listeners(eventName)