diff options
author | Pierre Ossman <pierre@ossman.eu> | 2017-01-28 14:50:48 +0100 |
---|---|---|
committer | Pierre Ossman <pierre@ossman.eu> | 2017-02-01 08:09:53 +0100 |
commit | 4099949984eb80ef33c2d0dd216991124975a5d2 (patch) | |
tree | 53d807d8818238373fdfaf50266aebfd3469122e /tests | |
parent | 56a4ccbf74be59484fad9878ea6c155c3edc0ff9 (diff) | |
download | websockify-4099949984eb80ef33c2d0dd216991124975a5d2.tar.gz |
Remove Base64 support
This is an older protocol used before browsers got native
support for Websockets.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/b64_vs_utf8.py | 29 | ||||
-rw-r--r-- | tests/base64.html | 91 | ||||
-rw-r--r-- | tests/base64.js | 12 | ||||
-rw-r--r-- | tests/echo.html | 1 | ||||
-rw-r--r-- | tests/latency.html | 1 | ||||
-rw-r--r-- | tests/load.html | 1 | ||||
-rw-r--r-- | tests/plain_echo.html | 2 | ||||
-rw-r--r-- | tests/simple.html | 1 | ||||
-rwxr-xr-x | tests/utf8-list.py | 19 |
9 files changed, 1 insertions, 156 deletions
diff --git a/tests/b64_vs_utf8.py b/tests/b64_vs_utf8.py deleted file mode 100755 index 9af7b62..0000000 --- a/tests/b64_vs_utf8.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env python - -from base64 import b64encode, b64decode -from codecs import (utf_8_encode, utf_8_decode, - latin_1_encode, latin_1_decode) -import random, time - -buf_len = 10000 -iterations = 10000 - -print "Generating random input buffer" -r = random.Random() -buf = "".join([chr(r.randint(0, 255)) for i in range(buf_len)]) - -tests = {'UTF8 encode': lambda: utf_8_encode(unicode(buf, 'latin-1'))[0], - 'B64 encode': lambda: b64encode(buf)} -utf8_buf = tests['UTF8 encode']() -b64_buf = tests['B64 encode']() -tests.update({'UTF8 decode': lambda: latin_1_encode(utf_8_decode(utf8_buf)[0])[0], - 'B64 decode': lambda: b64decode(b64_buf)}) - -print "Running tests" -for test in 'UTF8 encode', 'B64 encode', 'UTF8 decode', 'B64 decode': - start = time.time() - for i in range(iterations): - res_buf = tests[test]() - print "%s took %s seconds (result size %s)" % ( - test, (time.time() - start), len(res_buf)) - diff --git a/tests/base64.html b/tests/base64.html deleted file mode 100644 index 24ad80b..0000000 --- a/tests/base64.html +++ /dev/null @@ -1,91 +0,0 @@ -<!DOCTYPE html> -<html xmlns="http://www.w3.org/1999/xhtml"> - <head> - <title>Native Base64 Tests</title> - <script src="include/util.js"></script> - <script src="include/webutil.js"></script> - <script src="include/base64.js"></script> - </head> - <body> - <h1>Native Base64 Tests</h1> - - <br> - Messages:<br> - <textarea id="debug" style="font-size: 9px;" cols=80 rows=25></textarea> - - <br> - </body> - -<script> - function debug(str) { - console.log(str); - cell = $D('debug'); - cell.innerHTML += str + "\n"; - cell.scrollTop = cell.scrollHeight; - } - - function assertRun(code, result) { - try { - var actual = eval(code); - } catch (exc) { - debug("FAIL: '" + code + "' threw an exception"); - fail += 1; - return false; - } - if (actual !== result) { - debug("FAIL: '" + code + "' returned '" + actual + "', expected '" + result + "'"); - fail += 1; - return false; - } - debug("PASS: '" + code + "' returned expected '" + result +"'"); - pass += 1; - return true; - } - - function Base64_decode(data) { - var arr = Base64.decode (data); - return arr.map(function (num) { - return String.fromCharCode(num); } ).join(''); - - } - - window.onload = function() { - var str; - debug('onload'); - fail = 0; - pass = 0; - assertRun('window.btoa("hello world")', 'aGVsbG8gd29ybGQ='); - assertRun('window.btoa("a")', 'YQ=='); - assertRun('window.btoa("ab")', 'YWI='); - assertRun('window.btoa("abc")', 'YWJj'); - assertRun('window.btoa("abcd")', 'YWJjZA=='); - assertRun('window.btoa("abcde")', 'YWJjZGU='); - assertRun('window.btoa("abcdef")', 'YWJjZGVm'); - assertRun('window.btoa("abcdefg")', 'YWJjZGVmZw=='); - assertRun('window.btoa("abcdefgh")', 'YWJjZGVmZ2g='); - - assertRun('window.atob("aGVsbG8gd29ybGQ=")', 'hello world'); - assertRun('Base64_decode("aGVsbG8gd29ybGQ=")', 'hello world'); - assertRun('window.atob("YQ==")', 'a'); - assertRun('Base64_decode("YQ==")', 'a'); - assertRun('window.atob("YWI=")', 'ab'); - assertRun('Base64_decode("YWI=")', 'ab'); - assertRun('window.atob("YWJj")', 'abc'); - assertRun('Base64_decode("YWJj")', 'abc'); - assertRun('window.atob("YWJjZA==")', 'abcd'); - assertRun('Base64_decode("YWJjZA==")', 'abcd'); - assertRun('window.atob("YWJjZGU=")', 'abcde'); - assertRun('Base64_decode("YWJjZGU=")', 'abcde'); - assertRun('window.atob("YWJjZGVm")', 'abcdef'); - assertRun('Base64_decode("YWJjZGVm")', 'abcdef'); - - assertRun('typeof window.btoa', 'function'); - assertRun('window.btoa("")', ''); - assertRun('window.btoa(null)', ''); - assertRun('window.atob(window.btoa(window))', window.toString()); // "[object DOMWindow]" - assertRun('window.btoa("\\u0080\\u0081")', 'gIE='); - - debug("Tests failed: " + fail); - debug("Tests passed: " + pass); - } -</script> diff --git a/tests/base64.js b/tests/base64.js deleted file mode 100644 index 6ade00a..0000000 --- a/tests/base64.js +++ /dev/null @@ -1,12 +0,0 @@ -// The following results in 'hello [MANGLED]' -// -// Filed as https://github.com/ry/node/issues/issue/402 - -var sys = require("sys"), - buf = new Buffer(1024), len, - str1 = "aGVsbG8g", // 'hello ' - str2 = "d29ybGQ=", // 'world' - -len = buf.write(str1, 0, 'base64'); -len += buf.write(str2, len, 'base64'); -sys.log("decoded result: " + buf.toString('binary', 0, len)); diff --git a/tests/echo.html b/tests/echo.html index cc8b642..8cc7ecb 100644 --- a/tests/echo.html +++ b/tests/echo.html @@ -4,7 +4,6 @@ <title>WebSockets Echo Test</title> <script src="include/util.js"></script> <script src="include/webutil.js"></script> - <script src="include/base64.js"></script> <script src="include/websock.js"></script> <!-- Uncomment to activate firebug lite --> <!-- diff --git a/tests/latency.html b/tests/latency.html index 74538a4..6297926 100644 --- a/tests/latency.html +++ b/tests/latency.html @@ -2,7 +2,6 @@ <head> <title>WebSockets Latency Test</title> - <script src="include/base64.js"></script> <script src="include/util.js"></script> <script src="include/webutil.js"></script> <script src="include/websock.js"></script> diff --git a/tests/load.html b/tests/load.html index af165dc..ae31be3 100644 --- a/tests/load.html +++ b/tests/load.html @@ -4,7 +4,6 @@ <title>WebSockets Load Test</title> <script src="include/util.js"></script> <script src="include/webutil.js"></script> - <script src="include/base64.js"></script> <script src="include/websock.js"></script> <!-- Uncomment to activate firebug lite --> <!-- diff --git a/tests/plain_echo.html b/tests/plain_echo.html index 12926fb..83d7aa2 100644 --- a/tests/plain_echo.html +++ b/tests/plain_echo.html @@ -90,7 +90,7 @@ } uri = scheme + host + ":" + port; message("connecting to " + uri); - ws = new WebSocket(uri, "base64"); + ws = new WebSocket(uri); ws.onmessage = function(e) { //console.log(">> WebSockets.onmessage"); diff --git a/tests/simple.html b/tests/simple.html index 18fb200..1a20cc4 100644 --- a/tests/simple.html +++ b/tests/simple.html @@ -3,7 +3,6 @@ <head> <title>Websock Simple Client</title> <script src="include/util.js"></script> - <script src="include/base64.js"></script> <script src="include/websock.js"></script> </head> diff --git a/tests/utf8-list.py b/tests/utf8-list.py deleted file mode 100755 index 77bd430..0000000 --- a/tests/utf8-list.py +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/python - -''' -Display UTF-8 encoding for 0-255.''' - -import sys, os, socket, ssl, time, traceback -from select import select -sys.path.insert(0,os.path.join(os.path.dirname(__file__), "..")) -from websockify.websocket import WebSocketServer - -if __name__ == '__main__': - print "val: hybi_base64 | hybi_binary" - for c in range(0, 256): - hybi_base64 = WebSocketServer.encode_hybi(chr(c), opcode=1, - base64=True) - hybi_binary = WebSocketServer.encode_hybi(chr(c), opcode=2, - base64=False) - print "%d: %s | %s" % (c, repr(hybi_base64), repr(hybi_binary)) - |