[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):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@120291 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a4d136a6
2012-06-14 Li Yin <li.yin@intel.com>
[WebSocket] WebSocket object in Worker Context should fire error event when it fails connection.
https://bugs.webkit.org/show_bug.cgi?id=88744
Reviewed by Kent Tamura.
* 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):
2012-06-13 Zan Dobersek <zandobersek@gmail.com>
Unreviewed GTK gardening after r120246 and r120257, updating baselines.
......
......@@ -45,6 +45,7 @@ PASS PASS: worker: exceptionName is invalidAccessErr
Invalid code test: 12
Code NaN must cause INVALID_ACCESS_ERR.
PASS PASS: worker: exceptionName is invalidAccessErr
PASS PASS: onerror() was called.
runCodeTest: onclose().
PASS PASS: worker: closeEvent.code is abnormalClosure
Skip invalid string test.
......@@ -59,6 +60,7 @@ Reason 1234567890123456789012345678901234567890123456789012345678901234567890123
PASS PASS: worker: result is false
PASS PASS: worker: exceptionName is syntaxErr
Reason test: 2
PASS PASS: onerror() was called.
runReasonTest: onclose().
PASS PASS: worker: closeEvent.code is abnormalClosure
Code and reason test: 0
......
......@@ -8,6 +8,11 @@ function postResult(result, actual, expected)
postMessage(message);
}
function testPassed(message)
{
postMessage("PASS: " + message);
}
function testFailed(message)
{
postMessage("FAIL: " + message);
......@@ -110,6 +115,10 @@ function runCodeTest()
if (closeEvent.code == abnormalClosure)
runInvalidStringTest();
};
ws.onerror = function ()
{
testPassed("onerror() was called.");
};
}
try {
ws.close(codeTestCodes[id]);
......@@ -147,6 +156,10 @@ function runReasonTest()
if (closeEvent.code == abnormalClosure)
runCodeAndReasonTest();
};
ws.onerror = function ()
{
testPassed("onerror() was called.");
};
}
try {
ws.close(normalClosure, reasonTestReasons[id]);
......
2012-06-14 Li Yin <li.yin@intel.com>
[WebSocket] WebSocket object in Worker Context should fire error event when it fails connection.
https://bugs.webkit.org/show_bug.cgi?id=88744
Reviewed by Kent Tamura.
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):
2012-06-13 Kinuko Yasuda <kinuko@chromium.org>
Unreviewed build fix attempt for r120285
......@@ -205,6 +205,13 @@ void ThreadableWebSocketChannelClientWrapper::didClose(unsigned long unhandledBu
processPendingTasks();
}
void ThreadableWebSocketChannelClientWrapper::didReceiveMessageError()
{
m_pendingTasks.append(createCallbackTask(&didReceiveMessageErrorCallback, this));
if (!m_suspended)
processPendingTasks();
}
void ThreadableWebSocketChannelClientWrapper::suspend()
{
m_suspended = true;
......@@ -280,6 +287,13 @@ void ThreadableWebSocketChannelClientWrapper::didCloseCallback(ScriptExecutionCo
wrapper->m_client->didClose(unhandledBufferedAmount, closingHandshakeCompletion, code, reason);
}
void ThreadableWebSocketChannelClientWrapper::didReceiveMessageErrorCallback(ScriptExecutionContext* context, PassRefPtr<ThreadableWebSocketChannelClientWrapper> wrapper)
{
ASSERT_UNUSED(context, !context);
if (wrapper->m_client)
wrapper->m_client->didReceiveMessageError();
}
} // namespace WebCore
#endif
......@@ -88,6 +88,7 @@ public:
void didUpdateBufferedAmount(unsigned long bufferedAmount);
void didStartClosingHandshake();
void didClose(unsigned long unhandledBufferedAmount, WebSocketChannelClient::ClosingHandshakeCompletionStatus, unsigned short code, const String& reason);
void didReceiveMessageError();
void suspend();
void resume();
......@@ -104,6 +105,7 @@ private:
static void didStartClosingHandshakeCallback(ScriptExecutionContext*, PassRefPtr<ThreadableWebSocketChannelClientWrapper>);
static void didCloseCallback(ScriptExecutionContext*, PassRefPtr<ThreadableWebSocketChannelClientWrapper>, unsigned long unhandledBufferedAmount, WebSocketChannelClient::ClosingHandshakeCompletionStatus, unsigned short code, const String& reason);
static void processPendingTasksCallback(ScriptExecutionContext*, PassRefPtr<ThreadableWebSocketChannelClientWrapper>);
static void didReceiveMessageErrorCallback(ScriptExecutionContext*, PassRefPtr<ThreadableWebSocketChannelClientWrapper>);
ScriptExecutionContext* m_context;
WebSocketChannelClient* m_client;
......
......@@ -345,6 +345,18 @@ void WorkerThreadableWebSocketChannel::Peer::didClose(unsigned long unhandledBuf
m_loaderProxy.postTaskForModeToWorkerContext(createCallbackTask(&workerContextDidClose, m_workerClientWrapper, unhandledBufferedAmount, closingHandshakeCompletion, code, reason), m_taskMode);
}
static void workerContextDidReceiveMessageError(ScriptExecutionContext* context, PassRefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper)
{
ASSERT_UNUSED(context, context->isWorkerContext());
workerClientWrapper->didReceiveMessageError();
}
void WorkerThreadableWebSocketChannel::Peer::didReceiveMessageError()
{
ASSERT(isMainThread());
m_loaderProxy.postTaskForModeToWorkerContext(createCallbackTask(&workerContextDidReceiveMessageError, m_workerClientWrapper), m_taskMode);
}
WorkerThreadableWebSocketChannel::Bridge::Bridge(PassRefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper, PassRefPtr<WorkerContext> workerContext, const String& taskMode)
: m_workerClientWrapper(workerClientWrapper)
, m_workerContext(workerContext)
......
......@@ -106,6 +106,7 @@ public:
virtual void didUpdateBufferedAmount(unsigned long bufferedAmount) OVERRIDE;
virtual void didStartClosingHandshake() OVERRIDE;
virtual void didClose(unsigned long unhandledBufferedAmount, ClosingHandshakeCompletionStatus, unsigned short code, const String& reason) OVERRIDE;
virtual void didReceiveMessageError() OVERRIDE;
private:
Peer(PassRefPtr<ThreadableWebSocketChannelClientWrapper>, WorkerLoaderProxy&, ScriptExecutionContext*, const String& taskMode);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment