This commit is contained in:
Kevin Sawicki 2017-02-06 13:54:41 -08:00
Родитель 80dad58a59
Коммит 70010fdb8e
5 изменённых файлов: 11 добавлений и 10 удалений

Просмотреть файл

@ -801,8 +801,9 @@ describe('BrowserWindow module', function () {
describe('"node-integration" option', function () {
it('disables node integration when specified to false', function (done) {
var preload = path.join(fixtures, 'module', 'send-later.js')
ipcMain.once('answer', function (event, test) {
assert.equal(test, 'undefined')
ipcMain.once('answer', function (event, typeofProcess, typeofBuffer) {
assert.equal(typeofProcess, 'undefined')
assert.equal(typeofBuffer, 'undefined')
done()
})
w.destroy()

2
spec/fixtures/module/preload-node-off.js поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
setImmediate(function () {
try {
console.log([typeof process, typeof setImmediate, typeof global].join(' '))
console.log([typeof process, typeof setImmediate, typeof global, typeof Buffer].join(' '))
} catch (e) {
console.log(e.message)
}

2
spec/fixtures/module/preload.js поставляемый
Просмотреть файл

@ -1 +1 @@
console.log([typeof require, typeof module, typeof process].join(' '))
console.log([typeof require, typeof module, typeof process, typeof Buffer].join(' '))

2
spec/fixtures/module/send-later.js поставляемый
Просмотреть файл

@ -1,4 +1,4 @@
var ipcRenderer = require('electron').ipcRenderer
window.onload = function () {
ipcRenderer.send('answer', typeof window.process)
ipcRenderer.send('answer', typeof window.process, typeof window.Buffer)
}

Просмотреть файл

@ -171,7 +171,7 @@ describe('<webview> tag', function () {
describe('preload attribute', function () {
it('loads the script before other scripts in window', function (done) {
var listener = function (e) {
assert.equal(e.message, 'function object object')
assert.equal(e.message, 'function object object function')
webview.removeEventListener('console-message', listener)
done()
}
@ -181,9 +181,9 @@ describe('<webview> tag', function () {
document.body.appendChild(webview)
})
it('preload script can still use "process" in required modules when nodeintegration is off', function (done) {
it('preload script can still use "process" and "Buffer" in required modules when nodeintegration is off', function (done) {
webview.addEventListener('console-message', function (e) {
assert.equal(e.message, 'object undefined object')
assert.equal(e.message, 'object undefined object function')
done()
})
webview.setAttribute('preload', fixtures + '/module/preload-node-off.js')
@ -212,7 +212,7 @@ describe('<webview> tag', function () {
it('works without script tag in page', function (done) {
var listener = function (e) {
assert.equal(e.message, 'function object object')
assert.equal(e.message, 'function object object function')
webview.removeEventListener('console-message', listener)
done()
}
@ -224,7 +224,7 @@ describe('<webview> tag', function () {
it('resolves relative URLs', function (done) {
var listener = function (e) {
assert.equal(e.message, 'function object object')
assert.equal(e.message, 'function object object function')
webview.removeEventListener('console-message', listener)
done()
}