2009-12-08 Fumitoshi Ukai <ukai@chromium.org>
authorukai@chromium.org <ukai@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Dec 2009 03:20:46 +0000 (03:20 +0000)
committerukai@chromium.org <ukai@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Dec 2009 03:20:46 +0000 (03:20 +0000)
        Reviewed by Darin Adler.

        Add tests that WebSocket-Protocol: is ignored if protocol was not specified.
        https://bugs.webkit.org/show_bug.cgi?id=32267

        * websocket/tests/script-tests/websocket-protocol-ignored.js: Added.
        * websocket/tests/websocket-protocol-ignored-expected.txt: Added.
        * websocket/tests/websocket-protocol-ignored.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@51885 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/websocket/tests/script-tests/websocket-protocol-ignored.js [new file with mode: 0644]
LayoutTests/websocket/tests/websocket-protocol-ignored-expected.txt [new file with mode: 0644]
LayoutTests/websocket/tests/websocket-protocol-ignored.html [new file with mode: 0644]

index c08fea9..42592a3 100644 (file)
@@ -1,3 +1,14 @@
+2009-12-08  Fumitoshi Ukai  <ukai@chromium.org>
+
+        Reviewed by Darin Adler.
+
+        Add tests that WebSocket-Protocol: is ignored if protocol was not specified.
+        https://bugs.webkit.org/show_bug.cgi?id=32267
+
+        * websocket/tests/script-tests/websocket-protocol-ignored.js: Added.
+        * websocket/tests/websocket-protocol-ignored-expected.txt: Added.
+        * websocket/tests/websocket-protocol-ignored.html: Added.
+
 2009-12-08  Peterson Trethewey  <petersont@google.com>
 
         Reviewed by Oliver Hunt.
diff --git a/LayoutTests/websocket/tests/script-tests/websocket-protocol-ignored.js b/LayoutTests/websocket/tests/script-tests/websocket-protocol-ignored.js
new file mode 100644 (file)
index 0000000..12d7365
--- /dev/null
@@ -0,0 +1,44 @@
+description("Test WebSocket handshake success without protocol and ignore WebSocket-Protocol from server.");
+
+if (window.layoutTestController)
+    layoutTestController.waitUntilDone();
+
+var protocol;
+
+function endTest()
+{
+    shouldBe("protocol", '"sub-protocol"');
+    clearTimeout(timeoutID);
+    isSuccessfullyParsed();
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+}
+
+var url = "ws://localhost:8880/websocket/tests/protocol-test?protocol=sub-protocol";
+var ws = new WebSocket(url);
+
+ws.onopen = function()
+{
+    debug("Connected");
+};
+
+ws.onmessage = function (messageEvent)
+{
+    protocol = messageEvent.data;
+    ws.close();
+};
+
+ws.onclose = function()
+{
+    endTest();
+};
+
+function timeOutCallback()
+{
+    debug("Timed out in state: " + ws.readyState);
+    endTest();
+}
+
+var timeoutID = setTimeout(timeOutCallback, 3000);
+
+var successfullyParsed = true;
diff --git a/LayoutTests/websocket/tests/websocket-protocol-ignored-expected.txt b/LayoutTests/websocket/tests/websocket-protocol-ignored-expected.txt
new file mode 100644 (file)
index 0000000..4de6d71
--- /dev/null
@@ -0,0 +1,10 @@
+Test WebSocket handshake success without protocol and ignore WebSocket-Protocol from server.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Connected
+PASS protocol is "sub-protocol"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/websocket/tests/websocket-protocol-ignored.html b/LayoutTests/websocket/tests/websocket-protocol-ignored.html
new file mode 100644 (file)
index 0000000..85cdcd0
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script src="../../fast/js/resources/js-test-post-function.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script src="script-tests/websocket-protocol-ignored.js"></script>
+</body>
+</html>