Add spec for deleting Buffer global in preload

This commit is contained in:
Kevin Sawicki 2016-09-08 10:34:09 -07:00
parent d476227e16
commit aaf2bb2751
2 changed files with 27 additions and 0 deletions

View file

@ -542,6 +542,22 @@ describe('browser-window module', function () {
})
w.loadURL('file://' + path.join(fixtures, 'api', 'preload.html'))
})
it('can successfully delete the Buffer global', function (done) {
var preload = path.join(fixtures, 'module', 'delete-buffer.js')
ipcMain.once('answer', function (event, test) {
assert.equal(test.toString(), 'buffer')
done()
})
w.destroy()
w = new BrowserWindow({
show: false,
webPreferences: {
preload: preload
}
})
w.loadURL('file://' + path.join(fixtures, 'api', 'preload.html'))
})
})
describe('"node-integration" option', function () {

11
spec/fixtures/module/delete-buffer.js vendored Normal file
View file

@ -0,0 +1,11 @@
const path = require('path')
const {remote} = require('electron')
const {Buffer} = window
delete window.Buffer
delete global.Buffer
// Test that remote.js doesn't use Buffer global
remote.require(path.join(__dirname, 'print_name.js')).echo(new Buffer('bar'))
window.test = new Buffer('buffer')