Crash calling webSocket.close() from onError handler for blocked web socket.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Jul 2015 21:08:30 +0000 (21:08 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Jul 2015 21:08:30 +0000 (21:08 +0000)
commit8baaba52abe2cb64e28385a4aef4358cfdcbc1f4
treeb6dc00ecfcad3a918ccee62dfbbd956a18ac51b9
parent9636d523f52133b87e37b2e121ece124b05e8286
Crash calling webSocket.close() from onError handler for blocked web socket.
<rdar://problem/21771620> and https://bugs.webkit.org/show_bug.cgi?id=147411

Reviewed by Tim Horton.

Source/WebCore:

Tests: http/tests/security/mixedContent/websocket/insecure-websocket-in-iframe.html
       http/tests/security/mixedContent/websocket/insecure-websocket-in-main-frame.html

This was introduced with http://trac.webkit.org/changeset/185848

* Modules/websockets/WebSocket.cpp:
(WebCore::WebSocket::connect): When blocked because of mixedContent, call dispatchOrQueueErrorEvent().
(WebCore::WebSocket::didReceiveMessageError): Use dispatchOrQueueErrorEvent() instead.
(WebCore::WebSocket::dispatchOrQueueErrorEvent): Dispatch the error event, but don't dispatch one twice!
* Modules/websockets/WebSocket.h:

* Modules/websockets/WebSocketChannel.cpp:
(WebCore::WebSocketChannel::fail): Null-check m_handshake before creating a console message from it.

LayoutTests:

* http/tests/security/mixedContent/resources/frame-with-insecure-websocket.html: Add a call to webSocket.close() inside the onError handler.
* http/tests/security/mixedContent/websocket/insecure-websocket-in-iframe-expected.txt:
* http/tests/security/mixedContent/websocket/insecure-websocket-in-main-frame-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@187556 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/http/tests/security/mixedContent/resources/frame-with-insecure-websocket.html
LayoutTests/http/tests/security/mixedContent/websocket/insecure-websocket-in-iframe-expected.txt
LayoutTests/http/tests/security/mixedContent/websocket/insecure-websocket-in-main-frame-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/websockets/WebSocket.cpp
Source/WebCore/Modules/websockets/WebSocket.h
Source/WebCore/Modules/websockets/WebSocketChannel.cpp