Use helper function to show last dev tools panel
This commit is contained in:
parent
640b03f7d0
commit
515f689814
1 changed files with 24 additions and 34 deletions
|
@ -1663,18 +1663,10 @@ describe('BrowserWindow module', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('dev tool extensions', function () {
|
describe('dev tool extensions', function () {
|
||||||
describe('BrowserWindow.addDevToolsExtension', function () {
|
|
||||||
let showPanelIntervalId
|
let showPanelIntervalId
|
||||||
|
|
||||||
beforeEach(function () {
|
const showLastDevToolsPanel = () => {
|
||||||
BrowserWindow.removeDevToolsExtension('foo')
|
w.webContents.once('devtools-opened', function () {
|
||||||
assert.equal(BrowserWindow.getDevToolsExtensions().hasOwnProperty('foo'), false)
|
|
||||||
|
|
||||||
var extensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', 'foo')
|
|
||||||
BrowserWindow.addDevToolsExtension(extensionPath)
|
|
||||||
assert.equal(BrowserWindow.getDevToolsExtensions().hasOwnProperty('foo'), true)
|
|
||||||
|
|
||||||
w.webContents.on('devtools-opened', function () {
|
|
||||||
showPanelIntervalId = setInterval(function () {
|
showPanelIntervalId = setInterval(function () {
|
||||||
if (w && w.devToolsWebContents) {
|
if (w && w.devToolsWebContents) {
|
||||||
var showLastPanel = function () {
|
var showLastPanel = function () {
|
||||||
|
@ -1687,14 +1679,26 @@ describe('BrowserWindow module', function () {
|
||||||
}
|
}
|
||||||
}, 100)
|
}, 100)
|
||||||
})
|
})
|
||||||
|
}
|
||||||
w.loadURL('about:blank')
|
|
||||||
})
|
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
clearInterval(showPanelIntervalId)
|
clearInterval(showPanelIntervalId)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('BrowserWindow.addDevToolsExtension', function () {
|
||||||
|
beforeEach(function () {
|
||||||
|
BrowserWindow.removeDevToolsExtension('foo')
|
||||||
|
assert.equal(BrowserWindow.getDevToolsExtensions().hasOwnProperty('foo'), false)
|
||||||
|
|
||||||
|
var extensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', 'foo')
|
||||||
|
BrowserWindow.addDevToolsExtension(extensionPath)
|
||||||
|
assert.equal(BrowserWindow.getDevToolsExtensions().hasOwnProperty('foo'), true)
|
||||||
|
|
||||||
|
showLastDevToolsPanel()
|
||||||
|
|
||||||
|
w.loadURL('about:blank')
|
||||||
|
})
|
||||||
|
|
||||||
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,21 +1764,7 @@ 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'})
|
||||||
|
|
Loading…
Reference in a new issue