diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index a8dd8a3780cc..52af001d765f 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -824,6 +824,54 @@ describe('browser-window module', function () { }) describe('dev tool extensions', function () { + describe('BrowserWindow.addDevToolsExtension', function () { + this.timeout(10000) + + beforeEach(function () { + BrowserWindow.removeDevToolsExtension('foo') + + var extensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', 'foo') + BrowserWindow.addDevToolsExtension(extensionPath) + + w.webContents.on('devtools-opened', function () { + var showPanelIntevalId = setInterval(function () { + if (w && w.devToolsWebContents) { + w.devToolsWebContents.executeJavaScript('(' + (function () { + var lastPanelId = WebInspector.inspectorView._tabbedPane._tabs.peekLast().id + WebInspector.inspectorView.showPanel(lastPanelId) + }).toString() + ')()') + } else { + clearInterval(showPanelIntevalId) + } + }, 100) + }) + + w.loadURL('about:blank') + }) + + describe('when the devtools is docked', function () { + it('creates the extension', function (done) { + w.webContents.openDevTools({mode: 'bottom'}) + + ipcMain.once('answer', function (event, message) { + assert.equal(message, 'extension loaded') + done() + }) + }) + }) + + describe('when the devtools is undocked', function () { + it('creates the extension', function (done) { + w.webContents.openDevTools({mode: 'undocked'}) + + ipcMain.once('answer', function (event, message) { + assert.equal(message, 'extension loaded') + done() + }) + }) + }) + }) + it('serializes the registered extensions on quit', function () { var extensionName = 'foo' var extensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', extensionName) diff --git a/spec/fixtures/devtools-extensions/foo/foo.html b/spec/fixtures/devtools-extensions/foo/foo.html new file mode 100644 index 000000000000..a326639c38de --- /dev/null +++ b/spec/fixtures/devtools-extensions/foo/foo.html @@ -0,0 +1,10 @@ + + +
+ +