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