2011-05-24 Fumitoshi Ukai <ukai@chromium.org>
authorukai@chromium.org <ukai@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 May 2011 08:10:46 +0000 (08:10 +0000)
committerukai@chromium.org <ukai@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 May 2011 08:10:46 +0000 (08:10 +0000)
        Reviewed by Adam Barth.

        close before open WebSocket doesn't fire close event.
        https://bugs.webkit.org/show_bug.cgi?id=57301

        * http/tests/websocket/tests/close-before-open-expected.txt: Added.
        * http/tests/websocket/tests/close-before-open.html: Added.
2011-05-24  Fumitoshi Ukai  <ukai@chromium.org>

        Reviewed by Adam Barth.

        close before open WebSocket doesn't fire close event.
        https://bugs.webkit.org/show_bug.cgi?id=57301

        In platformClose(), m_readStream may be 0 until proxy is resolved.
        It should callback didClose() in such case.

        Test: http/tests/websocket/tests/close-before-open.html

        * platform/network/cf/SocketStreamHandleCFNet.cpp:
        (WebCore::SocketStreamHandle::platformClose):

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

LayoutTests/ChangeLog
LayoutTests/http/tests/websocket/tests/close-before-open-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/websocket/tests/close-before-open.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/network/cf/SocketStreamHandleCFNet.cpp

index 42c6f02..2c8128a 100644 (file)
@@ -1,3 +1,13 @@
+2011-05-24  Fumitoshi Ukai  <ukai@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        close before open WebSocket doesn't fire close event.
+        https://bugs.webkit.org/show_bug.cgi?id=57301
+
+        * http/tests/websocket/tests/close-before-open-expected.txt: Added.
+        * http/tests/websocket/tests/close-before-open.html: Added.
+
 2011-05-24  Zoltan Horvath  <zoltan@webkit.org>
 
         [Qt][WK2] Paint the bot green for ultimate satisfaction of Ossy. 
diff --git a/LayoutTests/http/tests/websocket/tests/close-before-open-expected.txt b/LayoutTests/http/tests/websocket/tests/close-before-open-expected.txt
new file mode 100644 (file)
index 0000000..7a5d92f
--- /dev/null
@@ -0,0 +1,9 @@
+Test if Web Socket fires close event when WebSocket is opened and closed fore open event is received.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+closed
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/http/tests/websocket/tests/close-before-open.html b/LayoutTests/http/tests/websocket/tests/close-before-open.html
new file mode 100644 (file)
index 0000000..e57b6f0
--- /dev/null
@@ -0,0 +1,29 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../../js-test-resources/js-test-style.css">
+<script src="../../../js-test-resources/js-test-pre.js"></script>
+<script src="../../../js-test-resources/js-test-post-function.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script type="text/javascript">
+description("Test if Web Socket fires close event when WebSocket is opened and closed fore open event is received.");
+
+if (window.layoutTestController)
+    layoutTestController.waitUntilDone();
+
+var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hanging-handshake");
+ws.onclose = function() {
+    debug("closed");
+    isSuccessfullyParsed();
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+};
+var successfullyParsed = true;
+ws.close();
+</script>
+
+</body>
+</html>
index a9b711c..2149eae 100644 (file)
@@ -1,3 +1,18 @@
+2011-05-24  Fumitoshi Ukai  <ukai@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        close before open WebSocket doesn't fire close event.
+        https://bugs.webkit.org/show_bug.cgi?id=57301
+
+        In platformClose(), m_readStream may be 0 until proxy is resolved.
+        It should callback didClose() in such case.
+        
+        Test: http/tests/websocket/tests/close-before-open.html
+
+        * platform/network/cf/SocketStreamHandleCFNet.cpp:
+        (WebCore::SocketStreamHandle::platformClose):
+
 2011-05-23  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r87118.
index 209f448..5bdc1a6 100644 (file)
@@ -569,8 +569,11 @@ void SocketStreamHandle::platformClose()
         removePACRunLoopSource();
 
     ASSERT(!m_readStream == !m_writeStream);
-    if (!m_readStream)
+    if (!m_readStream) {
+        if (m_connectingSubstate == New || m_connectingSubstate == ExecutingPACFile)
+            m_client->didClose(this);
         return;
+    }
 
 #if PLATFORM(WIN)
     CFReadStreamUnscheduleFromRunLoop(m_readStream.get(), loaderRunLoop(), kCFRunLoopDefaultMode);