From baacc939f673a7632ee4086878b1098ca33a8d33 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 14 Sep 2015 16:05:58 +0800 Subject: [PATCH] spec: node symbols should always be available in preload script --- spec/fixtures/module/preload-node-off.js | 7 +++++++ spec/webview-spec.coffee | 8 ++++++++ 2 files changed, 15 insertions(+) create mode 100644 spec/fixtures/module/preload-node-off.js diff --git a/spec/fixtures/module/preload-node-off.js b/spec/fixtures/module/preload-node-off.js new file mode 100644 index 00000000000..9020f4513a1 --- /dev/null +++ b/spec/fixtures/module/preload-node-off.js @@ -0,0 +1,7 @@ +setImmediate(function() { + try { + console.log([typeof process, typeof setImmediate, typeof global].join(' ')); + } catch (e) { + console.log(e.message); + } +}); diff --git a/spec/webview-spec.coffee b/spec/webview-spec.coffee index 3eeacb0ad0e..e5a97e65fc0 100644 --- a/spec/webview-spec.coffee +++ b/spec/webview-spec.coffee @@ -84,6 +84,14 @@ describe ' tag', -> webview.src = "file://#{fixtures}/pages/e.html" document.body.appendChild webview + it 'preload script can still use "process" in required modules when nodeintegration is off', (done) -> + webview.addEventListener 'console-message', (e) -> + assert.equal e.message, 'object function object' + done() + webview.setAttribute 'preload', "#{fixtures}/module/preload-node-off.js" + webview.src = "file://#{fixtures}/api/blank.html" + document.body.appendChild webview + it 'receives ipc message in preload script', (done) -> message = 'boom!' listener = (e) ->