[tor-commits] [flashproxy/js] Move WebSocket || MozWebSocket to global scope.

dcf at torproject.org dcf at torproject.org
Thu Apr 5 07:11:47 UTC 2012


commit 8820e124b67b9861e33bda98cf97464247bbba22
Author: David Fifield <david at bamsoftware.com>
Date:   Wed Apr 4 23:27:46 2012 -0700

    Move WebSocket || MozWebSocket to global scope.
---
 flashproxy.js |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/flashproxy.js b/flashproxy.js
index 10ed935..b7f339b 100644
--- a/flashproxy.js
+++ b/flashproxy.js
@@ -66,6 +66,10 @@ var DEFAULT_RATE_LIMIT = undefined;
 var MIN_RATE_LIMIT = 10 * 1024;
 var RATE_LIMIT_HISTORY = 5.0;
 
+/* Gecko browsers use the name MozWebSocket. Also we can test whether WebSocket
+   is defined to see if WebSockets are supported at all. */
+var WebSocket = window.WebSocket || window.MozWebSocket;
+
 var query = parse_query_string(window.location.search.substr(1));
 var debug_div;
 
@@ -266,14 +270,11 @@ function have_websocket_binary_frames()
 function make_websocket(addr)
 {
     var url;
-    var WebSocket;
     var ws;
 
     url = "ws://" + encodeURIComponent(addr.host)
             + ":" + encodeURIComponent(addr.port) + "/";
 
-    WebSocket = window.WebSocket || window.MozWebSocket;
-
     if (have_websocket_binary_frames())
         ws = new WebSocket(url);
     else





More information about the tor-commits mailing list