Add spec for Buffer global
This commit is contained in:
parent
80dad58a59
commit
70010fdb8e
5 changed files with 11 additions and 10 deletions
|
@ -801,8 +801,9 @@ describe('BrowserWindow module', function () {
|
||||||
describe('"node-integration" option', function () {
|
describe('"node-integration" option', function () {
|
||||||
it('disables node integration when specified to false', function (done) {
|
it('disables node integration when specified to false', function (done) {
|
||||||
var preload = path.join(fixtures, 'module', 'send-later.js')
|
var preload = path.join(fixtures, 'module', 'send-later.js')
|
||||||
ipcMain.once('answer', function (event, test) {
|
ipcMain.once('answer', function (event, typeofProcess, typeofBuffer) {
|
||||||
assert.equal(test, 'undefined')
|
assert.equal(typeofProcess, 'undefined')
|
||||||
|
assert.equal(typeofBuffer, 'undefined')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
w.destroy()
|
w.destroy()
|
||||||
|
|
2
spec/fixtures/module/preload-node-off.js
vendored
2
spec/fixtures/module/preload-node-off.js
vendored
|
@ -1,6 +1,6 @@
|
||||||
setImmediate(function () {
|
setImmediate(function () {
|
||||||
try {
|
try {
|
||||||
console.log([typeof process, typeof setImmediate, typeof global].join(' '))
|
console.log([typeof process, typeof setImmediate, typeof global, typeof Buffer].join(' '))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e.message)
|
console.log(e.message)
|
||||||
}
|
}
|
||||||
|
|
2
spec/fixtures/module/preload.js
vendored
2
spec/fixtures/module/preload.js
vendored
|
@ -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
vendored
2
spec/fixtures/module/send-later.js
vendored
|
@ -1,4 +1,4 @@
|
||||||
var ipcRenderer = require('electron').ipcRenderer
|
var ipcRenderer = require('electron').ipcRenderer
|
||||||
window.onload = function () {
|
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 () {
|
describe('preload attribute', function () {
|
||||||
it('loads the script before other scripts in window', function (done) {
|
it('loads the script before other scripts in window', function (done) {
|
||||||
var listener = function (e) {
|
var listener = function (e) {
|
||||||
assert.equal(e.message, 'function object object')
|
assert.equal(e.message, 'function object object function')
|
||||||
webview.removeEventListener('console-message', listener)
|
webview.removeEventListener('console-message', listener)
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
|
@ -181,9 +181,9 @@ describe('<webview> tag', function () {
|
||||||
document.body.appendChild(webview)
|
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) {
|
webview.addEventListener('console-message', function (e) {
|
||||||
assert.equal(e.message, 'object undefined object')
|
assert.equal(e.message, 'object undefined object function')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
webview.setAttribute('preload', fixtures + '/module/preload-node-off.js')
|
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) {
|
it('works without script tag in page', function (done) {
|
||||||
var listener = function (e) {
|
var listener = function (e) {
|
||||||
assert.equal(e.message, 'function object object')
|
assert.equal(e.message, 'function object object function')
|
||||||
webview.removeEventListener('console-message', listener)
|
webview.removeEventListener('console-message', listener)
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,7 @@ describe('<webview> tag', function () {
|
||||||
|
|
||||||
it('resolves relative URLs', function (done) {
|
it('resolves relative URLs', function (done) {
|
||||||
var listener = function (e) {
|
var listener = function (e) {
|
||||||
assert.equal(e.message, 'function object object')
|
assert.equal(e.message, 'function object object function')
|
||||||
webview.removeEventListener('console-message', listener)
|
webview.removeEventListener('console-message', listener)
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue