spec: de-flake ses.protocol test (#18884)

This commit is contained in:
Jeremy Apthorp 2019-06-20 09:54:33 -07:00 committed by GitHub
parent c27231ce5c
commit e95d2129be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -265,7 +265,7 @@ describe('session module', () => {
let customSession = null let customSession = null
const protocol = session.defaultSession.protocol const protocol = session.defaultSession.protocol
const handler = (ignoredError, callback) => { const handler = (ignoredError, callback) => {
callback({ data: 'test', mimeType: 'text/html' }) callback({ data: `<script>require('electron').ipcRenderer.send('hello')</script>`, mimeType: 'text/html' })
} }
beforeEach(async () => { beforeEach(async () => {
@ -273,7 +273,8 @@ describe('session module', () => {
w = new BrowserWindow({ w = new BrowserWindow({
show: false, show: false,
webPreferences: { webPreferences: {
partition: partitionName partition: partitionName,
nodeIntegration: true,
} }
}) })
customSession = session.fromPartition(partitionName) customSession = session.fromPartition(partitionName)
@ -294,8 +295,8 @@ describe('session module', () => {
}) })
it('handles requests from partition', async () => { it('handles requests from partition', async () => {
await w.loadURL(`${protocolName}://fake-host`) w.loadURL(`${protocolName}://fake-host`)
expect(await w.webContents.executeJavaScript('document.body.textContent')).to.equal('test') await emittedOnce(ipcMain, 'hello')
}) })
}) })