Add spec for destroying synchronous event.

This commit is contained in:
Cheng Zhao 2013-09-26 11:27:09 +08:00
parent 65176761f4
commit 5480cf58c2
4 changed files with 33 additions and 3 deletions

View file

@ -2,6 +2,9 @@ assert = require 'assert'
ipc = require 'ipc'
path = require 'path'
remote = require 'remote'
BrowserWindow = remote.require 'browser-window'
fixtures = path.resolve __dirname, '..', 'fixtures'
describe 'ipc', ->
fixtures = path.join __dirname, '..', 'fixtures'
@ -58,3 +61,13 @@ describe 'ipc', ->
it 'can be replied by setting event.returnValue', ->
msg = ipc.sendChannelSync 'echo', 'test'
assert.equal msg, 'test'
it 'does not crash when reply is not sent and both browser and event are destroyed', (done) ->
w = new BrowserWindow(show: false)
remote.require('ipc').once 'send-sync-message', (event) ->
event.returnValue = null
w.destroy()
event.destroy()
done()
w.loadUrl 'file://' + path.join(fixtures, 'api', 'send-sync-message.html')

View file

@ -0,0 +1,9 @@
<html>
<body>
<script type="text/javascript" charset="utf-8">
var ipc = require('ipc');
ipc.sendChannelSync('send-sync-message', 'message');
</script>
</body>
</html>