From e6fec57bd86274c5430dd2d7800fd3f58bb17b87 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 23 Feb 2017 11:26:37 -0800 Subject: [PATCH 1/3] Add failing spec for Buffer from preload required module --- spec/fixtures/module/preload-node-off-wrapper.js | 3 +++ spec/fixtures/module/preload-required-module.js | 5 +++++ spec/webview-spec.js | 12 +++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 spec/fixtures/module/preload-node-off-wrapper.js create mode 100644 spec/fixtures/module/preload-required-module.js diff --git a/spec/fixtures/module/preload-node-off-wrapper.js b/spec/fixtures/module/preload-node-off-wrapper.js new file mode 100644 index 000000000000..dbe1330adcf3 --- /dev/null +++ b/spec/fixtures/module/preload-node-off-wrapper.js @@ -0,0 +1,3 @@ +setImmediate(function () { + require('./preload-required-module') +}) diff --git a/spec/fixtures/module/preload-required-module.js b/spec/fixtures/module/preload-required-module.js new file mode 100644 index 000000000000..fbe6f95dc067 --- /dev/null +++ b/spec/fixtures/module/preload-required-module.js @@ -0,0 +1,5 @@ +try { + console.log([typeof process, typeof setImmediate, typeof global, typeof Buffer].join(' ')) +} catch (e) { + console.log(e.message) +} diff --git a/spec/webview-spec.js b/spec/webview-spec.js index 027a3a952006..83cb0ee925b6 100644 --- a/spec/webview-spec.js +++ b/spec/webview-spec.js @@ -181,7 +181,7 @@ describe(' 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() @@ -191,6 +191,16 @@ describe(' 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') + 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) { From ad03ba73a4234a8e21587b847d5284ecdba4c56c Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 23 Feb 2017 11:30:07 -0800 Subject: [PATCH 2/3] Upgrade node for Buffer wrapper fix --- spec/webview-spec.js | 2 +- vendor/node | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/webview-spec.js b/spec/webview-spec.js index 83cb0ee925b6..c29456b17ea3 100644 --- a/spec/webview-spec.js +++ b/spec/webview-spec.js @@ -191,7 +191,7 @@ describe(' tag', function () { document.body.appendChild(webview) }) - it('preload script can require modules that still use "process" and "Buffer"when nodeintegration is off', function (done) { + 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') done() diff --git a/vendor/node b/vendor/node index 9eeeb53aa697..0f84d972a1b4 160000 --- a/vendor/node +++ b/vendor/node @@ -1 +1 @@ -Subproject commit 9eeeb53aa697a54561ffc6c94f06b3ac5963f398 +Subproject commit 0f84d972a1b48b7da361f9717ff43349a7946abd From 6c40b1eead05f1b9a2b3b5068ebe56ea585dce2d Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 23 Feb 2017 11:35:28 -0800 Subject: [PATCH 3/3] Verify global.Buffer is undefined --- spec/fixtures/module/preload-required-module.js | 2 +- spec/webview-spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/fixtures/module/preload-required-module.js b/spec/fixtures/module/preload-required-module.js index fbe6f95dc067..1028d55cb0ef 100644 --- a/spec/fixtures/module/preload-required-module.js +++ b/spec/fixtures/module/preload-required-module.js @@ -1,5 +1,5 @@ try { - console.log([typeof process, typeof setImmediate, typeof global, typeof Buffer].join(' ')) + console.log([typeof process, typeof setImmediate, typeof global, typeof Buffer, typeof global.Buffer].join(' ')) } catch (e) { console.log(e.message) } diff --git a/spec/webview-spec.js b/spec/webview-spec.js index c29456b17ea3..93924e036c50 100644 --- a/spec/webview-spec.js +++ b/spec/webview-spec.js @@ -193,7 +193,7 @@ describe(' tag', function () { 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') + assert.equal(e.message, 'object undefined object function undefined') done() }) webview.setAttribute('preload', fixtures + '/module/preload-node-off-wrapper.js')