Converted callback can only be called for once

This commit is contained in:
Cheng Zhao 2015-10-28 20:44:46 +08:00
parent 4eac6b31b1
commit f40a3f72d7
3 changed files with 32 additions and 25 deletions

View file

@ -23,8 +23,10 @@ describe 'protocol module', ->
it 'does not crash when handler is called twice', (done) ->
doubleHandler = (request, callback) ->
callback(text)
callback()
try
callback(text)
callback()
catch
protocol.registerStringProtocol protocolName, doubleHandler, (error) ->
return done(error) if error
$.ajax
@ -302,8 +304,10 @@ describe 'protocol module', ->
it 'does not crash when handler is called twice', (done) ->
doubleHandler = (request, callback) ->
callback(text)
callback()
try
callback(text)
callback()
catch
protocol.interceptStringProtocol 'http', doubleHandler, (error) ->
return done(error) if error
$.ajax