         callback(text)
         callback()
       protocol.registerStringProtocol protocolName, doubleHandler, (error) ->
+        return done(error) if error
         $.ajax
           url: "#{protocolName}://fake-host"
           success: (data) ->


    it 'sends error when callback is called with nothing', (done) ->
      protocol.interceptBufferProtocol 'http', emptyHandler, (error) ->
        $.ajax
          url: 'http://fake-host'
          success: (data) ->

    it 'sends object as response', (done) ->
      handler = (request, callback) -> callback(path: filePath)
      protocol.registerFileProtocol protocolName, handler, (error) ->
        return done(error) if error
        $.ajax
          url: "#{protocolName}://fake-host"
          success: (data, statux, request) ->
