Browse Source

chore: add debugger specs for multiple sessions (#14598)

Robo 6 years ago
parent
commit
d9c6dd0254
1 changed files with 39 additions and 0 deletions
  1. 39 0
      spec/api-debugger-spec.js

+ 39 - 0
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')}`