Merge pull request #2754 from atom/fix-node-integration
Fix "node-integration" not working in "web-preferences"
This commit is contained in:
commit
708526baec
6 changed files with 41 additions and 99 deletions
|
@ -182,16 +182,37 @@ describe 'browser-window module', ->
|
||||||
assert.equal after[0], size.width
|
assert.equal after[0], size.width
|
||||||
assert.equal after[1], size.height
|
assert.equal after[1], size.height
|
||||||
|
|
||||||
describe '"preload" options', ->
|
describe '"web-preferences" option', ->
|
||||||
|
afterEach ->
|
||||||
|
remote.require('ipc').removeAllListeners('answer')
|
||||||
|
|
||||||
|
describe '"preload" option', ->
|
||||||
it 'loads the script before other scripts in window', (done) ->
|
it 'loads the script before other scripts in window', (done) ->
|
||||||
preload = path.join fixtures, 'module', 'set-global.js'
|
preload = path.join fixtures, 'module', 'set-global.js'
|
||||||
remote.require('ipc').once 'preload', (event, test) ->
|
remote.require('ipc').once 'answer', (event, test) ->
|
||||||
assert.equal(test, 'preload')
|
assert.equal(test, 'preload')
|
||||||
done()
|
done()
|
||||||
w.destroy()
|
w.destroy()
|
||||||
w = new BrowserWindow(show: false, width: 400, height: 400, preload: preload)
|
w = new BrowserWindow
|
||||||
|
show: false
|
||||||
|
'web-preferences':
|
||||||
|
preload: preload
|
||||||
w.loadUrl 'file://' + path.join(fixtures, 'api', 'preload.html')
|
w.loadUrl 'file://' + path.join(fixtures, 'api', 'preload.html')
|
||||||
|
|
||||||
|
describe '"node-integration" option', ->
|
||||||
|
it 'disables node integration when specified to false', (done) ->
|
||||||
|
preload = path.join fixtures, 'module', 'send-later.js'
|
||||||
|
remote.require('ipc').once 'answer', (event, test) ->
|
||||||
|
assert.equal(test, 'undefined')
|
||||||
|
done()
|
||||||
|
w.destroy()
|
||||||
|
w = new BrowserWindow
|
||||||
|
show: false
|
||||||
|
'web-preferences':
|
||||||
|
preload: preload
|
||||||
|
'node-integration': false
|
||||||
|
w.loadUrl 'file://' + path.join(fixtures, 'api', 'blank.html')
|
||||||
|
|
||||||
describe 'beforeunload handler', ->
|
describe 'beforeunload handler', ->
|
||||||
it 'returning true would not prevent close', (done) ->
|
it 'returning true would not prevent close', (done) ->
|
||||||
w.on 'closed', ->
|
w.on 'closed', ->
|
||||||
|
|
5
spec/fixtures/api/blank.html
vendored
Normal file
5
spec/fixtures/api/blank.html
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<html>
|
||||||
|
<script type="text/javascript" charset="utf-8">
|
||||||
|
window;
|
||||||
|
</script>
|
||||||
|
</html>
|
2
spec/fixtures/api/preload.html
vendored
2
spec/fixtures/api/preload.html
vendored
|
@ -3,7 +3,7 @@
|
||||||
<script type="text/javascript" charset="utf-8">
|
<script type="text/javascript" charset="utf-8">
|
||||||
if (!window.test)
|
if (!window.test)
|
||||||
window.test = 'window'
|
window.test = 'window'
|
||||||
require('ipc').send('preload', window.test);
|
require('ipc').send('answer', window.test);
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
4
spec/fixtures/module/send-later.js
vendored
Normal file
4
spec/fixtures/module/send-later.js
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
var ipc = require('ipc');
|
||||||
|
window.onload = function() {
|
||||||
|
ipc.send('answer', typeof window.process);
|
||||||
|
}
|
|
@ -2,7 +2,6 @@ var app = require('app');
|
||||||
var ipc = require('ipc');
|
var ipc = require('ipc');
|
||||||
var dialog = require('dialog');
|
var dialog = require('dialog');
|
||||||
var BrowserWindow = require('browser-window');
|
var BrowserWindow = require('browser-window');
|
||||||
var Menu = require('menu');
|
|
||||||
|
|
||||||
var window = null;
|
var window = null;
|
||||||
process.port = 0; // will be used by crash-reporter spec.
|
process.port = 0; // will be used by crash-reporter spec.
|
||||||
|
@ -52,93 +51,6 @@ app.on('window-all-closed', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
app.on('ready', function() {
|
app.on('ready', function() {
|
||||||
var template = [
|
|
||||||
{
|
|
||||||
label: 'Atom',
|
|
||||||
submenu: [
|
|
||||||
{
|
|
||||||
label: 'Quit',
|
|
||||||
accelerator: 'CommandOrControl+Q',
|
|
||||||
click: function(item, window) { app.quit(); }
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Edit',
|
|
||||||
submenu: [
|
|
||||||
{
|
|
||||||
label: 'Undo',
|
|
||||||
accelerator: 'CommandOrControl+Z',
|
|
||||||
selector: 'undo:',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Redo',
|
|
||||||
accelerator: 'CommandOrControl+Shift+Z',
|
|
||||||
selector: 'redo:',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'separator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Cut',
|
|
||||||
accelerator: 'CommandOrControl+X',
|
|
||||||
selector: 'cut:',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Copy',
|
|
||||||
accelerator: 'CommandOrControl+C',
|
|
||||||
selector: 'copy:',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Paste',
|
|
||||||
accelerator: 'CommandOrControl+V',
|
|
||||||
selector: 'paste:',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Select All',
|
|
||||||
accelerator: 'CommandOrControl+A',
|
|
||||||
selector: 'selectAll:',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'View',
|
|
||||||
submenu: [
|
|
||||||
{
|
|
||||||
label: 'Reload',
|
|
||||||
accelerator: 'CommandOrControl+R',
|
|
||||||
click: function(item, window) { window.restart(); }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Enter Fullscreen',
|
|
||||||
click: function(item, window) { window.setFullScreen(true); }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Toggle DevTools',
|
|
||||||
accelerator: 'Alt+CommandOrControl+I',
|
|
||||||
click: function(item, window) { window.toggleDevTools(); }
|
|
||||||
},
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Window',
|
|
||||||
submenu: [
|
|
||||||
{
|
|
||||||
label: 'Open',
|
|
||||||
accelerator: 'CommandOrControl+O',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Close',
|
|
||||||
accelerator: 'CommandOrControl+W',
|
|
||||||
click: function(item, window) { window.close(); }
|
|
||||||
},
|
|
||||||
]
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
var menu = Menu.buildFromTemplate(template);
|
|
||||||
app.setApplicationMenu(menu);
|
|
||||||
|
|
||||||
// Test if using protocol module would crash.
|
// Test if using protocol module would crash.
|
||||||
require('protocol').registerStringProtocol('test-if-crashes', function() {});
|
require('protocol').registerStringProtocol('test-if-crashes', function() {});
|
||||||
|
|
||||||
|
|
2
vendor/native_mate
vendored
2
vendor/native_mate
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 8ca005eb41591f583ebab804945311903f866ad6
|
Subproject commit b7387da0854b20d376fdae0d93a01f83d080668d
|
Loading…
Reference in a new issue