+protocols = ['websocket',
+        'xhr-streaming',
+        'iframe-eventsource',
+        'iframe-htmlfile',
+        'xhr-polling',
+        'iframe-xhr-polling',
+        'jsonp-polling']
+
 newSockJS = (path, protocol) ->
     url = if /^http/.test(path) then path else client_opts.url + path
     return new SockJS(url, [protocol], client_opts.sockjs_opts)


        asyncTest("user close", factor_user_close(protocol))
        asyncTest("server close", factor_server_close(protocol))
        asyncTest("invalid url 404", test_invalid_url_404(protocol))
        asyncTest("invalid url 500", test_invalid_url_500(protocol))
        asyncTest("invalid url port", test_invalid_url_port(protocol))


protocols = ['websocket',
        'xhr-streaming',
        'iframe-eventsource',
        'iframe-htmlfile',
        'xhr-polling',
        'iframe-xhr-polling',
        'jsonp-polling']
for protocol in protocols
    test_protocol(protocol)


module('other')

    r.removeEventListener 'message', bluff
    r.dispatchEvent({type:'message'})

chunking_test_factory = (counter) ->
    return ->
        expect(counter)
        a = new Array(counter)
        go = ->
            SockJS.chunkingTest client_opts.url + '/echo', (r) ->
                if $.browser.msie and $.browser.version < 8
                    # on browsers with no streaming support...
                    equal(r, false)
                else
                    equal(r, true)
                a.shift()
                if a.length isnt 0
                    go()
                else
                    start()
        go()

asyncTest "chunking test (simple)", chunking_test_factory(1)
asyncTest "chunking test (stability)", chunking_test_factory(25)



asyncTest "chunking test, invalid url 404", ->
        expect(1)
