2011-05-27 Sheriff Bot <webkit.review.bot@gmail.com>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 May 2011 16:34:10 +0000 (16:34 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 May 2011 16:34:10 +0000 (16:34 +0000)
        Unreviewed, rolling out r87464.
        http://trac.webkit.org/changeset/87464
        https://bugs.webkit.org/show_bug.cgi?id=61643

        client-close/server-close tests are flaky on Chromium Mac and
        Windows (Requested by aklein on #webkit).

        * http/tests/websocket/tests/client-close-expected.txt: Removed.
        * http/tests/websocket/tests/client-close.html: Removed.
        * http/tests/websocket/tests/client-close_wsh.py: Removed.
        * http/tests/websocket/tests/close-before-open-expected.txt:
        * http/tests/websocket/tests/close-event-expected.txt:
        * http/tests/websocket/tests/close-event.html:
        * http/tests/websocket/tests/close-unref-websocket-expected.txt:
        * http/tests/websocket/tests/frame-length-longer-than-buffer_wsh.py:
        * http/tests/websocket/tests/server-close-expected.txt: Removed.
        * http/tests/websocket/tests/server-close.html: Removed.
        * http/tests/websocket/tests/server-close_wsh.py: Removed.
        * http/tests/websocket/tests/websocket-event-target-expected.txt:
2011-05-27  Sheriff Bot  <webkit.review.bot@gmail.com>

        Unreviewed, rolling out r87464.
        http://trac.webkit.org/changeset/87464
        https://bugs.webkit.org/show_bug.cgi?id=61643

        client-close/server-close tests are flaky on Chromium Mac and
        Windows (Requested by aklein on #webkit).

        * platform/network/SocketStreamHandleBase.cpp:
        (WebCore::SocketStreamHandleBase::send):
        (WebCore::SocketStreamHandleBase::close):
        (WebCore::SocketStreamHandleBase::sendPendingData):
        * platform/network/SocketStreamHandleBase.h:
        * websockets/ThreadableWebSocketChannelClientWrapper.cpp:
        (WebCore::ThreadableWebSocketChannelClientWrapper::didClose):
        (WebCore::ThreadableWebSocketChannelClientWrapper::didCloseCallback):
        * websockets/ThreadableWebSocketChannelClientWrapper.h:
        * websockets/WebSocket.cpp:
        (WebCore::WebSocket::send):
        (WebCore::WebSocket::close):
        (WebCore::WebSocket::bufferedAmount):
        (WebCore::WebSocket::didConnect):
        (WebCore::WebSocket::didReceiveMessage):
        (WebCore::WebSocket::didReceiveMessageError):
        (WebCore::WebSocket::didClose):
        * websockets/WebSocket.h:
        * websockets/WebSocketChannel.cpp:
        (WebCore::WebSocketChannel::WebSocketChannel):
        (WebCore::WebSocketChannel::close):
        (WebCore::WebSocketChannel::disconnect):
        (WebCore::WebSocketChannel::didClose):
        (WebCore::WebSocketChannel::didReceiveData):
        (WebCore::WebSocketChannel::didFail):
        (WebCore::WebSocketChannel::processBuffer):
        * websockets/WebSocketChannel.h:
        * websockets/WebSocketChannelClient.h:
        (WebCore::WebSocketChannelClient::didClose):
        * websockets/WorkerThreadableWebSocketChannel.cpp:
        (WebCore::WorkerThreadableWebSocketChannel::Peer::close):
        (WebCore::workerContextDidClose):
        (WebCore::WorkerThreadableWebSocketChannel::Peer::didClose):
        * websockets/WorkerThreadableWebSocketChannel.h:
2011-05-27  Sheriff Bot  <webkit.review.bot@gmail.com>

        Unreviewed, rolling out r87464.
        http://trac.webkit.org/changeset/87464
        https://bugs.webkit.org/show_bug.cgi?id=61643

        client-close/server-close tests are flaky on Chromium Mac and
        Windows (Requested by aklein on #webkit).

        * Scripts/webkitpy/thirdparty/__init__.py:

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

27 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/websocket/tests/client-close-expected.txt [deleted file]
LayoutTests/http/tests/websocket/tests/client-close.html [deleted file]
LayoutTests/http/tests/websocket/tests/client-close_wsh.py [deleted file]
LayoutTests/http/tests/websocket/tests/close-before-open-expected.txt
LayoutTests/http/tests/websocket/tests/close-event-expected.txt
LayoutTests/http/tests/websocket/tests/close-event.html
LayoutTests/http/tests/websocket/tests/close-unref-websocket-expected.txt
LayoutTests/http/tests/websocket/tests/frame-length-longer-than-buffer_wsh.py
LayoutTests/http/tests/websocket/tests/server-close-expected.txt [deleted file]
LayoutTests/http/tests/websocket/tests/server-close.html [deleted file]
LayoutTests/http/tests/websocket/tests/server-close_wsh.py [deleted file]
LayoutTests/http/tests/websocket/tests/websocket-event-target-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/platform/network/SocketStreamHandleBase.cpp
Source/WebCore/platform/network/SocketStreamHandleBase.h
Source/WebCore/websockets/ThreadableWebSocketChannelClientWrapper.cpp
Source/WebCore/websockets/ThreadableWebSocketChannelClientWrapper.h
Source/WebCore/websockets/WebSocket.cpp
Source/WebCore/websockets/WebSocket.h
Source/WebCore/websockets/WebSocketChannel.cpp
Source/WebCore/websockets/WebSocketChannel.h
Source/WebCore/websockets/WebSocketChannelClient.h
Source/WebCore/websockets/WorkerThreadableWebSocketChannel.cpp
Source/WebCore/websockets/WorkerThreadableWebSocketChannel.h
Tools/ChangeLog
Tools/Scripts/webkitpy/thirdparty/__init__.py

index 9af9118..e106055 100644 (file)
@@ -1,3 +1,25 @@
+2011-05-27  Sheriff Bot  <webkit.review.bot@gmail.com>
+
+        Unreviewed, rolling out r87464.
+        http://trac.webkit.org/changeset/87464
+        https://bugs.webkit.org/show_bug.cgi?id=61643
+
+        client-close/server-close tests are flaky on Chromium Mac and
+        Windows (Requested by aklein on #webkit).
+
+        * http/tests/websocket/tests/client-close-expected.txt: Removed.
+        * http/tests/websocket/tests/client-close.html: Removed.
+        * http/tests/websocket/tests/client-close_wsh.py: Removed.
+        * http/tests/websocket/tests/close-before-open-expected.txt:
+        * http/tests/websocket/tests/close-event-expected.txt:
+        * http/tests/websocket/tests/close-event.html:
+        * http/tests/websocket/tests/close-unref-websocket-expected.txt:
+        * http/tests/websocket/tests/frame-length-longer-than-buffer_wsh.py:
+        * http/tests/websocket/tests/server-close-expected.txt: Removed.
+        * http/tests/websocket/tests/server-close.html: Removed.
+        * http/tests/websocket/tests/server-close_wsh.py: Removed.
+        * http/tests/websocket/tests/websocket-event-target-expected.txt:
+
 2011-05-27  Rob Buis  <rbuis@rim.com>
 
         Reviewed by Nikolas Zimmermann.
diff --git a/LayoutTests/http/tests/websocket/tests/client-close-expected.txt b/LayoutTests/http/tests/websocket/tests/client-close-expected.txt
deleted file mode 100644 (file)
index 5bb6eaa..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-WebSocket: Test client-initiated close.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-Connected
-Closed
-PASS closeEvent.wasClean is true
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
diff --git a/LayoutTests/http/tests/websocket/tests/client-close.html b/LayoutTests/http/tests/websocket/tests/client-close.html
deleted file mode 100644 (file)
index dfea21d..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-<!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>
-</head>
-<body>
-<div id="description"></div>
-<div id="console"></div>
-<script type="text/javascript">
-description("WebSocket: Test client-initiated close.");
-
-window.jsTestIsAsync = true;
-
-var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/client-close");
-var closeEvent;
-
-ws.onopen = function()
-{
-    debug("Connected");
-    ws.close();
-};
-
-ws.onmessage = function(messageEvent)
-{
-    debug("Received: " + messageEvent.data);
-};
-
-ws.onclose = function(event)
-{
-    debug("Closed");
-    closeEvent = event;
-    shouldBeTrue("closeEvent.wasClean");
-    finishJSTest();
-};
-
-var successfullyParsed = true;
-</script>
-<script src="../../../js-test-resources/js-test-post.js"></script>
-</body>
-</html>
diff --git a/LayoutTests/http/tests/websocket/tests/client-close_wsh.py b/LayoutTests/http/tests/websocket/tests/client-close_wsh.py
deleted file mode 100644 (file)
index 3ba91f6..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-from mod_pywebsocket import msgutil
-
-
-def web_socket_do_extra_handshake(request):
-    pass
-
-
-def web_socket_transfer_data(request):
-    # Wait for a close frame sent from the client.
-    close_frame = request.ws_stream.receive_bytes(2)
-
-    # If the following assertion fails, AssertionError will be raised,
-    # which will prevent pywebsocket from sending a close frame.
-    # In this case, the client will fail to finish closing handshake, thus
-    # closeEvent.wasClean will become false.
-    assert close_frame == '\xff\x00'
-
-    # Pretend we have received a close frame from the client.
-    # After this function exits, pywebsocket will send a close frame automatically.
-    request.client_terminated = True
index 57a542a..7a5d92f 100644 (file)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: line 0: WebSocket is closed before the connection is established.
 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".
index a605cc9..65be8e3 100644 (file)
@@ -7,7 +7,6 @@ Received: 'Hello from Simple WSH.'
 Closed
 PASS closeEventType is "close"
 PASS 'wasClean' in closeEvent is true
-PASS closeEvent.wasClean is true
 PASS Object.getPrototypeOf(closeEvent) === CloseEvent.prototype is true
 PASS Object.getPrototypeOf(closeEvent) !== Event.prototype is true
 PASS successfullyParsed is true
index 2ba1f0f..967e5d3 100644 (file)
@@ -33,7 +33,6 @@ ws.onclose = function(event)
     closeEventType = closeEvent.type;
     shouldBe("closeEventType", '"close"')
     shouldBeTrue("'wasClean' in closeEvent");
-    shouldBeTrue("closeEvent.wasClean");
     shouldBeTrue("Object.getPrototypeOf(closeEvent) === CloseEvent.prototype");
     shouldBeTrue("Object.getPrototypeOf(closeEvent) !== Event.prototype");
     finishJSTest();
index 39f5555..fc148b0 100644 (file)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: line 0: WebSocket is closed before the connection is established.
 Test if Web Socket is closed while handshaking and unreferenced, it should fire close event at most once.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
index 767d97c..0f91c96 100644 (file)
@@ -1,10 +1,10 @@
 def web_socket_do_extra_handshake(request):
-    pass
+  pass
 
 def web_socket_transfer_data(request):
-    msg = "\0hello\xff"
-    msg += "\x80\x81\x01" # Skip 1*128+1 bytes.
-    msg += "\x01\xff"
-    msg += "\0should be skipped\xff"
-    request.connection.write(msg)
-    raise Exception("Abort the connection") # Prevents pywebsocket from starting closing handshake.
+  msg = "\0hello\xff"
+  msg += "\x80\x81\x01"  # skip 1*128+1 bytes.
+  msg += "\x01\xff"
+  msg += "\0should be skipped\xff"
+  request.connection.write(msg)
+  print msg
diff --git a/LayoutTests/http/tests/websocket/tests/server-close-expected.txt b/LayoutTests/http/tests/websocket/tests/server-close-expected.txt
deleted file mode 100644 (file)
index feeda9e..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-WebSocket: Test server-initiated close.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-Connected
-Closed
-PASS closeEvent.wasClean is true
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
diff --git a/LayoutTests/http/tests/websocket/tests/server-close.html b/LayoutTests/http/tests/websocket/tests/server-close.html
deleted file mode 100644 (file)
index 2af487a..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<!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>
-</head>
-<body>
-<div id="description"></div>
-<div id="console"></div>
-<script type="text/javascript">
-description("WebSocket: Test server-initiated close.");
-
-window.jsTestIsAsync = true;
-
-var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/server-close");
-var closeEvent;
-
-ws.onopen = function()
-{
-    debug("Connected");
-};
-
-ws.onmessage = function(messageEvent)
-{
-    debug("Received: " + messageEvent.data);
-};
-
-ws.onclose = function(event)
-{
-    debug("Closed");
-    closeEvent = event;
-    shouldBeTrue("closeEvent.wasClean");
-    finishJSTest();
-};
-
-var successfullyParsed = true;
-</script>
-<script src="../../../js-test-resources/js-test-post.js"></script>
-</body>
-</html>
diff --git a/LayoutTests/http/tests/websocket/tests/server-close_wsh.py b/LayoutTests/http/tests/websocket/tests/server-close_wsh.py
deleted file mode 100644 (file)
index a0698a3..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-def web_socket_do_extra_handshake(request):
-    pass
-
-
-def web_socket_transfer_data(request):
-    # After this handler exits, pywebsocket initiates the closing handshake.
-    pass
index 379a44e..95b1ddd 100644 (file)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: line 0: WebSocket is closed before the connection is established.
 Make sure WebSocket object acts as EventTarget.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
index af699dd..8189ead 100644 (file)
@@ -1,3 +1,47 @@
+2011-05-27  Sheriff Bot  <webkit.review.bot@gmail.com>
+
+        Unreviewed, rolling out r87464.
+        http://trac.webkit.org/changeset/87464
+        https://bugs.webkit.org/show_bug.cgi?id=61643
+
+        client-close/server-close tests are flaky on Chromium Mac and
+        Windows (Requested by aklein on #webkit).
+
+        * platform/network/SocketStreamHandleBase.cpp:
+        (WebCore::SocketStreamHandleBase::send):
+        (WebCore::SocketStreamHandleBase::close):
+        (WebCore::SocketStreamHandleBase::sendPendingData):
+        * platform/network/SocketStreamHandleBase.h:
+        * websockets/ThreadableWebSocketChannelClientWrapper.cpp:
+        (WebCore::ThreadableWebSocketChannelClientWrapper::didClose):
+        (WebCore::ThreadableWebSocketChannelClientWrapper::didCloseCallback):
+        * websockets/ThreadableWebSocketChannelClientWrapper.h:
+        * websockets/WebSocket.cpp:
+        (WebCore::WebSocket::send):
+        (WebCore::WebSocket::close):
+        (WebCore::WebSocket::bufferedAmount):
+        (WebCore::WebSocket::didConnect):
+        (WebCore::WebSocket::didReceiveMessage):
+        (WebCore::WebSocket::didReceiveMessageError):
+        (WebCore::WebSocket::didClose):
+        * websockets/WebSocket.h:
+        * websockets/WebSocketChannel.cpp:
+        (WebCore::WebSocketChannel::WebSocketChannel):
+        (WebCore::WebSocketChannel::close):
+        (WebCore::WebSocketChannel::disconnect):
+        (WebCore::WebSocketChannel::didClose):
+        (WebCore::WebSocketChannel::didReceiveData):
+        (WebCore::WebSocketChannel::didFail):
+        (WebCore::WebSocketChannel::processBuffer):
+        * websockets/WebSocketChannel.h:
+        * websockets/WebSocketChannelClient.h:
+        (WebCore::WebSocketChannelClient::didClose):
+        * websockets/WorkerThreadableWebSocketChannel.cpp:
+        (WebCore::WorkerThreadableWebSocketChannel::Peer::close):
+        (WebCore::workerContextDidClose):
+        (WebCore::WorkerThreadableWebSocketChannel::Peer::didClose):
+        * websockets/WorkerThreadableWebSocketChannel.h:
+
 2011-05-27  Rob Buis  <rbuis@rim.com>
 
         Reviewed by Nikolas Zimmermann.
index d7a7e56..8472713 100644 (file)
@@ -52,7 +52,7 @@ SocketStreamHandleBase::SocketStreamState SocketStreamHandleBase::state() const
 
 bool SocketStreamHandleBase::send(const char* data, int length)
 {
-    if (m_state == Connecting || m_state == Closing)
+    if (m_state == Connecting)
         return false;
     if (!m_buffer.isEmpty()) {
         if (m_buffer.size() + length > bufferSize) {
@@ -78,16 +78,6 @@ bool SocketStreamHandleBase::send(const char* data, int length)
 
 void SocketStreamHandleBase::close()
 {
-    if (m_state == Closed)
-        return;
-    m_state = Closing;
-    if (!m_buffer.isEmpty())
-        return;
-    disconnect();
-}
-
-void SocketStreamHandleBase::disconnect()
-{
     RefPtr<SocketStreamHandle> protect(static_cast<SocketStreamHandle*>(this)); // platformClose calls the client, which may make the handle get deallocated immediately.
 
     platformClose();
@@ -102,16 +92,10 @@ void SocketStreamHandleBase::setClient(SocketStreamHandleClient* client)
 
 bool SocketStreamHandleBase::sendPendingData()
 {
-    if (m_state != Open && m_state != Closing)
+    if (m_state != Open)
+        return false;
+    if (m_buffer.isEmpty())
         return false;
-    if (m_buffer.isEmpty()) {
-        if (m_state == Open)
-            return false;
-        if (m_state == Closing) {
-            disconnect();
-            return false;
-        }
-    }
     int bytesWritten = platformSend(m_buffer.data(), m_buffer.size());
     if (bytesWritten <= 0)
         return false;
index 214bbd2..6082088 100644 (file)
@@ -48,8 +48,7 @@ namespace WebCore {
         SocketStreamState state() const;
 
         bool send(const char* data, int length);
-        void close(); // Disconnect after all data in buffer are sent.
-        void disconnect();
+        void close();
         int bufferedAmount() const { return m_buffer.size(); }
 
         SocketStreamHandleClient* client() const { return m_client; }
index 0db25a7..61307d5 100644 (file)
@@ -110,16 +110,9 @@ void ThreadableWebSocketChannelClientWrapper::didReceiveMessage(const String& me
         processPendingTasks();
 }
 
-void ThreadableWebSocketChannelClientWrapper::didStartClosingHandshake()
+void ThreadableWebSocketChannelClientWrapper::didClose(unsigned long unhandledBufferedAmount)
 {
-    m_pendingTasks.append(createCallbackTask(&ThreadableWebSocketChannelClientWrapper::didStartClosingHandshakeCallback, AllowCrossThreadAccess(this)));
-    if (!m_suspended)
-        processPendingTasks();
-}
-
-void ThreadableWebSocketChannelClientWrapper::didClose(unsigned long unhandledBufferedAmount, WebSocketChannelClient::ClosingHandshakeCompletionStatus closingHandshakeCompletion)
-{
-    m_pendingTasks.append(createCallbackTask(&ThreadableWebSocketChannelClientWrapper::didCloseCallback, AllowCrossThreadAccess(this), unhandledBufferedAmount, closingHandshakeCompletion));
+    m_pendingTasks.append(createCallbackTask(&ThreadableWebSocketChannelClientWrapper::didCloseCallback, AllowCrossThreadAccess(this), unhandledBufferedAmount));
     if (!m_suspended)
         processPendingTasks();
 }
@@ -158,18 +151,11 @@ void ThreadableWebSocketChannelClientWrapper::didReceiveMessageCallback(ScriptEx
         wrapper->m_client->didReceiveMessage(message);
 }
 
-void ThreadableWebSocketChannelClientWrapper::didStartClosingHandshakeCallback(ScriptExecutionContext* context, RefPtr<ThreadableWebSocketChannelClientWrapper> wrapper)
-{
-    ASSERT_UNUSED(context, !context);
-    if (wrapper->m_client)
-        wrapper->m_client->didStartClosingHandshake();
-}
-
-void ThreadableWebSocketChannelClientWrapper::didCloseCallback(ScriptExecutionContext* context, RefPtr<ThreadableWebSocketChannelClientWrapper> wrapper, unsigned long unhandledBufferedAmount, WebSocketChannelClient::ClosingHandshakeCompletionStatus closingHandshakeCompletion)
+void ThreadableWebSocketChannelClientWrapper::didCloseCallback(ScriptExecutionContext* context, RefPtr<ThreadableWebSocketChannelClientWrapper> wrapper, unsigned long unhandledBufferedAmount)
 {
     ASSERT_UNUSED(context, !context);
     if (wrapper->m_client)
-        wrapper->m_client->didClose(unhandledBufferedAmount, closingHandshakeCompletion);
+        wrapper->m_client->didClose(unhandledBufferedAmount);
 }
 
 } // namespace WebCore
index fa5f9ac..74659e2 100644 (file)
@@ -35,7 +35,6 @@
 
 #include "PlatformString.h"
 #include "ScriptExecutionContext.h"
-#include "WebSocketChannelClient.h"
 #include <wtf/Forward.h>
 #include <wtf/OwnPtr.h>
 #include <wtf/Threading.h>
@@ -63,8 +62,7 @@ public:
 
     void didConnect();
     void didReceiveMessage(const String& message);
-    void didStartClosingHandshake();
-    void didClose(unsigned long unhandledBufferedAmount, WebSocketChannelClient::ClosingHandshakeCompletionStatus);
+    void didClose(unsigned long unhandledBufferedAmount);
 
     void suspend();
     void resume();
@@ -75,8 +73,7 @@ protected:
     void processPendingTasks();
     static void didConnectCallback(ScriptExecutionContext*, RefPtr<ThreadableWebSocketChannelClientWrapper>);
     static void didReceiveMessageCallback(ScriptExecutionContext*, RefPtr<ThreadableWebSocketChannelClientWrapper>, String message);
-    static void didStartClosingHandshakeCallback(ScriptExecutionContext*, RefPtr<ThreadableWebSocketChannelClientWrapper>);
-    static void didCloseCallback(ScriptExecutionContext*, RefPtr<ThreadableWebSocketChannelClientWrapper>, unsigned long unhandledBufferedAmount, WebSocketChannelClient::ClosingHandshakeCompletionStatus);
+    static void didCloseCallback(ScriptExecutionContext*, RefPtr<ThreadableWebSocketChannelClientWrapper>, unsigned long unhandledBufferedAmount);
 
     WebSocketChannelClient* m_client;
     bool m_syncMethodDone;
index fd115ad..7ec8dd4 100644 (file)
@@ -164,7 +164,7 @@ bool WebSocket::send(const String& message, ExceptionCode& ec)
         return false;
     }
     // No exception is raised if the connection was once established but has subsequently been closed.
-    if (m_state == CLOSING || m_state == CLOSED) {
+    if (m_state == CLOSED) {
         m_bufferedAmountAfterClose += message.utf8().length() + 2; // 2 for frameing
         return false;
     }
@@ -176,14 +176,9 @@ bool WebSocket::send(const String& message, ExceptionCode& ec)
 void WebSocket::close()
 {
     LOG(Network, "WebSocket %p close", this);
-    if (m_state == CLOSING || m_state == CLOSED)
+    if (m_state == CLOSED)
         return;
-    if (m_state == CONNECTING) {
-        m_state = CLOSING;
-        m_channel->fail("WebSocket is closed before the connection is established.");
-        return;
-    }
-    m_state = CLOSING;
+    m_state = CLOSED;
     m_bufferedAmountAfterClose = m_channel->bufferedAmount();
     // didClose notification may be already queued, which we will inadvertently process while waiting for bufferedAmount() to return.
     // In this case m_channel will be set to null during didClose() call, thus we need to test validness of m_channel here.
@@ -205,8 +200,6 @@ unsigned long WebSocket::bufferedAmount() const
 {
     if (m_state == OPEN)
         return m_channel->bufferedAmount();
-    else if (m_state == CLOSING)
-        return m_channel->bufferedAmount() + m_bufferedAmountAfterClose;
     return m_bufferedAmountAfterClose;
 }
 
@@ -256,7 +249,7 @@ void WebSocket::didConnect()
 {
     LOG(Network, "WebSocket %p didConnect", this);
     if (m_state != CONNECTING) {
-        didClose(0, ClosingHandshakeIncomplete);
+        didClose(0);
         return;
     }
     ASSERT(scriptExecutionContext());
@@ -267,7 +260,7 @@ void WebSocket::didConnect()
 void WebSocket::didReceiveMessage(const String& msg)
 {
     LOG(Network, "WebSocket %p didReceiveMessage %s", this, msg.utf8().data());
-    if (m_state != OPEN && m_state != CLOSING)
+    if (m_state != OPEN)
         return;
     ASSERT(scriptExecutionContext());
     RefPtr<MessageEvent> evt = MessageEvent::create();
@@ -278,29 +271,22 @@ void WebSocket::didReceiveMessage(const String& msg)
 void WebSocket::didReceiveMessageError()
 {
     LOG(Network, "WebSocket %p didReceiveErrorMessage", this);
-    if (m_state != OPEN && m_state != CLOSING)
+    if (m_state != OPEN)
         return;
     ASSERT(scriptExecutionContext());
     dispatchEvent(Event::create(eventNames().errorEvent, false, false));
 }
 
-void WebSocket::didStartClosingHandshake()
-{
-    LOG(Network, "WebSocket %p didStartClosingHandshake", this);
-    m_state = CLOSING;
-}
-
-void WebSocket::didClose(unsigned long unhandledBufferedAmount, ClosingHandshakeCompletionStatus closingHandshakeCompletion)
+void WebSocket::didClose(unsigned long unhandledBufferedAmount)
 {
     LOG(Network, "WebSocket %p didClose", this);
     if (!m_channel)
         return;
-    bool wasClean = m_state == CLOSING && !unhandledBufferedAmount && closingHandshakeCompletion == ClosingHandshakeComplete;
     m_state = CLOSED;
     m_bufferedAmountAfterClose += unhandledBufferedAmount;
     ASSERT(scriptExecutionContext());
     RefPtr<CloseEvent> event = CloseEvent::create(false);
-    event->initCloseEvent(eventNames().closeEvent, false, false, wasClean);
+    event->initCloseEvent(eventNames().closeEvent, false, false, false);
     dispatchEvent(event);
     if (m_channel) {
         m_channel->disconnect();
index 191bc3f..66e645a 100644 (file)
@@ -95,8 +95,7 @@ namespace WebCore {
         virtual void didConnect();
         virtual void didReceiveMessage(const String& message);
         virtual void didReceiveMessageError();
-        virtual void didStartClosingHandshake();
-        virtual void didClose(unsigned long unhandledBufferedAmount, ClosingHandshakeCompletionStatus);
+        virtual void didClose(unsigned long unhandledBufferedAmount);
 
     private:
         WebSocket(ScriptExecutionContext*);
index 0be56e3..e3164f1 100644 (file)
@@ -56,8 +56,6 @@
 
 namespace WebCore {
 
-const double TCPMaximumSegmentLifetime = 2 * 60.0;
-
 WebSocketChannel::WebSocketChannel(ScriptExecutionContext* context, WebSocketChannelClient* client, const KURL& url, const String& protocol)
     : m_context(context)
     , m_client(client)
@@ -66,9 +64,6 @@ WebSocketChannel::WebSocketChannel(ScriptExecutionContext* context, WebSocketCha
     , m_bufferSize(0)
     , m_resumeTimer(this, &WebSocketChannel::resumeTimerFired)
     , m_suspended(false)
-    , m_closing(false)
-    , m_receivedClosingHandshake(false)
-    , m_closingTimer(this, &WebSocketChannel::closingTimerFired)
     , m_closed(false)
     , m_shouldDiscardReceivedData(false)
     , m_unhandledBufferedAmount(0)
@@ -122,11 +117,8 @@ void WebSocketChannel::close()
 {
     LOG(Network, "WebSocketChannel %p close", this);
     ASSERT(!m_suspended);
-    if (!m_handle)
-        return;
-    startClosingHandshake();
-    if (m_closing && !m_closingTimer.isActive())
-        m_closingTimer.startOneShot(2 * TCPMaximumSegmentLifetime);
+    if (m_handle)
+        m_handle->close();  // will call didClose()
 }
 
 void WebSocketChannel::fail(const String& reason)
@@ -148,7 +140,7 @@ void WebSocketChannel::disconnect()
     m_client = 0;
     m_context = 0;
     if (m_handle)
-        m_handle->disconnect();
+        m_handle->close();
 }
 
 void WebSocketChannel::suspend()
@@ -183,8 +175,6 @@ void WebSocketChannel::didClose(SocketStreamHandle* handle)
         InspectorInstrumentation::didCloseWebSocket(m_context, m_identifier);
     ASSERT_UNUSED(handle, handle == m_handle || !m_handle);
     m_closed = true;
-    if (m_closingTimer.isActive())
-        m_closingTimer.stop();
     if (m_handle) {
         m_unhandledBufferedAmount = m_handle->bufferedAmount();
         if (m_suspended)
@@ -194,7 +184,7 @@ void WebSocketChannel::didClose(SocketStreamHandle* handle)
         m_context = 0;
         m_handle = 0;
         if (client)
-            client->didClose(m_unhandledBufferedAmount, m_receivedClosingHandshake ? WebSocketChannelClient::ClosingHandshakeComplete : WebSocketChannelClient::ClosingHandshakeIncomplete);
+            client->didClose(m_unhandledBufferedAmount);
     }
     deref();
 }
@@ -207,13 +197,9 @@ void WebSocketChannel::didReceiveData(SocketStreamHandle* handle, const char* da
     if (!m_context) {
         return;
     }
-    if (len <= 0) {
-        handle->disconnect();
-        return;
-    }
     if (!m_client) {
         m_shouldDiscardReceivedData = true;
-        handle->disconnect();
+        handle->close();
         return;
     }
     if (m_shouldDiscardReceivedData)
@@ -247,7 +233,7 @@ void WebSocketChannel::didFail(SocketStreamHandle* handle, const SocketStreamErr
         m_context->addMessage(OtherMessageSource, NetworkErrorMessageType, ErrorMessageLevel, message, 0, failingURL, 0);
     }
     m_shouldDiscardReceivedData = true;
-    handle->disconnect();
+    handle->close();
 }
 
 void WebSocketChannel::didReceiveAuthenticationChallenge(SocketStreamHandle*, const AuthenticationChallenge&)
@@ -295,18 +281,9 @@ bool WebSocketChannel::processBuffer()
     ASSERT(!m_suspended);
     ASSERT(m_client);
     ASSERT(m_buffer);
-    LOG(Network, "WebSocketChannel %p processBuffer %lu", this, static_cast<unsigned long>(m_bufferSize));
-
     if (m_shouldDiscardReceivedData)
         return false;
 
-    if (m_receivedClosingHandshake) {
-        skipBuffer(m_bufferSize);
-        return false;
-    }
-
-    RefPtr<WebSocketChannel> protect(this); // The client can close the channel, potentially removing the last reference.
-
     if (m_handshake.mode() == WebSocketHandshake::Incomplete) {
         int headerLength = m_handshake.readServerHandshake(m_buffer, m_bufferSize);
         if (headerLength <= 0)
@@ -334,7 +311,7 @@ bool WebSocketChannel::processBuffer()
         skipBuffer(headerLength);
         m_shouldDiscardReceivedData = true;
         if (!m_closed)
-            m_handle->disconnect();
+            m_handle->close();
         return false;
     }
     if (m_handshake.mode() != WebSocketHandshake::Connected)
@@ -385,18 +362,12 @@ bool WebSocketChannel::processBuffer()
             return false;
         }
         ASSERT(p + length >= p);
-        if (p + length <= end) {
+        if (p + length < end) {
             p += length;
             nextFrame = p;
             ASSERT(nextFrame > m_buffer);
             skipBuffer(nextFrame - m_buffer);
-            if (frameByte == 0xff && !length) {
-                m_receivedClosingHandshake = true;
-                startClosingHandshake();
-                if (m_closing)
-                    m_handle->close(); // close after sending FF 00.
-            } else
-                m_client->didReceiveMessageError();
+            m_client->didReceiveMessageError();
             return m_buffer;
         }
         return false;
@@ -434,32 +405,6 @@ void WebSocketChannel::resumeTimerFired(Timer<WebSocketChannel>* timer)
         didClose(m_handle.get());
 }
 
-void WebSocketChannel::startClosingHandshake()
-{
-    LOG(Network, "WebSocketChannel %p closing %d %d", this, m_closing, m_receivedClosingHandshake);
-    if (m_closing)
-        return;
-    ASSERT(m_handle);
-    Vector<char> buf;
-    buf.append('\xff');
-    buf.append('\0');
-    if (!m_handle->send(buf.data(), buf.size())) {
-        m_handle->disconnect();
-        return;
-    }
-    m_closing = true;
-    if (m_client)
-        m_client->didStartClosingHandshake();
-}
-
-void WebSocketChannel::closingTimerFired(Timer<WebSocketChannel>* timer)
-{
-    LOG(Network, "WebSocketChannel %p closing timer", this);
-    ASSERT_UNUSED(timer, &m_closingTimer == timer);
-    if (m_handle)
-        m_handle->disconnect();
-}
-
 }  // namespace WebCore
 
 #endif  // ENABLE(WEB_SOCKETS)
index 5d57289..cd4bdb8 100644 (file)
@@ -57,7 +57,7 @@ namespace WebCore {
         virtual void connect();
         virtual bool send(const String& message);
         virtual unsigned long bufferedAmount() const;
-        virtual void close(); // Start closing handshake.
+        virtual void close();
         virtual void fail(const String& reason);
         virtual void disconnect();
 
@@ -85,8 +85,6 @@ namespace WebCore {
         void skipBuffer(size_t len);
         bool processBuffer();
         void resumeTimerFired(Timer<WebSocketChannel>* timer);
-        void startClosingHandshake();
-        void closingTimerFired(Timer<WebSocketChannel>*);
 
         ScriptExecutionContext* m_context;
         WebSocketChannelClient* m_client;
@@ -97,9 +95,6 @@ namespace WebCore {
 
         Timer<WebSocketChannel> m_resumeTimer;
         bool m_suspended;
-        bool m_closing;
-        bool m_receivedClosingHandshake;
-        Timer<WebSocketChannel> m_closingTimer;
         bool m_closed;
         bool m_shouldDiscardReceivedData;
         unsigned long m_unhandledBufferedAmount;
index 38bd17d..1551073 100644 (file)
@@ -41,12 +41,7 @@ namespace WebCore {
         virtual void didConnect() { }
         virtual void didReceiveMessage(const String&) { }
         virtual void didReceiveMessageError() { }
-        virtual void didStartClosingHandshake() { }
-        enum ClosingHandshakeCompletionStatus {
-            ClosingHandshakeIncomplete,
-            ClosingHandshakeComplete
-        };
-        virtual void didClose(unsigned long /* unhandledBufferedAmount */, ClosingHandshakeCompletionStatus) { }
+        virtual void didClose(unsigned long /* unhandledBufferedAmount */) { }
 
     protected:
         WebSocketChannelClient() { }
index 0026851..69fa288 100644 (file)
@@ -174,6 +174,7 @@ void WorkerThreadableWebSocketChannel::Peer::close()
     if (!m_mainWebSocketChannel)
         return;
     m_mainWebSocketChannel->close();
+    m_mainWebSocketChannel = 0;
 }
 
 void WorkerThreadableWebSocketChannel::Peer::fail(const String& reason)
@@ -233,29 +234,17 @@ void WorkerThreadableWebSocketChannel::Peer::didReceiveMessage(const String& mes
     m_loaderProxy.postTaskForModeToWorkerContext(createCallbackTask(&workerContextDidReceiveMessage, m_workerClientWrapper, message), m_taskMode);
 }
 
-static void workerContextDidStartClosingHandshake(ScriptExecutionContext* context, RefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper)
-{
-    ASSERT_UNUSED(context, context->isWorkerContext());
-    workerClientWrapper->didStartClosingHandshake();
-}
-
-void WorkerThreadableWebSocketChannel::Peer::didStartClosingHandshake()
-{
-    ASSERT(isMainThread());
-    m_loaderProxy.postTaskForModeToWorkerContext(createCallbackTask(&workerContextDidStartClosingHandshake, m_workerClientWrapper), m_taskMode);
-}
-
-static void workerContextDidClose(ScriptExecutionContext* context, RefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper, unsigned long unhandledBufferedAmount, WebSocketChannelClient::ClosingHandshakeCompletionStatus closingHandshakeCompletion)
+static void workerContextDidClose(ScriptExecutionContext* context, RefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper, unsigned long unhandledBufferedAmount)
 {
     ASSERT_UNUSED(context, context->isWorkerContext());
-    workerClientWrapper->didClose(unhandledBufferedAmount, closingHandshakeCompletion);
+    workerClientWrapper->didClose(unhandledBufferedAmount);
 }
 
-void WorkerThreadableWebSocketChannel::Peer::didClose(unsigned long unhandledBufferedAmount, ClosingHandshakeCompletionStatus closingHandshakeCompletion)
+void WorkerThreadableWebSocketChannel::Peer::didClose(unsigned long unhandledBufferedAmount)
 {
     ASSERT(isMainThread());
     m_mainWebSocketChannel = 0;
-    m_loaderProxy.postTaskForModeToWorkerContext(createCallbackTask(&workerContextDidClose, m_workerClientWrapper, unhandledBufferedAmount, closingHandshakeCompletion), m_taskMode);
+    m_loaderProxy.postTaskForModeToWorkerContext(createCallbackTask(&workerContextDidClose, m_workerClientWrapper, unhandledBufferedAmount), m_taskMode);
 }
 
 void WorkerThreadableWebSocketChannel::Bridge::setWebSocketChannel(ScriptExecutionContext* context, Bridge* thisPtr, Peer* peer, RefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper)
index 8fdd4b9..6e09786 100644 (file)
@@ -99,8 +99,7 @@ private:
 
         virtual void didConnect();
         virtual void didReceiveMessage(const String& message);
-        virtual void didStartClosingHandshake();
-        virtual void didClose(unsigned long unhandledBufferedAmount, ClosingHandshakeCompletionStatus);
+        virtual void didClose(unsigned long unhandledBufferedAmount);
 
     private:
         Peer(RefPtr<ThreadableWebSocketChannelClientWrapper>, WorkerLoaderProxy&, ScriptExecutionContext*, const String& taskMode, const KURL&, const String& protocol);
index eabdec4..55994e3 100644 (file)
@@ -1,3 +1,14 @@
+2011-05-27  Sheriff Bot  <webkit.review.bot@gmail.com>
+
+        Unreviewed, rolling out r87464.
+        http://trac.webkit.org/changeset/87464
+        https://bugs.webkit.org/show_bug.cgi?id=61643
+
+        client-close/server-close tests are flaky on Chromium Mac and
+        Windows (Requested by aklein on #webkit).
+
+        * Scripts/webkitpy/thirdparty/__init__.py:
+
 2011-05-27  Alexey Proskuryakov  <ap@apple.com>
 
         Added Douglas Davidson to contributors list for easier CC'ing.
index 325adef..7363f5f 100644 (file)
@@ -123,8 +123,8 @@ class AutoinstallImportHook(object):
     def _install_pywebsocket(self):
         pywebsocket_dir = self._fs.join(_AUTOINSTALLED_DIR, "pywebsocket")
         installer = AutoInstaller(target_dir=pywebsocket_dir)
-        installer.install(url="http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.6b1.tar.gz",
-                          url_subpath="pywebsocket-0.6b1/src/mod_pywebsocket")
+        installer.install(url="http://pywebsocket.googlecode.com/files/mod_pywebsocket-0.5.2.tar.gz",
+                          url_subpath="pywebsocket-0.5.2/src/mod_pywebsocket")
 
     def _install(self, url, url_subpath):
         installer = AutoInstaller(target_dir=_AUTOINSTALLED_DIR)