Skip to content

Commit

Permalink
Merge pull request #8758 from electron/use-local-buffer
Browse files Browse the repository at this point in the history
Use local Buffer variable in module.js require wrapper
  • Loading branch information
kevinsawicki committed Feb 24, 2017
2 parents b936221 + 6c40b1e commit 8e4bdec
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
3 changes: 3 additions & 0 deletions spec/fixtures/module/preload-node-off-wrapper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
setImmediate(function () {
require('./preload-required-module')
})
5 changes: 5 additions & 0 deletions spec/fixtures/module/preload-required-module.js
Original file line number Diff line number Diff line change
@@ -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)
}
12 changes: 11 additions & 1 deletion spec/webview-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ describe('<webview> tag', function () {
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) {
assert.equal(e.message, 'object undefined object function')
done()
Expand All @@ -191,6 +191,16 @@ describe('<webview> tag', function () {
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) {
var message = 'boom!'
var listener = function (e) {
Expand Down
2 changes: 1 addition & 1 deletion vendor/node
Submodule node updated 1 files
+1 −1 lib/module.js

0 comments on commit 8e4bdec

Please sign in to comment.