From e411b49f4e59fb4313a46b16fa21dc6be74fe0ec Mon Sep 17 00:00:00 2001 From: Nitish Sakhawalkar Date: Thu, 1 Feb 2018 16:47:52 -0800 Subject: [PATCH] Fix and update debugger UTF char test --- spec/api-debugger-spec.js | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/spec/api-debugger-spec.js b/spec/api-debugger-spec.js index 34840b203afc..1d98e7993946 100644 --- a/spec/api-debugger-spec.js +++ b/spec/api-debugger-spec.js @@ -134,8 +134,7 @@ describe('debugger module', () => { }) }) - // TODO(deepak1556): Find a way to enable this spec. - xit('handles invalid unicode characters in message', (done) => { + it('handles valid unicode characters in message', (done) => { try { w.webContents.debugger.attach() } catch (err) { @@ -146,12 +145,39 @@ describe('debugger module', () => { if (method === 'Network.loadingFinished') { w.webContents.debugger.sendCommand('Network.getResponseBody', { requestId: params.requestId - }, () => { + }, (_, data) => { + assert.equal(data.body, '\u0024') done() }) } }) + server = http.createServer((req, res) => { + res.setHeader('Content-Type', 'text/plain; charset=utf-8') + res.end('\u0024') + }) + + server.listen(0, '127.0.0.1', () => { + w.webContents.debugger.sendCommand('Network.enable') + w.loadURL(`http://127.0.0.1:${server.address().port}`) + }) + }) + + it('does not crash for invalid unicode characters in message', (done) => { + try { + w.webContents.debugger.attach() + } catch (err) { + done(`unexpected error : ${err}`) + } + + w.webContents.debugger.on('message', (event, method, params) => { + // loadingFinished indicates that page has been loaded and it did not + // crash because of invalid UTF-8 data + if (method === 'Network.loadingFinished') { + done() + } + }) + server = http.createServer((req, res) => { res.setHeader('Content-Type', 'text/plain; charset=utf-8') res.end('\uFFFF')