Schedule function after executeJavaScript completes

This commit is contained in:
Kevin Sawicki 2017-01-26 16:15:10 -08:00
parent eb6d92d427
commit 76e5589a31

View file

@ -1663,35 +1663,33 @@ describe('BrowserWindow module', function () {
})
describe('dev tool extensions', function () {
let showPanelIntervalId
let showPanelTimeoutId
const showLastDevToolsPanel = () => {
w.webContents.once('devtools-opened', function () {
clearInterval(showPanelIntervalId)
showPanelIntervalId = setInterval(function () {
const show = function () {
if (w == null || w.isDestroyed()) {
clearInterval(showLastDevToolsPanel)
return
}
const {devToolsWebContents} = w
if (devToolsWebContents == null || devToolsWebContents.isDestroyed()) {
clearInterval(showLastDevToolsPanel)
return
}
var showLastPanel = function () {
var lastPanelId = WebInspector.inspectorView._tabbedPane._tabs.peekLast().id
const showLastPanel = function () {
const lastPanelId = WebInspector.inspectorView._tabbedPane._tabs.peekLast().id
WebInspector.inspectorView.showPanel(lastPanelId)
}
devToolsWebContents.executeJavaScript(`(${showLastPanel})()`)
}, 100)
devToolsWebContents.executeJavaScript(`(${showLastPanel})()`, false, () => {
showPanelTimeoutId = setTimeout(show, 100)
})
}
showPanelTimeoutId = setTimeout(show, 100)
})
}
afterEach(function () {
clearInterval(showPanelIntervalId)
clearTimeout(showPanelTimeoutId)
})
describe('BrowserWindow.addDevToolsExtension', function () {