From 89bcabbb658f2d6252422eec79ddd9ca1cf02bef Mon Sep 17 00:00:00 2001 From: Zev Benjamin Date: Fri, 11 Oct 2013 15:36:49 -0400 Subject: [PATCH] Disallow XHR streaming when running the test suite There seems to be some sort of bug involving PhantomJS and XHR streaming messages. When successive pages are loaded that use XHR streaming, PhantomJS seems to think the second one never finishes loading and therefore hangs. (imported from commit db93b4cab816f1fdc3f3f543c9394b1cba8abedb) --- static/js/socket.js | 5 +++++ zerver/views/__init__.py | 1 + 2 files changed, 6 insertions(+) diff --git a/static/js/socket.js b/static/js/socket.js index 796ff73b9f..39b6222448 100644 --- a/static/js/socket.js +++ b/static/js/socket.js @@ -14,6 +14,11 @@ function Socket(url) { this._supported_protocols = ['websocket', 'xdr-streaming', 'xhr-streaming', 'xdr-polling', 'xhr-polling', 'jsonp-polling']; + if (page_params.test_suite) { + this._supported_protocols = _.reject(this._supported_protocols, + function (x) { return x === 'xhr-streaming'; }); + } + this._sockjs = new SockJS(url, null, {protocols_whitelist: this._supported_protocols}); this._setup_sockjs_callbacks(this._sockjs); } diff --git a/zerver/views/__init__.py b/zerver/views/__init__.py index 78faa4f12c..67134e7b96 100644 --- a/zerver/views/__init__.py +++ b/zerver/views/__init__.py @@ -704,6 +704,7 @@ def home(request): # These end up in a global JavaScript Object named 'page_params'. page_params = simplejson.encoder.JSONEncoderForHTML().encode(dict( debug_mode = settings.DEBUG, + test_suite = settings.TEST_SUITE, poll_timeout = settings.POLL_TIMEOUT, have_initial_messages = user_has_messages, stream_list = register_ret['subscriptions'],