spec: robustify some webview tests (#17301)

This commit is contained in:
Jeremy Apthorp 2019-03-12 15:50:28 -07:00 committed by Shelley Vohr
parent 14cc8a1808
commit 86291236a0

View file

@ -73,8 +73,9 @@ describe('<webview> tag', function () {
nodeIntegration: true
}
})
const pong = emittedOnce(ipcMain, 'pong')
w.loadFile(path.join(fixtures, 'pages', 'webview-no-script.html'))
await emittedOnce(ipcMain, 'pong')
await pong
})
it('works with sandbox', async () => {
@ -86,8 +87,9 @@ describe('<webview> tag', function () {
sandbox: true
}
})
const pong = emittedOnce(ipcMain, 'pong')
w.loadFile(path.join(fixtures, 'pages', 'webview-isolated.html'))
await emittedOnce(ipcMain, 'pong')
await pong
})
it('works with contextIsolation', async () => {
@ -99,8 +101,9 @@ describe('<webview> tag', function () {
contextIsolation: true
}
})
const pong = emittedOnce(ipcMain, 'pong')
w.loadFile(path.join(fixtures, 'pages', 'webview-isolated.html'))
await emittedOnce(ipcMain, 'pong')
await pong
})
it('works with contextIsolation + sandbox', async () => {
@ -113,8 +116,9 @@ describe('<webview> tag', function () {
sandbox: true
}
})
const pong = emittedOnce(ipcMain, 'pong')
w.loadFile(path.join(fixtures, 'pages', 'webview-isolated.html'))
await emittedOnce(ipcMain, 'pong')
await pong
})
it('is disabled by default', async () => {
@ -126,8 +130,9 @@ describe('<webview> tag', function () {
}
})
const webview = emittedOnce(ipcMain, 'webview')
w.loadFile(path.join(fixtures, 'pages', 'webview-no-script.html'))
const [, type] = await emittedOnce(ipcMain, 'webview')
const [, type] = await webview
expect(type).to.equal('undefined', 'WebView still exists')
})