WebSocket: MessageEvent fired during send() on workers
authoryutak@chromium.org <yutak@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Feb 2012 08:43:48 +0000 (08:43 +0000)
committeryutak@chromium.org <yutak@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Feb 2012 08:43:48 +0000 (08:43 +0000)
commit2315451bb1c7a59ccfa1c0087ac92bcf7f56379c
tree9c4e830f602bce849516919c362f45516d5875df
parenta3e298805f196fcd9418d4ed656f73110cf1bb50
WebSocket: MessageEvent fired during send() on workers
https://bugs.webkit.org/show_bug.cgi?id=76521

Reviewed by David Levin.

Source/WebCore:

WebSocket's message event should not be invoked while a synchronous operation
(send() and bufferedAmount) is in progress.

Test: http/tests/websocket/tests/hybi/workers/no-onmessage-in-sync-op.html

* websockets/ThreadableWebSocketChannelClientWrapper.cpp:
Added #if ENABLE(WORKERS) because ThreadableWebSocketChannelClientWrapper is not used
if Web Workers is not available.
Changed access label because private members were declared as protected with no good reason.
(WebCore::ThreadableWebSocketChannelClientWrapper::ThreadableWebSocketChannelClientWrapper):
Receive ScriptExecutionContext so we can post a task that should be executed later.
(WebCore::ThreadableWebSocketChannelClientWrapper::create):
(WebCore::ThreadableWebSocketChannelClientWrapper::processPendingTasksCallback):
(WebCore::ThreadableWebSocketChannelClientWrapper::processPendingTasks):
* websockets/ThreadableWebSocketChannelClientWrapper.h:
* websockets/WorkerThreadableWebSocketChannel.cpp:
(WebCore::WorkerThreadableWebSocketChannel::WorkerThreadableWebSocketChannel):

LayoutTests:

* http/tests/websocket/tests/hybi/workers/no-onmessage-in-sync-op-expected.txt: Added.
* http/tests/websocket/tests/hybi/workers/no-onmessage-in-sync-op.html: Added.
* http/tests/websocket/tests/hybi/workers/resources/no-onmessage-in-sync-op.js:
Added. The server sends messages immediately after the connection is established, but
these messages should not be delivered until the script exits the current cycle of
the event loop. The script calls a few synchronous operations to make sure we don't
fire MessageEvents while we are waiting for these operations to finish.
* http/tests/websocket/tests/hybi/workers/resources/no-onmessage-in-sync-op_wsh.py: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@107788 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/http/tests/websocket/tests/hybi/workers/no-onmessage-in-sync-op-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/websocket/tests/hybi/workers/no-onmessage-in-sync-op.html [new file with mode: 0644]
LayoutTests/http/tests/websocket/tests/hybi/workers/resources/no-onmessage-in-sync-op.js [new file with mode: 0644]
LayoutTests/http/tests/websocket/tests/hybi/workers/resources/no-onmessage-in-sync-op_wsh.py [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/websockets/ThreadableWebSocketChannelClientWrapper.cpp
Source/WebCore/websockets/ThreadableWebSocketChannelClientWrapper.h
Source/WebCore/websockets/WorkerThreadableWebSocketChannel.cpp