Merge pull request #8758 from electron/use-local-buffer
Use local Buffer variable in module.js require wrapper
This commit is contained in:
commit
8e4bdec6b6
4 changed files with 20 additions and 2 deletions
3
spec/fixtures/module/preload-node-off-wrapper.js
vendored
Normal file
3
spec/fixtures/module/preload-node-off-wrapper.js
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
setImmediate(function () {
|
||||||
|
require('./preload-required-module')
|
||||||
|
})
|
5
spec/fixtures/module/preload-required-module.js
vendored
Normal file
5
spec/fixtures/module/preload-required-module.js
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
try {
|
||||||
|
console.log([typeof process, typeof setImmediate, typeof global, typeof Buffer, typeof global.Buffer].join(' '))
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e.message)
|
||||||
|
}
|
|
@ -181,7 +181,7 @@ describe('<webview> tag', function () {
|
||||||
document.body.appendChild(webview)
|
document.body.appendChild(webview)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('preload script can still use "process" and "Buffer" in required modules when nodeintegration is off', function (done) {
|
it('preload script can still use "process" and "Buffer" 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 function')
|
assert.equal(e.message, 'object undefined object function')
|
||||||
done()
|
done()
|
||||||
|
@ -191,6 +191,16 @@ describe('<webview> tag', function () {
|
||||||
document.body.appendChild(webview)
|
document.body.appendChild(webview)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('preload script can require modules that still use "process" and "Buffer" when nodeintegration is off', function (done) {
|
||||||
|
webview.addEventListener('console-message', function (e) {
|
||||||
|
assert.equal(e.message, 'object undefined object function undefined')
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
webview.setAttribute('preload', fixtures + '/module/preload-node-off-wrapper.js')
|
||||||
|
webview.src = 'file://' + fixtures + '/api/blank.html'
|
||||||
|
document.body.appendChild(webview)
|
||||||
|
})
|
||||||
|
|
||||||
it('receives ipc message in preload script', function (done) {
|
it('receives ipc message in preload script', function (done) {
|
||||||
var message = 'boom!'
|
var message = 'boom!'
|
||||||
var listener = function (e) {
|
var listener = function (e) {
|
||||||
|
|
2
vendor/node
vendored
2
vendor/node
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 9eeeb53aa697a54561ffc6c94f06b3ac5963f398
|
Subproject commit 0f84d972a1b48b7da361f9717ff43349a7946abd
|
Loading…
Reference in a new issue