Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1405)

Unified Diff: tests/standalone/io/web_socket_test.dart

Issue 10388159: Correctly handle the case of a 126 bytes long message, in WebSocket frame encoding. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add 65535 and 65536 Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/websocket_impl.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/web_socket_test.dart
diff --git a/tests/standalone/io/web_socket_test.dart b/tests/standalone/io/web_socket_test.dart
index 907cf977fc0a7351059b0ab9c5422b37520aed3e..336e50e17678a87429a0a1dddb67f3bff229c94b 100644
--- a/tests/standalone/io/web_socket_test.dart
+++ b/tests/standalone/io/web_socket_test.dart
@@ -102,6 +102,42 @@ void testRequestResponseServerCloses(
}
+void testMessageLength(int messageLength) {
+ HttpServer server = new HttpServer();
+ HttpClient client = new HttpClient();
+
+ server.listen("127.0.0.1", 0, 1);
+
+ // Create a web socket handler and set is as the HTTP server default
+ // handler.
+ String originalMessage = "";
+ for (int i = 0; i < messageLength; i++) originalMessage += "${i % 10}";
+ WebSocketHandler wsHandler = new WebSocketHandler();
+ wsHandler.onOpen = (WebSocketConnection conn) {
+ conn.onMessage = (Object message) {
+ Expect.equals(originalMessage, message);
+ conn.send(message);
+ };
+ conn.onClosed = (status, reason) {
+ };
+ };
+ server.defaultRequestHandler = wsHandler.onRequest;
+
+ HttpClientConnection conn = client.get("127.0.0.1", server.port, "/");
+ WebSocketClientConnection wsconn = new WebSocketClientConnection(conn);
+ wsconn.onMessage = (message) {
+ Expect.equals(originalMessage, message);
+ wsconn.close();
+ };
+ wsconn.onClosed = (status, reason) {
+ server.close();
+ };
+ wsconn.onOpen = () {
+ wsconn.send(originalMessage);
+ };
+}
+
+
void testNoUpgrade() {
HttpServer server = new HttpServer();
HttpClient client = new HttpClient();
@@ -284,6 +320,11 @@ main() {
testRequestResponseServerCloses(2, null, null);
testRequestResponseServerCloses(2, 3001, null);
testRequestResponseServerCloses(2, 3002, "Got tired");
+ testMessageLength(125);
+ testMessageLength(126);
+ testMessageLength(127);
+ testMessageLength(65535);
+ testMessageLength(65536);
testNoUpgrade();
testUsePOST();
testHashCode(2);
« no previous file with comments | « runtime/bin/websocket_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698