# HG changeset patch # User Olli Pettay # Date 1276810213 -10800 # Node ID 7dcad6b2356dcd66665227a801f8601885f98e7e # Parent 7bca5d3905c8b3175a84ab28fe25a065fc5f5481 Some basic WS tests diff --git a/content/base/test/Makefile.in b/content/base/test/Makefile.in --- a/content/base/test/Makefile.in +++ b/content/base/test/Makefile.in @@ -396,6 +396,8 @@ test_bug571390.xul \ test_websocket_hello.html \ file_websocket_hello_wsh.py \ + test_ws_basic_tests.html \ + file_ws_basic_tests_wsh.py \ $(NULL) # This test fails on the Mac for some reason diff --git a/content/base/test/file_ws_basic_tests_wsh.py b/content/base/test/file_ws_basic_tests_wsh.py new file mode 100644 --- /dev/null +++ b/content/base/test/file_ws_basic_tests_wsh.py @@ -0,0 +1,26 @@ +from mod_pywebsocket import msgutil + +def web_socket_do_extra_handshake(request): + if (request.ws_protocol == 'error'): + raise ValueError('Error') + pass + +def web_socket_transfer_data(request): + while True: + line = msgutil.receive_message(request) + if line == 'protocol': + msgutil.send_message(request, request.ws_protocol) + continue + + if line == 'resource': + msgutil.send_message(request, request.ws_resource) + continue + + if line == 'origin': + msgutil.send_message(request, request.ws_origin) + continue + + msgutil.send_message(request, line) + + if line == 'end': + return diff --git a/content/base/test/test_websocket_hello.html b/content/base/test/test_websocket_hello.html --- a/content/base/test/test_websocket_hello.html +++ b/content/base/test/test_websocket_hello.html @@ -26,11 +26,11 @@ ws.onclose = function(e) { } ws.onerror = function(e) { - is(false, "onerror called!"); + ok(false, "onerror called!"); SimpleTest.finish(); } ws.onmessage = function(e) { - is(e.data, "Hello world!"); + is(e.data, "Hello world!", "Wrong data"); ws.close(); SimpleTest.finish(); } diff --git a/content/base/test/test_ws_basic_tests.html b/content/base/test/test_ws_basic_tests.html new file mode 100644 --- /dev/null +++ b/content/base/test/test_ws_basic_tests.html @@ -0,0 +1,89 @@ + + + + + Basic websocket test + + + + + +Mozilla Bug +

+ +
+
+
+
+
+
+ + +
+ + + +