spec: "preload" option of BrowserWindow

This commit is contained in:
Cheng Zhao 2014-11-12 15:38:50 +08:00
parent 9f29f66768
commit 58795eaa7e
3 changed files with 20 additions and 0 deletions

View file

@ -136,6 +136,16 @@ describe 'browser-window module', ->
assert.equal after[0], size.width
assert.equal after[1], size.height
describe '"preload" options', ->
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) ->
assert.equal(test, 'preload')
done()
w.destroy()
w = new BrowserWindow(show: false, width: 400, height: 400, preload: preload)
w.loadUrl 'file://' + path.join(fixtures, 'api', 'preload.html')
describe 'beforeunload handler', ->
it 'returning true would not prevent close', (done) ->
w.on 'closed', ->

9
spec/fixtures/api/preload.html vendored Normal file
View file

@ -0,0 +1,9 @@
<html>
<body>
<script type="text/javascript" charset="utf-8">
if (!window.test)
window.test = 'window'
require('ipc').send('preload', window.test);
</script>
</body>
</html>

1
spec/fixtures/module/set-global.js vendored Normal file
View file

@ -0,0 +1 @@
window.test = 'preload';