Merge pull request #8519 from electron/consolidate-panel-showing
Use helper function to show last dev tools panel
This commit is contained in:
commit
a4e25a8917
1 changed files with 33 additions and 35 deletions
|
@ -1663,9 +1663,38 @@ describe('BrowserWindow module', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('dev tool extensions', function () {
|
describe('dev tool extensions', function () {
|
||||||
describe('BrowserWindow.addDevToolsExtension', function () {
|
|
||||||
let showPanelIntervalId
|
let showPanelIntervalId
|
||||||
|
|
||||||
|
const showLastDevToolsPanel = () => {
|
||||||
|
w.webContents.once('devtools-opened', function () {
|
||||||
|
clearInterval(showPanelIntervalId)
|
||||||
|
|
||||||
|
showPanelIntervalId = setInterval(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
|
||||||
|
WebInspector.inspectorView.showPanel(lastPanelId)
|
||||||
|
}
|
||||||
|
devToolsWebContents.executeJavaScript(`(${showLastPanel})()`)
|
||||||
|
}, 100)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
afterEach(function () {
|
||||||
|
clearInterval(showPanelIntervalId)
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('BrowserWindow.addDevToolsExtension', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
BrowserWindow.removeDevToolsExtension('foo')
|
BrowserWindow.removeDevToolsExtension('foo')
|
||||||
assert.equal(BrowserWindow.getDevToolsExtensions().hasOwnProperty('foo'), false)
|
assert.equal(BrowserWindow.getDevToolsExtensions().hasOwnProperty('foo'), false)
|
||||||
|
@ -1674,27 +1703,11 @@ describe('BrowserWindow module', function () {
|
||||||
BrowserWindow.addDevToolsExtension(extensionPath)
|
BrowserWindow.addDevToolsExtension(extensionPath)
|
||||||
assert.equal(BrowserWindow.getDevToolsExtensions().hasOwnProperty('foo'), true)
|
assert.equal(BrowserWindow.getDevToolsExtensions().hasOwnProperty('foo'), true)
|
||||||
|
|
||||||
w.webContents.on('devtools-opened', function () {
|
showLastDevToolsPanel()
|
||||||
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)
|
|
||||||
})
|
|
||||||
|
|
||||||
w.loadURL('about:blank')
|
w.loadURL('about:blank')
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(function () {
|
|
||||||
clearInterval(showPanelIntervalId)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('throws errors for missing manifest.json files', function () {
|
it('throws errors for missing manifest.json files', function () {
|
||||||
assert.throws(function () {
|
assert.throws(function () {
|
||||||
BrowserWindow.addDevToolsExtension(path.join(__dirname, 'does-not-exist'))
|
BrowserWindow.addDevToolsExtension(path.join(__dirname, 'does-not-exist'))
|
||||||
|
@ -1760,27 +1773,12 @@ describe('BrowserWindow module', function () {
|
||||||
BrowserWindow.removeDevToolsExtension('foo')
|
BrowserWindow.removeDevToolsExtension('foo')
|
||||||
BrowserWindow.addDevToolsExtension(extensionPath)
|
BrowserWindow.addDevToolsExtension(extensionPath)
|
||||||
|
|
||||||
let showPanelIntervalId = null
|
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)
|
|
||||||
})
|
|
||||||
|
|
||||||
w.loadURL('about:blank')
|
w.loadURL('about:blank')
|
||||||
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