Changeset 120291 in webkit


Ignore:
Timestamp:
Jun 14, 2012 12:22:09 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[WebSocket] WebSocket object in Worker Context should fire error event when it fails connection.
https://bugs.webkit.org/show_bug.cgi?id=88744

Patch by Li Yin <li.yin@intel.com> on 2012-06-14
Reviewed by Kent Tamura.

Source/WebCore:

Spec:http://dev.w3.org/html5/websockets/#feedback-from-the-protocol
The behavior of firing error event in Document has been implemented in Committed r117944.
WebSocket in WorkerContext is also required to fire error event.

Test: http/tests/websocket/tests/hybi/workers/close.html

  • Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp:

(WebCore::ThreadableWebSocketChannelClientWrapper::didReceiveMessageError):
(WebCore):
(WebCore::ThreadableWebSocketChannelClientWrapper::didReceiveMessageErrorCallback):

  • Modules/websockets/ThreadableWebSocketChannelClientWrapper.h:

(ThreadableWebSocketChannelClientWrapper):

  • Modules/websockets/WorkerThreadableWebSocketChannel.cpp:

(WebCore::workerContextDidReceiveMessageError):
(WebCore):
(WebCore::WorkerThreadableWebSocketChannel::Peer::didReceiveMessageError):

  • Modules/websockets/WorkerThreadableWebSocketChannel.h:

(Peer):

LayoutTests:

  • http/tests/websocket/tests/hybi/workers/close-expected.txt:
  • http/tests/websocket/tests/hybi/workers/resources/close.js:

(testPassed):
(runCodeTest.else.ws.onerror):
(runCodeTest):
(runReasonTest.else.ws.onerror):
(runReasonTest):

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r120287 r120291  
     12012-06-14  Li Yin  <li.yin@intel.com>
     2
     3        [WebSocket] WebSocket object in Worker Context should fire error event when it fails connection.
     4        https://bugs.webkit.org/show_bug.cgi?id=88744
     5
     6        Reviewed by Kent Tamura.
     7
     8        * http/tests/websocket/tests/hybi/workers/close-expected.txt:
     9        * http/tests/websocket/tests/hybi/workers/resources/close.js:
     10        (testPassed):
     11        (runCodeTest.else.ws.onerror):
     12        (runCodeTest):
     13        (runReasonTest.else.ws.onerror):
     14        (runReasonTest):
     15
    1162012-06-13  Zan Dobersek  <zandobersek@gmail.com>
    217
  • trunk/LayoutTests/http/tests/websocket/tests/hybi/workers/close-expected.txt

    r110037 r120291  
    4646Code NaN must cause INVALID_ACCESS_ERR.
    4747PASS PASS: worker: exceptionName is invalidAccessErr
     48PASS PASS: onerror() was called.
    4849runCodeTest: onclose().
    4950PASS PASS: worker: closeEvent.code is abnormalClosure
     
    6061PASS PASS: worker: exceptionName is syntaxErr
    6162Reason test: 2
     63PASS PASS: onerror() was called.
    6264runReasonTest: onclose().
    6365PASS PASS: worker: closeEvent.code is abnormalClosure
  • trunk/LayoutTests/http/tests/websocket/tests/hybi/workers/resources/close.js

    r94387 r120291  
    77    message += expected;
    88    postMessage(message);
     9}
     10
     11function testPassed(message)
     12{
     13    postMessage("PASS: " + message);
    914}
    1015
     
    111116                    runInvalidStringTest();
    112117            };
     118            ws.onerror = function ()
     119            {
     120                testPassed("onerror() was called.");
     121            };
    113122        }
    114123        try {
     
    147156                if (closeEvent.code == abnormalClosure)
    148157                    runCodeAndReasonTest();
     158            };
     159            ws.onerror = function ()
     160            {
     161                testPassed("onerror() was called.");
    149162            };
    150163        }
  • trunk/Source/WebCore/ChangeLog

    r120289 r120291  
     12012-06-14  Li Yin  <li.yin@intel.com>
     2
     3        [WebSocket] WebSocket object in Worker Context should fire error event when it fails connection.
     4        https://bugs.webkit.org/show_bug.cgi?id=88744
     5
     6        Reviewed by Kent Tamura.
     7
     8        Spec:http://dev.w3.org/html5/websockets/#feedback-from-the-protocol
     9        The behavior of firing error event in Document has been implemented in Committed r117944.
     10        WebSocket in WorkerContext is also required to fire error event.
     11
     12        Test: http/tests/websocket/tests/hybi/workers/close.html
     13
     14        * Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp:
     15        (WebCore::ThreadableWebSocketChannelClientWrapper::didReceiveMessageError):
     16        (WebCore):
     17        (WebCore::ThreadableWebSocketChannelClientWrapper::didReceiveMessageErrorCallback):
     18        * Modules/websockets/ThreadableWebSocketChannelClientWrapper.h:
     19        (ThreadableWebSocketChannelClientWrapper):
     20        * Modules/websockets/WorkerThreadableWebSocketChannel.cpp:
     21        (WebCore::workerContextDidReceiveMessageError):
     22        (WebCore):
     23        (WebCore::WorkerThreadableWebSocketChannel::Peer::didReceiveMessageError):
     24        * Modules/websockets/WorkerThreadableWebSocketChannel.h:
     25        (Peer):
     26
    1272012-06-13  Kinuko Yasuda  <kinuko@chromium.org>
    228
  • trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp

    r116908 r120291  
    206206}
    207207
     208void ThreadableWebSocketChannelClientWrapper::didReceiveMessageError()
     209{
     210    m_pendingTasks.append(createCallbackTask(&didReceiveMessageErrorCallback, this));
     211    if (!m_suspended)
     212        processPendingTasks();
     213}
     214
    208215void ThreadableWebSocketChannelClientWrapper::suspend()
    209216{
     
    281288}
    282289
     290void ThreadableWebSocketChannelClientWrapper::didReceiveMessageErrorCallback(ScriptExecutionContext* context, PassRefPtr<ThreadableWebSocketChannelClientWrapper> wrapper)
     291{
     292    ASSERT_UNUSED(context, !context);
     293    if (wrapper->m_client)
     294        wrapper->m_client->didReceiveMessageError();
     295}
     296
    283297} // namespace WebCore
    284298
  • trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.h

    r114215 r120291  
    8989    void didStartClosingHandshake();
    9090    void didClose(unsigned long unhandledBufferedAmount, WebSocketChannelClient::ClosingHandshakeCompletionStatus, unsigned short code, const String& reason);
     91    void didReceiveMessageError();
    9192
    9293    void suspend();
     
    105106    static void didCloseCallback(ScriptExecutionContext*, PassRefPtr<ThreadableWebSocketChannelClientWrapper>, unsigned long unhandledBufferedAmount, WebSocketChannelClient::ClosingHandshakeCompletionStatus, unsigned short code, const String& reason);
    106107    static void processPendingTasksCallback(ScriptExecutionContext*, PassRefPtr<ThreadableWebSocketChannelClientWrapper>);
     108    static void didReceiveMessageErrorCallback(ScriptExecutionContext*, PassRefPtr<ThreadableWebSocketChannelClientWrapper>);
    107109
    108110    ScriptExecutionContext* m_context;
  • trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp

    r114215 r120291  
    346346}
    347347
     348static void workerContextDidReceiveMessageError(ScriptExecutionContext* context, PassRefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper)
     349{
     350    ASSERT_UNUSED(context, context->isWorkerContext());
     351    workerClientWrapper->didReceiveMessageError();
     352}
     353
     354void WorkerThreadableWebSocketChannel::Peer::didReceiveMessageError()
     355{
     356     ASSERT(isMainThread());
     357     m_loaderProxy.postTaskForModeToWorkerContext(createCallbackTask(&workerContextDidReceiveMessageError, m_workerClientWrapper), m_taskMode);
     358}
     359
    348360WorkerThreadableWebSocketChannel::Bridge::Bridge(PassRefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper, PassRefPtr<WorkerContext> workerContext, const String& taskMode)
    349361    : m_workerClientWrapper(workerClientWrapper)
  • trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.h

    r114215 r120291  
    107107        virtual void didStartClosingHandshake() OVERRIDE;
    108108        virtual void didClose(unsigned long unhandledBufferedAmount, ClosingHandshakeCompletionStatus, unsigned short code, const String& reason) OVERRIDE;
     109        virtual void didReceiveMessageError() OVERRIDE;
    109110
    110111    private:
Note: See TracChangeset for help on using the changeset viewer.