[tor-commits] [flashproxy/master] Add tests for have_websocket_binary_frames().

dcf at torproject.org dcf at torproject.org
Sun Nov 10 08:12:36 UTC 2013


commit 4ddd0cc48873438e53ecf2fdd444892550e6427d
Author: Arlo Breault <arlolra at gmail.com>
Date:   Sat Nov 2 10:35:25 2013 -0700

    Add tests for have_websocket_binary_frames().
---
 proxy/flashproxy-test.js |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/proxy/flashproxy-test.js b/proxy/flashproxy-test.js
index e2b5a43..e775f53 100755
--- a/proxy/flashproxy-test.js
+++ b/proxy/flashproxy-test.js
@@ -322,6 +322,26 @@ function test_lang_keys() {
     }
 }
 
+function test_have_websocket_binary_frames() {
+    var TESTS = [
+        { ua: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36", expected: true },
+        { ua: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/536.30.1 (KHTML, like Gecko) Version/6.0.5 Safari/536.30.1", expected: true },
+        { expected: false },  // no userAgent
+    ];
+    var _navigator = window.navigator;
+    for (var i = 0; i < TESTS.length; i++) {
+        var test = TESTS[i];
+        window.navigator = { userAgent: test.ua };
+        var actual = have_websocket_binary_frames();
+
+        if (objects_equal(actual, test.expected))
+            pass(test.ua);
+        else
+            fail(test.ua, test.expected, actual);
+    }
+    window.navigator = _navigator;
+}
+
 test_build_url();
 test_parse_cookie_string();
 test_parse_query_string();
@@ -329,6 +349,7 @@ test_get_param_boolean();
 test_parse_addr_spec();
 test_get_param_addr();
 test_lang_keys();
+test_have_websocket_binary_frames();
 
 if (num_failed == 0)
     quit(0);





More information about the tor-commits mailing list