diff --git a/spec/api-debugger-spec.js b/spec/api-debugger-spec.js index fe7ca0422b10..d8fe42029988 100644 --- a/spec/api-debugger-spec.js +++ b/spec/api-debugger-spec.js @@ -72,6 +72,24 @@ describe('debugger module', () => { } w.webContents.debugger.detach() }) + + it('doesn\'t disconnect an active devtools session', done => { + w.webContents.loadURL('about:blank') + try { + w.webContents.debugger.attach() + } catch (err) { + return done(`unexpected error : ${err}`) + } + w.webContents.openDevTools() + w.webContents.once('devtools-opened', () => { + w.webContents.debugger.detach() + }) + w.webContents.debugger.on('detach', (e, reason) => { + expect(w.webContents.debugger.isAttached()).to.be.false() + expect(w.devToolsWebContents.isDestroyed()).to.be.false() + done() + }) + }) }) describe('debugger.sendCommand', () => { @@ -105,6 +123,27 @@ describe('debugger module', () => { w.webContents.debugger.sendCommand('Runtime.evaluate', params, callback) }) + it('returns response when devtools is opened', done => { + w.webContents.loadURL('about:blank') + try { + w.webContents.debugger.attach() + } catch (err) { + return done(`unexpected error : ${err}`) + } + const callback = (err, res) => { + expect(err.message).to.be.undefined() + expect(res.wasThrown).to.be.undefined() + expect(res.result.value).to.equal(6) + w.webContents.debugger.detach() + done() + } + w.webContents.openDevTools() + w.webContents.once('devtools-opened', () => { + const params = {'expression': '4+2'} + w.webContents.debugger.sendCommand('Runtime.evaluate', params, callback) + }) + }) + it('fires message event', done => { const url = process.platform !== 'win32' ? `file://${path.join(fixtures, 'pages', 'a.html')}`