[Pkg-javascript-commits] [sockjs-client] 270/434: #36 Remove chunking_test remains

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:47:18 UTC 2014


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch master
in repository sockjs-client.

commit 20397de3016fb336ec33621cebde3767eda3f67d
Author: Marek Majkowski <majek04 at gmail.com>
Date:   Fri Jan 6 13:16:56 2012 +0000

    #36 Remove chunking_test remains
---
 lib/chunking-test.js            | 94 -----------------------------------------
 lib/index.js                    |  1 -
 lib/trans-iframe-eventsource.js |  1 -
 lib/trans-iframe-htmlfile.js    |  1 -
 lib/trans-xhr-streaming.js      |  3 --
 tests/html/src/tests.coffee     | 42 ------------------
 6 files changed, 142 deletions(-)

diff --git a/lib/chunking-test.js b/lib/chunking-test.js
deleted file mode 100644
index 13007be..0000000
--- a/lib/chunking-test.js
+++ /dev/null
@@ -1,94 +0,0 @@
-var doChunkingTest = function(base_url, callback, cors) {
-    var recv = new XhrReceiver(base_url + '/chunking_test', {cors: cors});
-    var result = 0;
-    recv.onmessage = function(e) {
-        // Now a cool hack: we can stop receiving after we got at least
-        // one chunk, contains some data, but not everyting.
-        var l = e.responsetext.split('h\n').length;
-        if(e.readystate === 3 && l > 0 && l < 6 ) {
-            result = l;
-            recv.abort();
-        }
-    };
-    recv.onclose = function(e) {
-        recv = recv.onmessage = recv.onclose = null;
-        utils.log('Chunking test: ' + (result ? 'passed' : 'failed')
-                  + ' (' + result + ' chunk received)');
-        callback(!!result);
-    };
-};
-
-var ChunkingTestIframe = FacadeJS['w-iframe-chunking-test'] = function (ri, trans_url, base_url) {
-    doChunkingTest(base_url, function(r) {
-                       ri._didMessage('m'+r);
-                       ri._didClose();
-                   }, false);
-};
-ChunkingTestIframe.prototype.doCleanup = function() {};
-
-var chunkingTestUncached = SockJS.chunkingTest = function(base_url, callback, options) {
-    base_url = utils.amendUrl(base_url);
-    // 1. CORS
-    if (_window.XDomainRequest ||
-         (_window.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest())) {
-        doChunkingTest(base_url, callback, true);
-        return;
-    }
-    if(!_document.body) {
-        utils.attachEvent('load', function(){
-            chunkingTestWithBody(base_url, callback, options);
-        });
-    } else {
-        chunkingTestWithBody(base_url, callback, options);
-    }
-}
-var chunkingTestWithBody = function(base_url, callback, options) {
-    // 2. Iframe
-    if (IframeTransport.enabled()) {
-        var ifr = new IframeTransport();
-        ifr.protocol = 'w-iframe-chunking-test';
-        var fun = function(r) {
-            if (ifr) {
-                callback(r === 'mtrue');
-                ifr.doCleanup();
-                ifr = null;
-            }
-        };
-        var mock_ri = {
-            _options: options || {},
-            _didClose: fun,
-            _didMessage: fun
-        };
-        ifr.i_constructor(mock_ri, '', base_url);
-        return;
-    }
-    // 3. Fall back to polling (IE 7)
-    setTimeout(function() {
-                   callback(false);
-               }, 0);
-    return;
-};
-
-// Although chunking test is run against a particular 'base_url', it's
-// safe to assume that if chunking works for client, it will work for
-// any SockJS server. That means we can cache the result of
-// chunkingTest, at least until user switches network. Let's assume a
-// value of 10 seconds.
-var chunkingTest = function() {
-    var value;
-    var t0 = 0;
-    return function (base_url, callback) {
-        var t1 = (new Date()).getTime();
-        if (t1 - t0 > 10000) {
-            chunkingTestUncached(base_url, function (v) {
-                                     value = v;
-                                     t0 = (new Date()).getTime();
-                                     callback(value);
-                                 });
-        } else {
-            setTimeout(function() {
-                           callback(value);
-                       }, 0);
-        }
-    };
-}();
diff --git a/lib/index.js b/lib/index.js
index e5fb574..1fe2aba 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -15,7 +15,6 @@ SockJS = (function(){
 <!-- include lib/trans-xhr-polling.js -->
 <!-- include lib/trans-iframe.js -->
 <!-- include lib/trans-iframe-within.js -->
-<!-- include lib/chunking-test.js -->
 <!-- include lib/info.js -->
 <!-- include lib/trans-iframe-eventsource.js -->
 <!-- include lib/trans-iframe-xhr-polling.js -->
diff --git a/lib/trans-iframe-eventsource.js b/lib/trans-iframe-eventsource.js
index 7b2e0e9..77d85d1 100644
--- a/lib/trans-iframe-eventsource.js
+++ b/lib/trans-iframe-eventsource.js
@@ -11,7 +11,6 @@ EventSourceIframeTransport.enabled = function () {
     return ('EventSource' in window) && IframeTransport.enabled();
 };
 
-EventSourceIframeTransport.need_chunking = true;
 EventSourceIframeTransport.need_body = true;
 
 
diff --git a/lib/trans-iframe-htmlfile.js b/lib/trans-iframe-htmlfile.js
index 7348d4a..8cf1eb2 100644
--- a/lib/trans-iframe-htmlfile.js
+++ b/lib/trans-iframe-htmlfile.js
@@ -18,7 +18,6 @@ HtmlFileIframeTransport.enabled = function (options) {
     return (options.cookie !== false && IframeTransport.enabled());
 };
 
-HtmlFileIframeTransport.need_chunking = true;
 HtmlFileIframeTransport.need_body = true;
 
 
diff --git a/lib/trans-xhr-streaming.js b/lib/trans-xhr-streaming.js
index 98189aa..dd26efb 100644
--- a/lib/trans-xhr-streaming.js
+++ b/lib/trans-xhr-streaming.js
@@ -28,6 +28,3 @@ XhrStreamingTransport.enabled = function(options) {
         'withCredentials' in new XMLHttpRequest()) return true;
     return false;
 };
-
-XhrStreamingTransport.need_chunking = true;
-
diff --git a/tests/html/src/tests.coffee b/tests/html/src/tests.coffee
index de8464d..35652c7 100644
--- a/tests/html/src/tests.coffee
+++ b/tests/html/src/tests.coffee
@@ -388,48 +388,6 @@ test "EventEmitter", ->
     r.dispatchEvent({type:'close'}) # 0 runs
 
 
-chunking_test_factory = (counter) ->
-    return ->
-        expect(counter)
-        a = new Array(counter)
-        go = ->
-            SockJS.chunkingTest client_opts.url + '/echo', (r) ->
-                if $.browser.msie and not window.XDomainRequest
-                    # 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)
-        SockJS.chunkingTest client_opts.url + '/invalid_url', (r) ->
-            equal(r, false)
-            start()
-
-asyncTest "chunking test, invalid url 500", ->
-        expect(1)
-        SockJS.chunkingTest client_opts.url + '/500_error', (r) ->
-            equal(r, false)
-            start()
-
-asyncTest "chunking test, invalid url port", ->
-        expect(1)
-        dl = document.location
-        SockJS.chunkingTest dl.protocol + '//' + dl.hostname + ':1079', (r) ->
-            equal(r, false)
-            start()
-
 asyncTest "disabled websocket test", ->
         expect(3)
         r = newSockJS('/disabled_websocket_echo', 'websocket')

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git



More information about the Pkg-javascript-commits mailing list