Add getDevToolsExtensions API

This commit is contained in:
Kevin Sawicki 2016-06-10 09:24:00 -07:00
parent 091682a039
commit 1f245d5ff6
2 changed files with 9 additions and 4 deletions

View file

@ -340,7 +340,12 @@ app.once('ready', function () {
delete manifestNameMap[name]
}
BrowserWindow.isDevToolsExtensionInstalled = function (name) {
return manifestNameMap.hasOwnProperty(name)
BrowserWindow.getDevToolsExtensions = function () {
const extensions = {}
Object.keys(manifestNameMap).forEach(function (name) {
const manifest = manifestNameMap[name]
extensions[name] = {name: manifest.name, version: manifest.version}
})
return extensions
}
})

View file

@ -838,11 +838,11 @@ describe('browser-window module', function () {
beforeEach(function () {
BrowserWindow.removeDevToolsExtension('foo')
assert.equal(BrowserWindow.isDevToolsExtensionInstalled('foo'), false)
assert.equal(BrowserWindow.getDevToolsExtensions().hasOwnProperty('foo'), false)
var extensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', 'foo')
BrowserWindow.addDevToolsExtension(extensionPath)
assert.equal(BrowserWindow.isDevToolsExtensionInstalled('foo'), true)
assert.equal(BrowserWindow.getDevToolsExtensions().hasOwnProperty('foo'), true)
w.webContents.on('devtools-opened', function () {
var showPanelIntevalId = setInterval(function () {