From 1f245d5ff6b7c4170696182aa110bf1279ea9169 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 10 Jun 2016 09:24:00 -0700 Subject: [PATCH] Add getDevToolsExtensions API --- lib/browser/chrome-extension.js | 9 +++++++-- spec/api-browser-window-spec.js | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/browser/chrome-extension.js b/lib/browser/chrome-extension.js index d3f8aab694e8..8739c7a0aba3 100644 --- a/lib/browser/chrome-extension.js +++ b/lib/browser/chrome-extension.js @@ -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 } }) diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index d9f50b6195a3..42a9b0887a99 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -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 () {