 
         asyncTest("user close", factor_user_close(protocol))
         asyncTest("server close", factor_server_close(protocol))
+
+test_protocol_errors = (protocol) ->
+    module(protocol)
+    if not SockJS[protocol] or not SockJS[protocol].enabled(client_opts.sockjs_opts)
+        test "[unsupported by client]", ->
+                log('Unsupported protocol (by client): "' + protocol + '"')
+    else if client_opts.disabled_transports and
+          arrIndexOf(client_opts.disabled_transports, protocol) isnt -1
+        test "[unsupported by server]", ->
+                log('Unsupported protocol (by server): "' + protocol + '"')
+    else
+        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)
+    test_protocol_messages(protocol)
 
 
 module('other')

        SockJS.chunkingTest dl.protocol + '//' + dl.hostname + ':1079', (r) ->
            equal(r, false)
            start()

    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)
