Add failing spec for invalid debugger message

This commit is contained in:
Kevin Sawicki 2017-04-28 09:28:11 -07:00
parent f84c75aa1a
commit db6097ecec

View file

@ -1,4 +1,6 @@
const assert = require('assert') const assert = require('assert')
const fs = require('fs')
const http = require('http')
const path = require('path') const path = require('path')
const {closeWindow} = require('./window-helpers') const {closeWindow} = require('./window-helpers')
const BrowserWindow = require('electron').remote.BrowserWindow const BrowserWindow = require('electron').remote.BrowserWindow
@ -70,6 +72,15 @@ describe('debugger module', function () {
}) })
describe('debugger.sendCommand', function () { describe('debugger.sendCommand', function () {
let server
afterEach(function () {
if (server != null) {
server.close()
server = null
}
})
it('retuns response', function (done) { it('retuns response', function (done) {
w.webContents.loadURL('about:blank') w.webContents.loadURL('about:blank')
try { try {
@ -125,5 +136,33 @@ describe('debugger module', function () {
done() 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}`)
})
})
}) })
}) })