spec: node-integration should work in web-preferences
This commit is contained in:
parent
6321a3898c
commit
d4cbf7cadb
4 changed files with 40 additions and 10 deletions
|
@ -182,16 +182,37 @@ describe 'browser-window module', ->
|
|||
assert.equal after[0], size.width
|
||||
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) ->
|
||||
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')
|
||||
done()
|
||||
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')
|
||||
|
||||
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', ->
|
||||
it 'returning true would not prevent close', (done) ->
|
||||
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">
|
||||
if (!window.test)
|
||||
window.test = 'window'
|
||||
require('ipc').send('preload', window.test);
|
||||
require('ipc').send('answer', window.test);
|
||||
</script>
|
||||
</body>
|
||||
</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);
|
||||
}
|
Loading…
Reference in a new issue