fix: add native function to create preload script (#13032)

* add native function to create preload script

* add tests

* fix formatting

* fix tests

* rerun CI
This commit is contained in:
PalmerAL 2018-07-12 21:17:11 -05:00 committed by Cheng Zhao
parent e922b1733b
commit ffc15e02a6
4 changed files with 36 additions and 4 deletions

View file

@ -249,6 +249,22 @@ describe('<webview> tag', function () {
})
})
it('runs in the correct scope when sandboxed', async () => {
const message = await startLoadingWebViewAndWaitForMessage(webview, {
preload: `${fixtures}/module/preload-context.js`,
src: `file://${fixtures}/api/blank.html`,
webpreferences: 'sandbox=yes'
})
const types = JSON.parse(message)
expect(types).to.include({
require: 'function', // arguments passed to it should be availale
electron: 'undefined', // objects from the scope it is called from should not be available
window: 'object', // the window object should be available
localVar: 'undefined' // but local variables should not be exposed to the window
})
})
it('preload script can require modules that still use "process" and "Buffer" when nodeintegration is off', async () => {
const message = await startLoadingWebViewAndWaitForMessage(webview, {
preload: `${fixtures}/module/preload-node-off-wrapper.js`,