[Pkg-javascript-commits] [sockjs-client] 82/350: Fix #184 remove need for SockJS global for protocol detection

tonnerre at ancient-solutions.com tonnerre at ancient-solutions.com
Fri Aug 5 01:03:45 UTC 2016


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

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

commit 718406f0763585ba4771908b49077212428d8d06
Author: Bryce Kahle <bkahle at gmail.com>
Date:   Sun Aug 24 23:43:52 2014 -0400

    Fix #184 remove need for SockJS global for protocol detection
---
 lib/protocols.js                |  40 +++++++++
 lib/sockjs.js                   |  67 +++++----------
 lib/trans-iframe-eventsource.js |   1 +
 lib/trans-iframe-htmlfile.js    |   1 +
 lib/trans-iframe-xhr-polling.js |   1 +
 lib/trans-jsonp-polling.js      |   2 +-
 lib/trans-websocket.js          |   1 +
 lib/trans-xdr-polling.js        |   1 +
 lib/trans-xdr-streaming.js      |   5 +-
 lib/trans-xhr-polling.js        |   4 +-
 lib/trans-xhr-streaming.js      |   5 +-
 lib/utils.js                    |  71 ----------------
 package.json                    |   1 +
 tests/html/lib/domtests.js      |  38 ++++++++-
 tests/html/lib/tests.js         |  16 ++--
 tests/html/lib/unittests.js     | 183 ++++++++++++++++++++--------------------
 16 files changed, 214 insertions(+), 223 deletions(-)

diff --git a/lib/protocols.js b/lib/protocols.js
new file mode 100644
index 0000000..f4e7125
--- /dev/null
+++ b/lib/protocols.js
@@ -0,0 +1,40 @@
+'use strict';
+
+var protocolOrdering = [
+  'websocket',
+  'xdr-streaming',
+  'xhr-streaming',
+  'iframe-eventsource',
+  'iframe-htmlfile',
+  'xdr-polling',
+  'xhr-polling',
+  'iframe-xhr-polling',
+  'jsonp-polling'
+];
+
+var allProtocols = {
+  'websocket': require('./trans-websocket')
+, 'iframe-eventsource': require('./trans-iframe-eventsource')
+, 'iframe-htmlfile': require('./trans-iframe-htmlfile')
+, 'iframe-xhr-polling': require('./trans-iframe-xhr-polling')
+, 'jsonp-polling': require('./trans-jsonp-polling')
+, 'xdr-polling': require('./trans-xdr-polling')
+, 'xdr-streaming': require('./trans-xdr-streaming')
+, 'xhr-polling': require('./trans-xhr-polling')
+, 'xhr-streaming': require('./trans-xhr-streaming')
+};
+
+module.exports = function (url, protocols_whitelist, info) {
+  var protocols = [];
+  if (!protocols_whitelist) protocols_whitelist = [];
+  if (!protocols_whitelist.length) protocols_whitelist = protocolOrdering;
+
+  for (var i = 0; i < protocolOrdering.length; i++) {
+    var protoName = protocolOrdering[i];
+    if (protocols_whitelist.indexOf(protoName) === -1) continue;
+
+    var proto = allProtocols[protoName];
+    if (proto && proto.enabled(url, info)) protocols.push(proto);
+  }
+  return protocols;
+};
\ No newline at end of file
diff --git a/lib/sockjs.js b/lib/sockjs.js
index 661957e..a49ccf0 100644
--- a/lib/sockjs.js
+++ b/lib/sockjs.js
@@ -21,6 +21,8 @@ var XDRObject = require('./xdr');
 var XDRPolling = require('./trans-xdr-polling');
 var IframeTransport = require('./trans-iframe');
 
+var protocols = require('./protocols')
+
 function SockJS(url, _reserved, options) {
     if (!(this instanceof SockJS)) {
         // makes `new` optional
@@ -83,6 +85,7 @@ SockJS.prototype._dispatchOpen = function() {
             that._transport_tref = null;
         }
         that.readyState = SockJS.OPEN;
+        that.protocol = that._transport.transportName;
         that.dispatchEvent(new SimpleEvent("open"));
     } else {
         // The server might have been restarted, and lost track of our
@@ -195,40 +198,32 @@ SockJS.prototype._try_next_protocol = function(close_event) {
         that._try_next_protocol();
     }
 
-    while(1) {
-        var protocol = that.protocol = that._protocols.shift();
-        if (!protocol) {
+    while (true) {
+        var Protocol = that._protocols.shift();
+        if (!Protocol) {
             return false;
         }
-        // Some protocols require access to `body`, what if were in
-        // the `head`?
-        if (SockJS[protocol] &&
-            SockJS[protocol].need_body === true &&
+        // Some protocols require access to `body`, what if we are in the `head`?
+        if (Protocol.need_body === true &&
             (!document.body ||
              (typeof document.readyState !== 'undefined'
               && document.readyState !== 'complete'))) {
-            that._protocols.unshift(protocol);
+            that._protocols.unshift(Protocol);
             that.protocol = 'waiting-for-load';
             utils.attachEvent('load', tryNextProtocol);
             return true;
         }
-
-        if (!SockJS[protocol] ||
-              !SockJS[protocol].enabled(that._base_url)) {
-            that._log('Skipping transport:', protocol);
-        } else {
-            var roundTrips = SockJS[protocol].roundTrips || 1;
-            var to = ((that._rto || 0) * roundTrips) || 5000;
-            that._transport_tref = utils.delay(to, timeoutFunction);
-
-            var connid = utils.random_string(8);
-            var trans_url = that._base_url + '/' + that._server + '/' + connid;
-            that._log('Opening transport:', protocol, ' url:'+trans_url,
-                        ' RTO:'+that._rto);
-            that._transport = new SockJS[protocol](that, trans_url,
-                                                   that._base_url);
-            return true;
-        }
+        
+        var roundTrips = Protocol.roundTrips || 1;
+        var to = ((that._rto || 0) * roundTrips) || 5000;
+        that._transport_tref = utils.delay(to, timeoutFunction);
+
+        var connid = utils.random_string(8);
+        var trans_url = that._base_url + '/' + that._server + '/' + connid;
+        that._log('Opening transport:', Protocol.transportName, ' url:'+trans_url,
+                    ' RTO:'+that._rto);
+        that._transport = new Protocol(that, trans_url, that._base_url);
+        return true;
     }
 };
 
@@ -263,10 +258,8 @@ SockJS.prototype._applyInfo = function(info, rtt, protocols_whitelist) {
     info.null_origin = !document.domain;
     // Servers can override base_url, eg to provide a randomized domain name and
     // avoid browser per-domain connection limits.
-    if (info.base_url)
-      that._base_url = utils.amendUrl(info.base_url);
-    var probed = utils.probeProtocols(that._base_url);
-    that._protocols = utils.detectProtocols(probed, protocols_whitelist, info);
+    if (info.base_url) that._base_url = utils.amendUrl(info.base_url);
+    that._protocols = protocols(that._base_url, protocols_whitelist, info);
 };
 
 utils.parent_origin = undefined;
@@ -329,16 +322,6 @@ SockJS.bootstrap_iframe = function() {
     utils.postMessage('s');
 };
 
-SockJS.websocket = require('./trans-websocket');
-SockJS['iframe-eventsource'] = require('./trans-iframe-eventsource');
-SockJS['iframe-htmlfile'] = require('./trans-iframe-htmlfile');
-SockJS['iframe-xhr-polling'] = require('./trans-iframe-xhr-polling');
-SockJS['jsonp-polling'] = require('./trans-jsonp-polling');
-SockJS['xdr-polling'] = XDRPolling;
-SockJS['xdr-streaming'] = require('./trans-xdr-streaming');
-SockJS['xhr-polling'] = require('./trans-xhr-polling');
-SockJS['xhr-streaming'] = require('./trans-xhr-streaming');
-
 module.exports = SockJS;
 
 FacadeJS['w-iframe-info-receiver'] = require('./info-receiver-iframe');
@@ -346,12 +329,6 @@ FacadeJS['w-iframe-eventsource'] = require('./trans-eventsource');
 FacadeJS['w-iframe-htmlfile'] = require('./trans-htmlfile');
 FacadeJS['w-iframe-xhr-polling'] = require('./xhr-polling-iframe');
 
-// TODO get rid of both of these!!!!
-SockJS.getUtils = function () { return utils; };
-
-// This is seriously wack.
-if ('_sockjs_onload' in window) setTimeout(window._sockjs_onload, 1);
-
 function createInfoReceiver(base_url) {
     if (utils.isSameOriginUrl(base_url)) {
         // If, for some reason, we have SockJS locally - there's no
diff --git a/lib/trans-iframe-eventsource.js b/lib/trans-iframe-eventsource.js
index 9fb261e..ed0bc59 100644
--- a/lib/trans-iframe-eventsource.js
+++ b/lib/trans-iframe-eventsource.js
@@ -21,6 +21,7 @@ EventSourceIframeTransport.enabled = function () {
     return ('EventSource' in window) && IframeTransport.enabled();
 };
 
+EventSourceIframeTransport.transportName = 'iframe-eventsource';
 EventSourceIframeTransport.need_body = true;
 EventSourceIframeTransport.roundTrips = 3; // html, javascript, eventsource
 
diff --git a/lib/trans-iframe-htmlfile.js b/lib/trans-iframe-htmlfile.js
index 4b98293..0b25ae5 100644
--- a/lib/trans-iframe-htmlfile.js
+++ b/lib/trans-iframe-htmlfile.js
@@ -27,6 +27,7 @@ HtmlFileIframeTransport.enabled = function() {
     return IframeTransport.enabled();
 };
 
+HtmlFileIframeTransport.transportName = 'iframe-htmlfile';
 HtmlFileIframeTransport.need_body = true;
 HtmlFileIframeTransport.roundTrips = 3; // html, javascript, htmlfile
 
diff --git a/lib/trans-iframe-xhr-polling.js b/lib/trans-iframe-xhr-polling.js
index 2588566..d5137a3 100644
--- a/lib/trans-iframe-xhr-polling.js
+++ b/lib/trans-iframe-xhr-polling.js
@@ -21,6 +21,7 @@ XhrPollingIframeTransport.enabled = function () {
     return window.XMLHttpRequest && IframeTransport.enabled();
 };
 
+XhrPollingIframeTransport.transportName = 'iframe-xhr-polling';
 XhrPollingIframeTransport.need_body = true;
 XhrPollingIframeTransport.roundTrips = 3; // html, javascript, xhr
 
diff --git a/lib/trans-jsonp-polling.js b/lib/trans-jsonp-polling.js
index 62efa6b..ede68a2 100644
--- a/lib/trans-jsonp-polling.js
+++ b/lib/trans-jsonp-polling.js
@@ -53,9 +53,9 @@ JsonPTransport.enabled = function() {
     return true;
 };
 
+JsonPTransport.transportName = 'jsonp-polling';
 JsonPTransport.need_body = true;
 
-
 JsonPTransport.prototype.doCleanup = function() {
     var that = this;
     that._is_closing = true;
diff --git a/lib/trans-websocket.js b/lib/trans-websocket.js
index 222816f..13ca273 100644
--- a/lib/trans-websocket.js
+++ b/lib/trans-websocket.js
@@ -56,6 +56,7 @@ WebSocketTransport.prototype.doCleanup = function() {
 WebSocketTransport.enabled = function() {
     return !!(window.WebSocket || window.MozWebSocket);
 };
+WebSocketTransport.transportName = 'websocket';
 
 // In theory, ws should require 1 round trip. But in chrome, this is
 // not very stable over SSL. Most likely a ws connection requires a
diff --git a/lib/trans-xdr-polling.js b/lib/trans-xdr-polling.js
index 9a78871..ceb210c 100644
--- a/lib/trans-xdr-polling.js
+++ b/lib/trans-xdr-polling.js
@@ -19,6 +19,7 @@ function XdrPollingTransport(ri, trans_url) {
 XdrPollingTransport.prototype = new AjaxBasedTransport();
 
 XdrPollingTransport.enabled = XdrStreamingTransport.enabled;
+XdrPollingTransport.transportName = 'xdr-polling';
 XdrPollingTransport.roundTrips = 2; // preflight, ajax
 
 module.exports = XdrPollingTransport;
\ No newline at end of file
diff --git a/lib/trans-xdr-streaming.js b/lib/trans-xdr-streaming.js
index 2b0de41..ed71485 100644
--- a/lib/trans-xdr-streaming.js
+++ b/lib/trans-xdr-streaming.js
@@ -22,11 +22,14 @@ function XdrStreamingTransport(ri, trans_url) {
 
 XdrStreamingTransport.prototype = new AjaxBasedTransport();
 
-XdrStreamingTransport.enabled = function(url) {
+XdrStreamingTransport.enabled = function(url, info) {
+    if (info.cookie_needed || info.null_origin) return false;
     // IE 8/9 if the request target uses the same scheme - #79
     return !!(window.XDomainRequest && document.domain && utils.isSameOriginScheme(url));
 };
 
+XdrStreamingTransport.transportName = 'xdr-streaming';
+
 XdrStreamingTransport.roundTrips = 2; // preflight, ajax
 
 module.exports = XdrStreamingTransport;
\ No newline at end of file
diff --git a/lib/trans-xhr-polling.js b/lib/trans-xhr-polling.js
index 1656908..4c55ef5 100644
--- a/lib/trans-xhr-polling.js
+++ b/lib/trans-xhr-polling.js
@@ -18,11 +18,13 @@ function XhrPollingTransport(ri, trans_url) {
 
 XhrPollingTransport.prototype = new AjaxBasedTransport();
 
-XhrPollingTransport.enabled = function(url) {
+XhrPollingTransport.enabled = function(url, info) {
+    if (info.null_origin) return false;
     if (window.XMLHttpRequest && utils.isSameOriginUrl(url)) return true;
     return utils.isXHRCorsCapable() === 1;
 };
 
+XhrPollingTransport.transportName = 'xhr-polling';
 XhrPollingTransport.roundTrips = 2; // preflight, ajax
 
 module.exports = XhrPollingTransport;
\ No newline at end of file
diff --git a/lib/trans-xhr-streaming.js b/lib/trans-xhr-streaming.js
index b51f16c..c394c81 100644
--- a/lib/trans-xhr-streaming.js
+++ b/lib/trans-xhr-streaming.js
@@ -18,13 +18,16 @@ function XhrStreamingTransport(ri, trans_url) {
 
 XhrStreamingTransport.prototype = new AjaxBasedTransport();
 
-XhrStreamingTransport.enabled = function(url) {
+XhrStreamingTransport.enabled = function(url, info) {
+    if (info.null_origin) return false;
     // Opera doesn't support xhr-streaming
     if (/opera/i.test(navigator.userAgent)) return false;
     if (window.XMLHttpRequest && utils.isSameOriginUrl(url)) return true;
 
     return utils.isXHRCorsCapable() === 1;
 };
+
+XhrStreamingTransport.transportName = 'xhr-streaming';
 XhrStreamingTransport.roundTrips = 2; // preflight, ajax
 
 // Safari gets confused when a streaming ajax request is started
diff --git a/lib/utils.js b/lib/utils.js
index 6c015a2..d56d516 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -305,77 +305,6 @@ utils.quote = function(string) {
     });
 };
 
-var _all_protocols = ['websocket',
-                      'xdr-streaming',
-                      'xhr-streaming',
-                      'iframe-eventsource',
-                      'iframe-htmlfile',
-                      'xdr-polling',
-                      'xhr-polling',
-                      'iframe-xhr-polling',
-                      'jsonp-polling'];
-
-utils.probeProtocols = function(url) {
-    var probed = {};
-    for(var i=0; i<_all_protocols.length; i++) {
-        var protocol = _all_protocols[i];
-        // User can have a typo in protocol name.
-        probed[protocol] = SockJS[protocol] &&
-                           SockJS[protocol].enabled(url);
-    }
-    return probed;
-};
-
-utils.detectProtocols = function(probed, protocols_whitelist, info) {
-    var pe = {},
-        protocols = [];
-    if (!protocols_whitelist || !protocols_whitelist.length) protocols_whitelist = _all_protocols;
-    for(var i=0; i<protocols_whitelist.length; i++) {
-        var protocol = protocols_whitelist[i];
-        pe[protocol] = probed[protocol];
-    }
-    var maybe_push = function(protos) {
-        var proto = protos.shift();
-        if (pe[proto]) {
-            protocols.push(proto);
-        } else {
-            if (protos.length > 0) {
-                maybe_push(protos);
-            }
-        }
-    };
-
-    // 1. Websocket
-    if (info.websocket !== false) {
-        maybe_push(['websocket']);
-    }
-
-    // 2. Streaming
-    if (pe['xhr-streaming'] && !info.null_origin) {
-        protocols.push('xhr-streaming');
-    } else {
-        if (pe['xdr-streaming'] && !info.cookie_needed && !info.null_origin) {
-            protocols.push('xdr-streaming');
-        } else {
-            maybe_push(['iframe-eventsource',
-                        'iframe-htmlfile']);
-        }
-    }
-
-    // 3. Polling
-    if (pe['xhr-polling'] && !info.null_origin) {
-        protocols.push('xhr-polling');
-    } else {
-        if (pe['xdr-polling'] && !info.cookie_needed && !info.null_origin) {
-            protocols.push('xdr-polling');
-        } else {
-            maybe_push(['iframe-xhr-polling',
-                        'jsonp-polling']);
-        }
-    }
-    return protocols;
-};
-
 // 1. Is natively via XHR
 // 2. Is natively via XDR
 // 3. Nope, but postMessage is there so it should work via the Iframe.
diff --git a/package.json b/package.json
index a99bac5..b89038f 100644
--- a/package.json
+++ b/package.json
@@ -33,6 +33,7 @@
     "websocket"
   ],
   "license": "MIT",
+  "main": "./lib/sockjs.js",
   "private": true,
   "repository": {
     "type": "git",
diff --git a/tests/html/lib/domtests.js b/tests/html/lib/domtests.js
index 17263f4..120d4e1 100644
--- a/tests/html/lib/domtests.js
+++ b/tests/html/lib/domtests.js
@@ -1,5 +1,6 @@
 'use strict';
 /* global suite, test */
+/* jshint multistr: true */
 var ajax_simple_factory, ajax_streaming_factory, ajax_wrong_port_factory, onunload_test_factory, test_wrong_url;
 
 suite('DOM');
@@ -39,7 +40,27 @@ if (navigator.userAgent.indexOf('Konqueror') !== -1 || navigator.userAgent.index
   test('onunload', function (done) {
     this.timeout(5000);
     this.runnable().globals(['_sockjs_global']);
-    onunload_test_factory("var u = SockJS.getUtils();\nu.attachEvent('load', function(){\n    hook.load();\n});\nvar w = 0;\nvar run = function(){\n    if(w === 0) {\n        w = 1;\n        hook.unload();\n    }\n};\nu.attachEvent('beforeunload', run);\nu.attachEvent('unload', run);", done);
+    onunload_test_factory("\
+      function attachEvent(event, listener) {\n\
+          if (typeof window.addEventListener !== 'undefined') {\n\
+              window.addEventListener(event, listener, false);\n\
+          } else {\n\
+              document.attachEvent('on' + event, listener);\n\
+              window.attachEvent('on' + event, listener);\n\
+          }\n\
+      }\n\
+      attachEvent('load', function(){\n\
+          hook.load();\n\
+      });\n\
+      var w = 0;\n\
+      var run = function(){\n\
+          if(w === 0) {\n\
+              w = 1;\n\
+              hook.unload();\n\
+          }\n\
+      };\n\
+      attachEvent('beforeunload', run);\n\
+      attachEvent('unload', run);", done);
   });
 }
 
@@ -55,7 +76,20 @@ if (!require('../../../lib/trans-iframe').enabled()) {
     hook = testutils.newIframe();
     hook.open = function() {
       assert.ok(true, 'open hook called by an iframe');
-      hook.callback("var u = SockJS.getUtils();\nu.attachMessage(function(e) {\n    var b = e.data;\n    parent.postMessage(window_id + ' ' + 'e', '*');\n});\nparent.postMessage(window_id + ' ' + 's', '*');");
+      hook.callback("\
+        function attachEvent(event, listener) {\n\
+            if (typeof window.addEventListener !== 'undefined') {\n\
+                window.addEventListener(event, listener, false);\n\
+            } else {\n\
+                document.attachEvent('on' + event, listener);\n\
+                window.attachEvent('on' + event, listener);\n\
+            }\n\
+        }\n\
+        attachMessage(function(e) {\n\
+            var b = e.data;\n\
+            parent.postMessage(window_id + ' ' + 'e', '*');\n\
+        });\n\
+        parent.postMessage(window_id + ' ' + 's', '*');");
     };
     u.attachMessage(function(e) {
       var _ref = e.data.split(' ')
diff --git a/tests/html/lib/tests.js b/tests/html/lib/tests.js
index f5eeaf5..ac3f0c6 100644
--- a/tests/html/lib/tests.js
+++ b/tests/html/lib/tests.js
@@ -5,6 +5,7 @@ var arrIndexOf, batch_factory_factory, batch_factory_factory_amp, echo_factory_f
 var assert = require('assert');
 var u = require('../../../lib/utils');
 var testutils = require('./testutils');
+var protocols = require('../../../lib/protocols')
 
 var TIMEOUT_MS = 10000;
 
@@ -310,11 +311,7 @@ arrIndexOf = function(arr, obj) {
 
 test_protocol_messages = function(protocol) {
   suite(protocol);
-  if (!SockJS[protocol] || !SockJS[protocol].enabled(client_opts.url)) {
-    test("[unsupported by client]", function() {
-      assert.ok(true, 'Unsupported protocol (by client): "' + protocol + '"');
-    });
-  } else if (client_opts.disabled_transports && arrIndexOf(client_opts.disabled_transports, protocol) !== -1) {
+  if (client_opts.disabled_transports && arrIndexOf(client_opts.disabled_transports, protocol) !== -1) {
     test("[disabled by config]", function() {
       assert.ok(true, 'Disabled by config: "' + protocol + '"');
     });
@@ -334,9 +331,8 @@ test_protocol_messages = function(protocol) {
   }
 };
 
-var protocols = ['websocket', 'xdr-streaming', 'xhr-streaming', 'iframe-eventsource', 'iframe-htmlfile', 'xdr-polling', 'xhr-polling', 'iframe-xhr-polling', 'jsonp-polling'];
-
-for (var _i = 0, _len = 0, _len = protocols.length; _i < _len; _i++) {
-  var protocol = protocols[_i];
-  test_protocol_messages(protocol);
+var validProtocols = protocols(client_opts.url, [], { cookie_needed: false, null_origin: false });
+for (var i = 0; i < validProtocols.length; i++) {
+  var Protocol = validProtocols[i];
+  test_protocol_messages(Protocol.transportName);
 }
diff --git a/tests/html/lib/unittests.js b/tests/html/lib/unittests.js
index b171d96..0cc9bb0 100644
--- a/tests/html/lib/unittests.js
+++ b/tests/html/lib/unittests.js
@@ -3,6 +3,7 @@
 
 var assert = require('assert');
 var u = require('../../../lib/utils');
+var protocols = require('../../../lib/protocols')
 
 test('random_string', function() {
   var i, _i, _len, _ref;
@@ -178,97 +179,97 @@ test('quote', function() {
   assert.ok(JSON.parse(u.quote(all_chars)) === all_chars, "Quote/unquote all 64K chars.");
 });
 
-test('detectProtocols', function() {
-  var chrome_probed, ie10_probed, ie6_probed, ie8_probed, opera_probed;
-  chrome_probed = {
-    'websocket': true,
-    'xdr-streaming': false,
-    'xhr-streaming': true,
-    'iframe-eventsource': true,
-    'iframe-htmlfile': true,
-    'xdr-polling': false,
-    'xhr-polling': true,
-    'iframe-xhr-polling': true,
-    'jsonp-polling': true
-  };
-  assert.deepEqual(u.detectProtocols(chrome_probed, null, {}), ['websocket', 'xhr-streaming', 'xhr-polling']);
-  assert.deepEqual(u.detectProtocols(chrome_probed, null, {
-    websocket: false
-  }), ['xhr-streaming', 'xhr-polling']);
-  opera_probed = {
-    'websocket': false,
-    'xdr-streaming': false,
-    'xhr-streaming': false,
-    'iframe-eventsource': true,
-    'iframe-htmlfile': true,
-    'xdr-polling': false,
-    'xhr-polling': false,
-    'iframe-xhr-polling': true,
-    'jsonp-polling': true
-  };
-  assert.deepEqual(u.detectProtocols(opera_probed, null, {}), ['iframe-eventsource', 'iframe-xhr-polling']);
-  ie6_probed = {
-    'websocket': false,
-    'xdr-streaming': false,
-    'xhr-streaming': false,
-    'iframe-eventsource': false,
-    'iframe-htmlfile': false,
-    'xdr-polling': false,
-    'xhr-polling': false,
-    'iframe-xhr-polling': false,
-    'jsonp-polling': true
-  };
-  assert.deepEqual(u.detectProtocols(ie6_probed, null, {}), ['jsonp-polling']);
-  ie8_probed = {
-    'websocket': false,
-    'xdr-streaming': true,
-    'xhr-streaming': false,
-    'iframe-eventsource': false,
-    'iframe-htmlfile': true,
-    'xdr-polling': true,
-    'xhr-polling': false,
-    'iframe-xhr-polling': true,
-    'jsonp-polling': true
-  };
-  assert.deepEqual(u.detectProtocols(ie8_probed, null, {}), ['xdr-streaming', 'xdr-polling']);
-  assert.deepEqual(u.detectProtocols(ie8_probed, null, {
-    cookie_needed: true
-  }), ['iframe-htmlfile', 'iframe-xhr-polling']);
-  ie10_probed = {
-    'websocket': true,
-    'xdr-streaming': true,
-    'xhr-streaming': true,
-    'iframe-eventsource': false,
-    'iframe-htmlfile': true,
-    'xdr-polling': true,
-    'xhr-polling': true,
-    'iframe-xhr-polling': true,
-    'jsonp-polling': true
-  };
-  assert.deepEqual(u.detectProtocols(ie10_probed, null, {}), ['websocket', 'xhr-streaming', 'xhr-polling']);
-  assert.deepEqual(u.detectProtocols(ie10_probed, null, {
-    cookie_needed: true
-  }), ['websocket', 'xhr-streaming', 'xhr-polling']);
-  assert.deepEqual(u.detectProtocols(chrome_probed, null, {
-    null_origin: true
-  }), ['websocket', 'iframe-eventsource', 'iframe-xhr-polling']);
-  assert.deepEqual(u.detectProtocols(chrome_probed, null, {
-    websocket: false,
-    null_origin: true
-  }), ['iframe-eventsource', 'iframe-xhr-polling']);
-  assert.deepEqual(u.detectProtocols(opera_probed, null, {
-    null_origin: true
-  }), ['iframe-eventsource', 'iframe-xhr-polling']);
-  assert.deepEqual(u.detectProtocols(ie6_probed, null, {
-    null_origin: true
-  }), ['jsonp-polling']);
-  assert.deepEqual(u.detectProtocols(ie8_probed, null, {
-    null_origin: true
-  }), ['iframe-htmlfile', 'iframe-xhr-polling']);
-  assert.deepEqual(u.detectProtocols(ie10_probed, null, {
-    null_origin: true
-  }), ['websocket', 'iframe-htmlfile', 'iframe-xhr-polling']);
-});
+// test('detectProtocols', function() {
+//   var chrome_probed, ie10_probed, ie6_probed, ie8_probed, opera_probed;
+//   chrome_probed = {
+//     'websocket': true,
+//     'xdr-streaming': false,
+//     'xhr-streaming': true,
+//     'iframe-eventsource': true,
+//     'iframe-htmlfile': true,
+//     'xdr-polling': false,
+//     'xhr-polling': true,
+//     'iframe-xhr-polling': true,
+//     'jsonp-polling': true
+//   };
+//   assert.deepEqual(u.detectProtocols(chrome_probed, null, {}), ['websocket', 'xhr-streaming', 'xhr-polling']);
+//   assert.deepEqual(u.detectProtocols(chrome_probed, null, {
+//     websocket: false
+//   }), ['xhr-streaming', 'xhr-polling']);
+//   opera_probed = {
+//     'websocket': false,
+//     'xdr-streaming': false,
+//     'xhr-streaming': false,
+//     'iframe-eventsource': true,
+//     'iframe-htmlfile': true,
+//     'xdr-polling': false,
+//     'xhr-polling': false,
+//     'iframe-xhr-polling': true,
+//     'jsonp-polling': true
+//   };
+//   assert.deepEqual(u.detectProtocols(opera_probed, null, {}), ['iframe-eventsource', 'iframe-xhr-polling']);
+//   ie6_probed = {
+//     'websocket': false,
+//     'xdr-streaming': false,
+//     'xhr-streaming': false,
+//     'iframe-eventsource': false,
+//     'iframe-htmlfile': false,
+//     'xdr-polling': false,
+//     'xhr-polling': false,
+//     'iframe-xhr-polling': false,
+//     'jsonp-polling': true
+//   };
+//   assert.deepEqual(u.detectProtocols(ie6_probed, null, {}), ['jsonp-polling']);
+//   ie8_probed = {
+//     'websocket': false,
+//     'xdr-streaming': true,
+//     'xhr-streaming': false,
+//     'iframe-eventsource': false,
+//     'iframe-htmlfile': true,
+//     'xdr-polling': true,
+//     'xhr-polling': false,
+//     'iframe-xhr-polling': true,
+//     'jsonp-polling': true
+//   };
+//   assert.deepEqual(u.detectProtocols(ie8_probed, null, {}), ['xdr-streaming', 'xdr-polling']);
+//   assert.deepEqual(u.detectProtocols(ie8_probed, null, {
+//     cookie_needed: true
+//   }), ['iframe-htmlfile', 'iframe-xhr-polling']);
+//   ie10_probed = {
+//     'websocket': true,
+//     'xdr-streaming': true,
+//     'xhr-streaming': true,
+//     'iframe-eventsource': false,
+//     'iframe-htmlfile': true,
+//     'xdr-polling': true,
+//     'xhr-polling': true,
+//     'iframe-xhr-polling': true,
+//     'jsonp-polling': true
+//   };
+//   assert.deepEqual(u.detectProtocols(ie10_probed, null, {}), ['websocket', 'xhr-streaming', 'xhr-polling']);
+//   assert.deepEqual(u.detectProtocols(ie10_probed, null, {
+//     cookie_needed: true
+//   }), ['websocket', 'xhr-streaming', 'xhr-polling']);
+//   assert.deepEqual(u.detectProtocols(chrome_probed, null, {
+//     null_origin: true
+//   }), ['websocket', 'iframe-eventsource', 'iframe-xhr-polling']);
+//   assert.deepEqual(u.detectProtocols(chrome_probed, null, {
+//     websocket: false,
+//     null_origin: true
+//   }), ['iframe-eventsource', 'iframe-xhr-polling']);
+//   assert.deepEqual(u.detectProtocols(opera_probed, null, {
+//     null_origin: true
+//   }), ['iframe-eventsource', 'iframe-xhr-polling']);
+//   assert.deepEqual(u.detectProtocols(ie6_probed, null, {
+//     null_origin: true
+//   }), ['jsonp-polling']);
+//   assert.deepEqual(u.detectProtocols(ie8_probed, null, {
+//     null_origin: true
+//   }), ['iframe-htmlfile', 'iframe-xhr-polling']);
+//   assert.deepEqual(u.detectProtocols(ie10_probed, null, {
+//     null_origin: true
+//   }), ['websocket', 'iframe-htmlfile', 'iframe-xhr-polling']);
+// });
 
 test("EventEmitter", function() {
   var bluff, handler0, handler1, handler2, handler3, handler4, log, r, single;

-- 
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