spec: The preload script should be able to receive ipc messages
This commit is contained in:
parent
6c62895898
commit
c14c6a3521
2 changed files with 20 additions and 0 deletions
4
spec/fixtures/module/preload-ipc.js
vendored
Normal file
4
spec/fixtures/module/preload-ipc.js
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
var ipc = require('ipc');
|
||||
ipc.on('ping', function(message) {
|
||||
ipc.sendToHost('pong', message);
|
||||
});
|
|
@ -58,6 +58,22 @@ describe '<webview> tag', ->
|
|||
webview.src = "file://#{fixtures}/pages/e.html"
|
||||
document.body.appendChild webview
|
||||
|
||||
it 'receives ipc message in preload script', (done) ->
|
||||
message = 'boom!'
|
||||
listener = (e) ->
|
||||
assert.equal e.channel, 'pong'
|
||||
assert.deepEqual e.args, [message]
|
||||
webview.removeEventListener 'ipc-message', listener
|
||||
done()
|
||||
listener2 = (e) ->
|
||||
webview.send 'ping', message
|
||||
webview.removeEventListener 'did-finish-load', listener2
|
||||
webview.addEventListener 'ipc-message', listener
|
||||
webview.addEventListener 'did-finish-load', listener2
|
||||
webview.setAttribute 'preload', "#{fixtures}/module/preload-ipc.js"
|
||||
webview.src = "file://#{fixtures}/pages/e.html"
|
||||
document.body.appendChild webview
|
||||
|
||||
describe 'httpreferrer attribute', ->
|
||||
it 'sets the referrer url', (done) ->
|
||||
referrer = 'http://github.com/'
|
||||
|
|
Loading…
Reference in a new issue