fix: check the result when calling js function (#17443)

* fix: check the result when calling js function

* test: should not crash when callback returns nothing
This commit is contained in:
Cheng Zhao 2019-03-21 00:27:06 +09:00 committed by Shelley Vohr
parent 1571461bae
commit 671533f7d2
5 changed files with 26 additions and 18 deletions

View file

@ -2525,17 +2525,26 @@ describe('BrowserWindow module', () => {
describe('beginFrameSubscription method', () => {
before(function () {
// This test is too slow, only test it on CI.
if (!isCI) {
this.skip()
}
// FIXME These specs crash on Linux when run in a docker container
if (isCI && process.platform === 'linux') {
this.skip()
}
})
it('does not crash when callback returns nothing', (done) => {
w.loadFile(path.join(fixtures, 'api', 'frame-subscriber.html'))
w.webContents.on('dom-ready', () => {
w.webContents.beginFrameSubscription(function (data) {
// Pending endFrameSubscription to next tick can reliably reproduce
// a crash which happens when nothing is returned in the callback.
setTimeout(() => {
w.webContents.endFrameSubscription()
done()
})
})
})
})
it('subscribes to frame updates', (done) => {
let called = false
w.loadFile(path.join(fixtures, 'api', 'frame-subscriber.html'))