Add failing spec for invalid debugger message
This commit is contained in:
parent
f84c75aa1a
commit
db6097ecec
1 changed files with 39 additions and 0 deletions
|
@ -1,4 +1,6 @@
|
|||
const assert = require('assert')
|
||||
const fs = require('fs')
|
||||
const http = require('http')
|
||||
const path = require('path')
|
||||
const {closeWindow} = require('./window-helpers')
|
||||
const BrowserWindow = require('electron').remote.BrowserWindow
|
||||
|
@ -70,6 +72,15 @@ describe('debugger module', function () {
|
|||
})
|
||||
|
||||
describe('debugger.sendCommand', function () {
|
||||
let server
|
||||
|
||||
afterEach(function () {
|
||||
if (server != null) {
|
||||
server.close()
|
||||
server = null
|
||||
}
|
||||
})
|
||||
|
||||
it('retuns response', function (done) {
|
||||
w.webContents.loadURL('about:blank')
|
||||
try {
|
||||
|
@ -125,5 +136,33 @@ describe('debugger module', function () {
|
|||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('handles invalid unicode characters in message', function (done) {
|
||||
try {
|
||||
w.webContents.debugger.attach()
|
||||
} catch (err) {
|
||||
done('unexpected error : ' + err)
|
||||
}
|
||||
|
||||
w.webContents.debugger.on('message', (event, method, params) => {
|
||||
if (method === 'Network.loadingFinished') {
|
||||
w.webContents.debugger.sendCommand('Network.getResponseBody', {
|
||||
requestId: params.requestId
|
||||
}, () => {
|
||||
done()
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
server = http.createServer((req, res) => {
|
||||
res.setHeader('Content-Type', 'text/plain; charset=utf-8')
|
||||
res.end('\uFFFF')
|
||||
})
|
||||
|
||||
server.listen(0, '127.0.0.1', () => {
|
||||
w.webContents.debugger.sendCommand('Network.enable')
|
||||
w.loadURL(`http://127.0.0.1:${server.address().port}`)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue