test: move remote specs to main process (#21387)

This commit is contained in:
Jeremy Apthorp 2019-12-09 10:27:30 -08:00 committed by GitHub
parent 409ef49d3a
commit 7f6b308bf1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 702 additions and 633 deletions

View file

@ -558,4 +558,50 @@ describe('<webview> tag', function () {
expect(error).to.equal('denied')
})
})
describe('enableremotemodule attribute', () => {
let w: BrowserWindow
beforeEach(async () => {
w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, webviewTag: true } })
await w.loadURL('about:blank')
})
afterEach(closeAllWindows)
const generateSpecs = (description: string, sandbox: boolean) => {
describe(description, () => {
const preload = `file://${fixtures}/module/preload-disable-remote.js`
const src = `file://${fixtures}/api/blank.html`
it('enables the remote module by default', async () => {
loadWebView(w.webContents, {
preload,
src,
sandbox: sandbox.toString()
})
const [, webViewContents] = await emittedOnce(app, 'web-contents-created')
const [, , message] = await emittedOnce(webViewContents, 'console-message')
const typeOfRemote = JSON.parse(message)
expect(typeOfRemote).to.equal('object')
})
it('disables the remote module when false', async () => {
loadWebView(w.webContents, {
preload,
src,
sandbox: sandbox.toString(),
enableremotemodule: 'false'
})
const [, webViewContents] = await emittedOnce(app, 'web-contents-created')
const [, , message] = await emittedOnce(webViewContents, 'console-message')
const typeOfRemote = JSON.parse(message)
expect(typeOfRemote).to.equal('undefined')
})
})
}
generateSpecs('without sandbox', false)
generateSpecs('with sandbox', true)
})
})