Guard against destroyed window or web contents
This commit is contained in:
parent
515f689814
commit
e2e33a8cf0
1 changed files with 15 additions and 9 deletions
|
@ -1668,15 +1668,22 @@ describe('BrowserWindow module', function () {
|
||||||
const showLastDevToolsPanel = () => {
|
const showLastDevToolsPanel = () => {
|
||||||
w.webContents.once('devtools-opened', function () {
|
w.webContents.once('devtools-opened', function () {
|
||||||
showPanelIntervalId = setInterval(function () {
|
showPanelIntervalId = setInterval(function () {
|
||||||
if (w && w.devToolsWebContents) {
|
if (w == null || w.isDestroyed()) {
|
||||||
var showLastPanel = function () {
|
clearInterval(showLastDevToolsPanel)
|
||||||
var lastPanelId = WebInspector.inspectorView._tabbedPane._tabs.peekLast().id
|
return
|
||||||
WebInspector.inspectorView.showPanel(lastPanelId)
|
|
||||||
}
|
|
||||||
w.devToolsWebContents.executeJavaScript(`(${showLastPanel})()`)
|
|
||||||
} else {
|
|
||||||
clearInterval(showPanelIntervalId)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const {devToolsWebContents} = w
|
||||||
|
if (devToolsWebContents == null || devToolsWebContents.isDestroyed()) {
|
||||||
|
clearInterval(showLastDevToolsPanel)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var showLastPanel = function () {
|
||||||
|
var lastPanelId = WebInspector.inspectorView._tabbedPane._tabs.peekLast().id
|
||||||
|
WebInspector.inspectorView.showPanel(lastPanelId)
|
||||||
|
}
|
||||||
|
devToolsWebContents.executeJavaScript(`(${showLastPanel})()`)
|
||||||
}, 100)
|
}, 100)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1770,7 +1777,6 @@ describe('BrowserWindow module', function () {
|
||||||
w.webContents.openDevTools({mode: 'bottom'})
|
w.webContents.openDevTools({mode: 'bottom'})
|
||||||
|
|
||||||
ipcMain.once('answer', function (event, message) {
|
ipcMain.once('answer', function (event, message) {
|
||||||
clearInterval(showPanelIntervalId)
|
|
||||||
assert.equal(message.runtimeId, 'foo')
|
assert.equal(message.runtimeId, 'foo')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue