test: move debugger spec to main process (#20514)
This commit is contained in:
parent
5c2c30142c
commit
1f44f47de1
2 changed files with 16 additions and 19 deletions
|
@ -50,7 +50,7 @@ Returns:
|
||||||
|
|
||||||
* `event` Event
|
* `event` Event
|
||||||
* `method` String - Method name.
|
* `method` String - Method name.
|
||||||
* `params` unknown - Event parameters defined by the 'parameters'
|
* `params` any - Event parameters defined by the 'parameters'
|
||||||
attribute in the remote debugging protocol.
|
attribute in the remote debugging protocol.
|
||||||
|
|
||||||
Emitted whenever the debugging target issues an instrumentation event.
|
Emitted whenever the debugging target issues an instrumentation event.
|
||||||
|
|
|
@ -1,17 +1,14 @@
|
||||||
const chai = require('chai')
|
import { expect } from 'chai'
|
||||||
const dirtyChai = require('dirty-chai')
|
import * as http from 'http'
|
||||||
const http = require('http')
|
import * as path from 'path'
|
||||||
const path = require('path')
|
import { AddressInfo } from 'net'
|
||||||
const { emittedOnce } = require('./events-helpers')
|
import { BrowserWindow } from 'electron'
|
||||||
const { closeWindow } = require('./window-helpers')
|
import { closeAllWindows } from './window-helpers'
|
||||||
const { BrowserWindow } = require('electron').remote
|
import { emittedOnce } from './events-helpers'
|
||||||
|
|
||||||
const { expect } = chai
|
|
||||||
chai.use(dirtyChai)
|
|
||||||
|
|
||||||
describe('debugger module', () => {
|
describe('debugger module', () => {
|
||||||
const fixtures = path.resolve(__dirname, 'fixtures')
|
const fixtures = path.resolve(__dirname, '..', 'spec', 'fixtures')
|
||||||
let w = null
|
let w: BrowserWindow
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
w = new BrowserWindow({
|
w = new BrowserWindow({
|
||||||
|
@ -21,7 +18,7 @@ describe('debugger module', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => closeWindow(w).then(() => { w = null }))
|
afterEach(closeAllWindows)
|
||||||
|
|
||||||
describe('debugger.attach', () => {
|
describe('debugger.attach', () => {
|
||||||
it('succeeds when devtools is already open', done => {
|
it('succeeds when devtools is already open', done => {
|
||||||
|
@ -87,19 +84,19 @@ describe('debugger module', () => {
|
||||||
})
|
})
|
||||||
w.webContents.debugger.on('detach', (e, reason) => {
|
w.webContents.debugger.on('detach', (e, reason) => {
|
||||||
expect(w.webContents.debugger.isAttached()).to.be.false()
|
expect(w.webContents.debugger.isAttached()).to.be.false()
|
||||||
expect(w.devToolsWebContents.isDestroyed()).to.be.false()
|
expect((w as any).devToolsWebContents.isDestroyed()).to.be.false()
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('debugger.sendCommand', () => {
|
describe('debugger.sendCommand', () => {
|
||||||
let server
|
let server: http.Server
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
if (server != null) {
|
if (server != null) {
|
||||||
server.close()
|
server.close()
|
||||||
server = null
|
server = null as any
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -193,7 +190,7 @@ describe('debugger module', () => {
|
||||||
|
|
||||||
server.listen(0, '127.0.0.1', () => {
|
server.listen(0, '127.0.0.1', () => {
|
||||||
w.webContents.debugger.sendCommand('Network.enable')
|
w.webContents.debugger.sendCommand('Network.enable')
|
||||||
w.loadURL(`http://127.0.0.1:${server.address().port}`)
|
w.loadURL(`http://127.0.0.1:${(server.address() as AddressInfo).port}`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -219,7 +216,7 @@ describe('debugger module', () => {
|
||||||
|
|
||||||
server.listen(0, '127.0.0.1', () => {
|
server.listen(0, '127.0.0.1', () => {
|
||||||
w.webContents.debugger.sendCommand('Network.enable')
|
w.webContents.debugger.sendCommand('Network.enable')
|
||||||
w.loadURL(`http://127.0.0.1:${server.address().port}`)
|
w.loadURL(`http://127.0.0.1:${(server.address() as AddressInfo).port}`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
Loading…
Reference in a new issue