Merge pull request #11774 from nitsakh/fix-invalid-utf
Handle invalid utf8 characters for debugger
This commit is contained in:
commit
e6a5990b95
1 changed files with 29 additions and 3 deletions
|
@ -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')
|
||||
|
|
Loading…
Reference in a new issue