fix: destroy WebContents synchronously on shutdown (#15541)

This commit is contained in:
Cheng Zhao 2018-11-09 00:57:28 +09:00 committed by Shelley Vohr
parent 6162d9090d
commit 746beb0d8b
12 changed files with 122 additions and 13 deletions

View file

@ -1,7 +1,10 @@
'use strict'
const chai = require('chai')
const ChildProcess = require('child_process')
const dirtyChai = require('dirty-chai')
const path = require('path')
const { emittedOnce } = require('./events-helpers')
const { closeWindow } = require('./window-helpers')
const { remote } = require('electron')
@ -172,4 +175,14 @@ describe('BrowserView module', () => {
expect(views[0].webContents.id).to.equal(view.webContents.id)
})
})
describe('new BrowserView()', () => {
it('does not crash on exit', async () => {
const appPath = path.join(__dirname, 'fixtures', 'api', 'leak-exit-browserview.js')
const electronPath = remote.getGlobal('process').execPath
const appProcess = ChildProcess.spawn(electronPath, [appPath])
const [code] = await emittedOnce(appProcess, 'close')
expect(code).to.equal(0)
})
})
})