spec: "preload" option of BrowserWindow
This commit is contained in:
parent
9f29f66768
commit
58795eaa7e
3 changed files with 20 additions and 0 deletions
|
@ -136,6 +136,16 @@ 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', ->
|
||||||
|
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', ->
|
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', ->
|
||||||
|
|
9
spec/fixtures/api/preload.html
vendored
Normal file
9
spec/fixtures/api/preload.html
vendored
Normal 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
1
spec/fixtures/module/set-global.js
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
window.test = 'preload';
|
Loading…
Reference in a new issue