|
@@ -2,6 +2,7 @@ const chai = require('chai')
|
|
|
const dirtyChai = require('dirty-chai')
|
|
|
const http = require('http')
|
|
|
const path = require('path')
|
|
|
+const { emittedOnce } = require('./events-helpers')
|
|
|
const { closeWindow } = require('./window-helpers')
|
|
|
const { BrowserWindow } = require('electron').remote
|
|
|
|
|
@@ -102,7 +103,21 @@ describe('debugger module', () => {
|
|
|
}
|
|
|
})
|
|
|
|
|
|
- it('returns response', done => {
|
|
|
+ it('returns response', async () => {
|
|
|
+ w.webContents.loadURL('about:blank')
|
|
|
+ w.webContents.debugger.attach()
|
|
|
+
|
|
|
+ const params = { 'expression': '4+2' }
|
|
|
+ const res = await w.webContents.debugger.sendCommand('Runtime.evaluate', params)
|
|
|
+
|
|
|
+ expect(res.wasThrown).to.be.undefined()
|
|
|
+ expect(res.result.value).to.equal(6)
|
|
|
+
|
|
|
+ w.webContents.debugger.detach()
|
|
|
+ })
|
|
|
+
|
|
|
+ // TODO(miniak): remove when promisification is complete
|
|
|
+ it('returns response (callback)', done => {
|
|
|
w.webContents.loadURL('about:blank')
|
|
|
try {
|
|
|
w.webContents.debugger.attach()
|
|
@@ -123,7 +138,24 @@ describe('debugger module', () => {
|
|
|
w.webContents.debugger.sendCommand('Runtime.evaluate', params, callback)
|
|
|
})
|
|
|
|
|
|
- it('returns response when devtools is opened', done => {
|
|
|
+ it('returns response when devtools is opened', async () => {
|
|
|
+ w.webContents.loadURL('about:blank')
|
|
|
+ w.webContents.debugger.attach()
|
|
|
+
|
|
|
+ w.webContents.openDevTools()
|
|
|
+ await emittedOnce(w.webContents, 'devtools-opened')
|
|
|
+
|
|
|
+ const params = { 'expression': '4+2' }
|
|
|
+ const res = await w.webContents.debugger.sendCommand('Runtime.evaluate', params)
|
|
|
+
|
|
|
+ expect(res.wasThrown).to.be.undefined()
|
|
|
+ expect(res.result.value).to.equal(6)
|
|
|
+
|
|
|
+ w.webContents.debugger.detach()
|
|
|
+ })
|
|
|
+
|
|
|
+ // TODO(miniak): remove when promisification is complete
|
|
|
+ it('returns response when devtools is opened (callback)', done => {
|
|
|
w.webContents.loadURL('about:blank')
|
|
|
try {
|
|
|
w.webContents.debugger.attach()
|
|
@@ -169,7 +201,18 @@ describe('debugger module', () => {
|
|
|
w.webContents.debugger.sendCommand('Console.enable')
|
|
|
})
|
|
|
|
|
|
- it('returns error message when command fails', done => {
|
|
|
+ it('returns error message when command fails', async () => {
|
|
|
+ w.webContents.loadURL('about:blank')
|
|
|
+ w.webContents.debugger.attach()
|
|
|
+
|
|
|
+ const promise = w.webContents.debugger.sendCommand('Test')
|
|
|
+ await expect(promise).to.be.eventually.rejectedWith(Error, "'Test' wasn't found")
|
|
|
+
|
|
|
+ w.webContents.debugger.detach()
|
|
|
+ })
|
|
|
+
|
|
|
+ // TODO(miniak): remove when promisification is complete
|
|
|
+ it('returns error message when command fails (callback)', done => {
|
|
|
w.webContents.loadURL('about:blank')
|
|
|
try {
|
|
|
w.webContents.debugger.attach()
|
|
@@ -177,9 +220,8 @@ describe('debugger module', () => {
|
|
|
done(`unexpected error : ${err}`)
|
|
|
}
|
|
|
|
|
|
- w.webContents.debugger.sendCommand('Test', err => {
|
|
|
- expect(err).to.not.be.null()
|
|
|
- expect(err.message).to.equal("'Test' wasn't found")
|
|
|
+ w.webContents.debugger.sendCommand('Test', (err, res) => {
|
|
|
+ expect(err).to.be.an.instanceOf(Error).with.property('message', "'Test' wasn't found")
|
|
|
w.webContents.debugger.detach()
|
|
|
done()
|
|
|
})
|