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

        WebSocket allow space (U+0020) in sub protocol name.
        https://bugs.webkit.org/show_bug.cgi?id=32266

        Skipped sub-protocol-with-space.html for now until new pywebsocket is
        landed.

        * websocket/tests/bad-sub-protocol-expected.txt:
        * websocket/tests/script-tests/bad-sub-protocol.js:
        * websocket/tests/script-tests/sub-protocol-with-space.js: Added.
        * websocket/tests/sub-protocol-with-space-expected.txt: Added.
        * websocket/tests/sub-protocol-with-space.html: Added.
2009-12-08  Fumitoshi Ukai  <ukai@chromium.org>

        Reviewed by Darin Adler.

        WebSocket allow space (U+0020) in sub protocol name.
        https://bugs.webkit.org/show_bug.cgi?id=32266

        Test: websocket/tests/sub-protocol-with-space.html

        * websockets/WebSocket.cpp:
        (WebCore::isValidProtocolString):

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

LayoutTests/ChangeLog
LayoutTests/platform/mac/Skipped
LayoutTests/platform/win/Skipped
LayoutTests/websocket/tests/bad-sub-protocol-expected.txt
LayoutTests/websocket/tests/script-tests/bad-sub-protocol.js
LayoutTests/websocket/tests/script-tests/sub-protocol-with-space.js [new file with mode: 0644]
LayoutTests/websocket/tests/sub-protocol-with-space-expected.txt [new file with mode: 0644]
LayoutTests/websocket/tests/sub-protocol-with-space.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/websockets/WebSocket.cpp

index 42592a3..a362dbb 100644 (file)
@@ -2,6 +2,22 @@
 
         Reviewed by Darin Adler.
 
+        WebSocket allow space (U+0020) in sub protocol name.
+        https://bugs.webkit.org/show_bug.cgi?id=32266
+
+        Skipped sub-protocol-with-space.html for now until new pywebsocket is
+        landed.
+
+        * websocket/tests/bad-sub-protocol-expected.txt:
+        * websocket/tests/script-tests/bad-sub-protocol.js:
+        * websocket/tests/script-tests/sub-protocol-with-space.js: Added.
+        * websocket/tests/sub-protocol-with-space-expected.txt: Added.
+        * websocket/tests/sub-protocol-with-space.html: Added.
+
+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
 
index afd9179..e6517ad 100644 (file)
@@ -111,3 +111,6 @@ plugins/qt-qwidget-plugin.html
 
 # This test requires ogg codecs
 media/media-can-play-ogg.html
+
+# This test requires new pywebsocket
+websocket/tests/sub-protocol-with-space.html
index 2a56bb8..99838b3 100644 (file)
@@ -724,3 +724,6 @@ fast/js/excessive-comma-usage.html
 fast/js/math-transforms.html
 fast/js/math.html
 fast/js/lastModified.html
+
+# This test requires new pywebsocket
+websocket/tests/sub-protocol-with-space.html
index 8574acf..0c2fcde 100644 (file)
@@ -3,7 +3,6 @@ Test WebSocket bad sub-protocol names.
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 PASS new WebSocket("ws://127.0.0.1:8880/simple", "") threw exception Error: SYNTAX_ERR: DOM Exception 12.
-PASS new WebSocket("ws://127.0.0.1:8880/simple", "sub protocol") threw exception Error: SYNTAX_ERR: DOM Exception 12.
 PASS new WebSocket("ws://127.0.0.1:8880/simple", "") threw exception Error: SYNTAX_ERR: DOM Exception 12.
 PASS new WebSocket("ws://127.0.0.1:8880/simple", "     ") threw exception Error: SYNTAX_ERR: DOM Exception 12.
 PASS new WebSocket("ws://127.0.0.1:8880/simple", "
@@ -11,6 +10,7 @@ PASS new WebSocket("ws://127.0.0.1:8880/simple", "
 PASS new WebSocket("ws://127.0.0.1:8880/simple", "
 ") threw exception SyntaxError: Parse error.
 PASS new WebSocket("ws://127.0.0.1:8880/simple", "\e") threw exception Error: SYNTAX_ERR: DOM Exception 12.
+PASS new WebSocket("ws://127.0.0.1:8880/simple", "\7f") threw exception Error: SYNTAX_ERR: DOM Exception 12.
 PASS new WebSocket("ws://127.0.0.1:8880/simple", "\80") threw exception Error: SYNTAX_ERR: DOM Exception 12.
 PASS new WebSocket("ws://127.0.0.1:8880/simple", "あ") threw exception Error: SYNTAX_ERR: DOM Exception 12.
 PASS new WebSocket("ws://127.0.0.1:8880/simple", "￿") threw exception Error: SYNTAX_ERR: DOM Exception 12.
index 1d8d486..66f8b38 100644 (file)
@@ -3,15 +3,15 @@ description("Test WebSocket bad sub-protocol names.");
 // Fails if protocol is an empty string.
 shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "")');
 
-// Fails if protocol contains an character less than U+0021.
-shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "sub protocol")');
+// Fails if protocol contains an character less than U+0020.
 shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\u0000")');
 shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\u0009")');
 shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\u000A")');
 shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\u000D")');
 shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\u001B")');
 
-// Fails if protocol containns an character greater than U+007F.
+// Fails if protocol contains an character greater than U+007E.
+shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\u007F")');
 shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\u0080")');
 shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\u3042")');
 shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\uFFFF")');
diff --git a/LayoutTests/websocket/tests/script-tests/sub-protocol-with-space.js b/LayoutTests/websocket/tests/script-tests/sub-protocol-with-space.js
new file mode 100644 (file)
index 0000000..9fb411a
--- /dev/null
@@ -0,0 +1,44 @@
+description("Test WebSocket handshake success with sub protocol contains space.");
+
+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%20protocol";
+var ws = new WebSocket(url, "sub protocol");
+
+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/sub-protocol-with-space-expected.txt b/LayoutTests/websocket/tests/sub-protocol-with-space-expected.txt
new file mode 100644 (file)
index 0000000..021a749
--- /dev/null
@@ -0,0 +1,10 @@
+Test WebSocket handshake success with sub protocol contains space.
+
+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/sub-protocol-with-space.html b/LayoutTests/websocket/tests/sub-protocol-with-space.html
new file mode 100644 (file)
index 0000000..7973549
--- /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/sub-protocol-with-space.js"></script>
+</body>
+</html>
index dcd46fc..2937020 100644 (file)
@@ -1,3 +1,15 @@
+2009-12-08  Fumitoshi Ukai  <ukai@chromium.org>
+
+        Reviewed by Darin Adler.
+
+        WebSocket allow space (U+0020) in sub protocol name.
+        https://bugs.webkit.org/show_bug.cgi?id=32266
+
+        Test: websocket/tests/sub-protocol-with-space.html
+
+        * websockets/WebSocket.cpp:
+        (WebCore::isValidProtocolString):
+
 2009-12-08  Peterson Trethewey  <petersont@google.com>
 
         Reviewed by Oliver Hunt.
index 7d16493..2b54091 100644 (file)
@@ -79,7 +79,7 @@ static bool isValidProtocolString(const WebCore::String& protocol)
         return false;
     const UChar* characters = protocol.characters();
     for (size_t i = 0; i < protocol.length(); i++) {
-        if (characters[i] < 0x21 || characters[i] > 0x7E)
+        if (characters[i] < 0x20 || characters[i] > 0x7E)
             return false;
     }
     return true;