diff --git a/spec/api-debugger-spec.js b/spec/api-debugger-spec.js index f8597c03409b..9224d643184c 100644 --- a/spec/api-debugger-spec.js +++ b/spec/api-debugger-spec.js @@ -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}`) + }) + }) }) })