Use helper function to show last dev tools panel

This commit is contained in:
Kevin Sawicki 2017-01-26 09:42:45 -08:00
parent 640b03f7d0
commit 515f689814

View file

@ -1663,9 +1663,29 @@ describe('BrowserWindow module', function () {
})
describe('dev tool extensions', function () {
describe('BrowserWindow.addDevToolsExtension', function () {
let showPanelIntervalId
let showPanelIntervalId
const showLastDevToolsPanel = () => {
w.webContents.once('devtools-opened', function () {
showPanelIntervalId = setInterval(function () {
if (w && w.devToolsWebContents) {
var showLastPanel = function () {
var lastPanelId = WebInspector.inspectorView._tabbedPane._tabs.peekLast().id
WebInspector.inspectorView.showPanel(lastPanelId)
}
w.devToolsWebContents.executeJavaScript(`(${showLastPanel})()`)
} else {
clearInterval(showPanelIntervalId)
}
}, 100)
})
}
afterEach(function () {
clearInterval(showPanelIntervalId)
})
describe('BrowserWindow.addDevToolsExtension', function () {
beforeEach(function () {
BrowserWindow.removeDevToolsExtension('foo')
assert.equal(BrowserWindow.getDevToolsExtensions().hasOwnProperty('foo'), false)
@ -1674,27 +1694,11 @@ describe('BrowserWindow module', function () {
BrowserWindow.addDevToolsExtension(extensionPath)
assert.equal(BrowserWindow.getDevToolsExtensions().hasOwnProperty('foo'), true)
w.webContents.on('devtools-opened', function () {
showPanelIntervalId = setInterval(function () {
if (w && w.devToolsWebContents) {
var showLastPanel = function () {
var lastPanelId = WebInspector.inspectorView._tabbedPane._tabs.peekLast().id
WebInspector.inspectorView.showPanel(lastPanelId)
}
w.devToolsWebContents.executeJavaScript(`(${showLastPanel})()`)
} else {
clearInterval(showPanelIntervalId)
}
}, 100)
})
showLastDevToolsPanel()
w.loadURL('about:blank')
})
afterEach(function () {
clearInterval(showPanelIntervalId)
})
it('throws errors for missing manifest.json files', function () {
assert.throws(function () {
BrowserWindow.addDevToolsExtension(path.join(__dirname, 'does-not-exist'))
@ -1760,21 +1764,7 @@ describe('BrowserWindow module', function () {
BrowserWindow.removeDevToolsExtension('foo')
BrowserWindow.addDevToolsExtension(extensionPath)
let showPanelIntervalId = null
w.webContents.once('devtools-opened', function () {
showPanelIntervalId = setInterval(function () {
if (w && w.devToolsWebContents) {
var showLastPanel = function () {
var lastPanelId = WebInspector.inspectorView._tabbedPane._tabs.peekLast().id
WebInspector.inspectorView.showPanel(lastPanelId)
}
w.devToolsWebContents.executeJavaScript(`(${showLastPanel})()`)
} else {
clearInterval(showPanelIntervalId)
}
}, 100)
})
showLastDevToolsPanel()
w.loadURL('about:blank')
w.webContents.openDevTools({mode: 'bottom'})