Skip to content

Commit e411b49

Browse files
committed
Fix and update debugger UTF char test
1 parent b32a7d4 commit e411b49

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

spec/api-debugger-spec.js

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ describe('debugger module', () => {
134134
})
135135
})
136136

137-
// TODO(deepak1556): Find a way to enable this spec.
138-
xit('handles invalid unicode characters in message', (done) => {
137+
it('handles valid unicode characters in message', (done) => {
139138
try {
140139
w.webContents.debugger.attach()
141140
} catch (err) {
@@ -146,12 +145,39 @@ describe('debugger module', () => {
146145
if (method === 'Network.loadingFinished') {
147146
w.webContents.debugger.sendCommand('Network.getResponseBody', {
148147
requestId: params.requestId
149-
}, () => {
148+
}, (_, data) => {
149+
assert.equal(data.body, '\u0024')
150150
done()
151151
})
152152
}
153153
})
154154

155+
server = http.createServer((req, res) => {
156+
res.setHeader('Content-Type', 'text/plain; charset=utf-8')
157+
res.end('\u0024')
158+
})
159+
160+
server.listen(0, '127.0.0.1', () => {
161+
w.webContents.debugger.sendCommand('Network.enable')
162+
w.loadURL(`http://127.0.0.1:${server.address().port}`)
163+
})
164+
})
165+
166+
it('does not crash for invalid unicode characters in message', (done) => {
167+
try {
168+
w.webContents.debugger.attach()
169+
} catch (err) {
170+
done(`unexpected error : ${err}`)
171+
}
172+
173+
w.webContents.debugger.on('message', (event, method, params) => {
174+
// loadingFinished indicates that page has been loaded and it did not
175+
// crash because of invalid UTF-8 data
176+
if (method === 'Network.loadingFinished') {
177+
done()
178+
}
179+
})
180+
155181
server = http.createServer((req, res) => {
156182
res.setHeader('Content-Type', 'text/plain; charset=utf-8')
157183
res.end('\uFFFF')

0 commit comments

Comments
 (0)