spec: The preload script should be able to receive ipc messages

This commit is contained in:
Cheng Zhao 2015-01-26 15:50:10 -08:00
parent 6c62895898
commit c14c6a3521
2 changed files with 20 additions and 0 deletions

4
spec/fixtures/module/preload-ipc.js vendored Normal file
View file

@ -0,0 +1,4 @@
var ipc = require('ipc');
ipc.on('ping', function(message) {
ipc.sendToHost('pong', message);
});

View file

@ -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/'