Commit b3d37027 authored by abarth@webkit.org's avatar abarth@webkit.org

WebSocket: Remove hixie76 protocol implementation

https://bugs.webkit.org/show_bug.cgi?id=88620

Patch by Yuta Kitamura <yutak@chromium.org> on 2012-07-10
Reviewed by Adam Barth.

Source/WebCore: 

This change removes code that implements the old hixie-76 WebSocket protocol which
isn't used anymore.

No new tests are added, because the code using the current protocol should not be
affected. Tests for hixie-76 protocol are skipped (these tests will be removed
eventually).

* Modules/websockets/ThreadableWebSocketChannel.h:
* Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp:
(WebCore::ThreadableWebSocketChannelClientWrapper::ThreadableWebSocketChannelClientWrapper):
(WebCore::ThreadableWebSocketChannelClientWrapper::didCreateWebSocketChannel):
* Modules/websockets/ThreadableWebSocketChannelClientWrapper.h:
(ThreadableWebSocketChannelClientWrapper):
* Modules/websockets/WebSocket.cpp:
(WebCore::WebSocket::WebSocket):
(WebCore::WebSocket::connect):
(WebCore::WebSocket::send):
(WebCore::WebSocket::protocol):
(WebCore::WebSocket::extensions):
(WebCore::WebSocket::binaryType):
(WebCore::WebSocket::setBinaryType):
(WebCore::WebSocket::didReceiveMessageError):
(WebCore::WebSocket::didClose):
(WebCore::WebSocket::getFramingOverhead):
* Modules/websockets/WebSocket.h:
* Modules/websockets/WebSocketChannel.cpp:
(WebCore::WebSocketChannel::WebSocketChannel):
(WebCore::WebSocketChannel::connect):
(WebCore::WebSocketChannel::send):
(WebCore::WebSocketChannel::fail):
(WebCore::WebSocketChannel::didCloseSocketStream):
(WebCore::WebSocketChannel::processBuffer):
(WebCore::WebSocketChannel::startClosingHandshake):
(WebCore::WebSocketChannel::enqueueTextFrame):
(WebCore::WebSocketChannel::enqueueRawFrame):
(WebCore::WebSocketChannel::enqueueBlobFrame):
(WebCore::WebSocketChannel::processOutgoingFrameQueue):
(WebCore::WebSocketChannel::abortOutgoingFrameQueue):
* Modules/websockets/WebSocketChannel.h:
(WebSocketChannel):
* Modules/websockets/WebSocketHandshake.cpp:
(WebCore::WebSocketHandshake::WebSocketHandshake):
(WebCore::WebSocketHandshake::clientHandshakeMessage):
(WebCore::WebSocketHandshake::clientHandshakeRequest):
(WebCore::WebSocketHandshake::readServerHandshake):
(WebCore::WebSocketHandshake::checkResponseHeaders):
* Modules/websockets/WebSocketHandshake.h:
* Modules/websockets/WorkerThreadableWebSocketChannel.cpp:
(WebCore::WorkerThreadableWebSocketChannel::WorkerContextDidInitializeTask::create):
(WebCore::WorkerThreadableWebSocketChannel::WorkerContextDidInitializeTask::WorkerContextDidInitializeTask):
(WorkerThreadableWebSocketChannel::WorkerContextDidInitializeTask):
(WebCore::WorkerThreadableWebSocketChannel::Bridge::mainThreadInitialize):
* Modules/websockets/WorkerThreadableWebSocketChannel.h:
(WorkerThreadableWebSocketChannel):
(Peer):
(Bridge):

LayoutTests: 

Skip tests under hixie76 directory in all ports, because hixie-76 protocol support is
being dropped. These tests will be removed later.

* platform/chromium/TestExpectations:
* platform/gtk/TestExpectations:
* platform/mac/TestExpectations:
* platform/qt/TestExpectations:
* platform/win/Skipped:
* platform/wk2/Skipped:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@122199 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent fe2082bf
2012-07-10 Yuta Kitamura <yutak@chromium.org>
WebSocket: Remove hixie76 protocol implementation
https://bugs.webkit.org/show_bug.cgi?id=88620
Reviewed by Adam Barth.
Skip tests under hixie76 directory in all ports, because hixie-76 protocol support is
being dropped. These tests will be removed later.
* platform/chromium/TestExpectations:
* platform/gtk/TestExpectations:
* platform/mac/TestExpectations:
* platform/qt/TestExpectations:
* platform/win/Skipped:
* platform/wk2/Skipped:
2012-07-09 Kent Tamura <tkent@chromium.org>
REGRESSION(r114862-r114886): Fix a crash by switching the input type to hidden.
ALERT: waiting for open
ALERT: message handled.first message
ALERT: message handled.second message
Make sure event handler called serially.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
alert will suspend/resume WebSocket.
onopen should fire later.
Connected
Enter onmessage: first message
Leave onmessage: first message
Enter onmessage: second message
Leave onmessage: second message
Closed
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../../js-test-resources/js-test-pre.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script type="text/javascript">
description("Make sure event handler called serially.");
window.jsTestIsAsync = true;
if (window.layoutTestController)
layoutTestController.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 1);
var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hixie76/send2");
ws.onopen = function()
{
debug("Connected");
};
ws.onmessage = function(messageEvent)
{
debug("Enter onmessage: " + messageEvent.data);
// alert() will suspend/resume WebSocket.
alert("message handled." + messageEvent.data);
debug("Leave onmessage: " + messageEvent.data);
};
ws.onclose = function()
{
debug("Closed");
finishJSTest();
};
debug("alert will suspend/resume WebSocket.");
alert("waiting for open");
debug("onopen should fire later.");
</script>
<script src="../../../../js-test-resources/js-test-post.js"></script>
</body>
</html>
CONSOLE MESSAGE: Invalid UTF-8 sequence in header name
Make sure WebSocket doesn't crash with bad handshake message.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
WebSocket is closed
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../../js-test-resources/js-test-pre.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script type="text/javascript">
description("Make sure WebSocket doesn't crash with bad handshake message.");
window.jsTestIsAsync = true;
if (window.layoutTestController)
layoutTestController.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 1);
var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hixie76/bad-handshake-crash");
ws.onopen = function () {
debug("WebSocket is open");
};
ws.onclose = function () {
debug("WebSocket is closed");
finishJSTest();
};
</script>
<script src="../../../../js-test-resources/js-test-post.js"></script>
</body>
</html>
from mod_pywebsocket import handshake
def web_socket_do_extra_handshake(request):
msg = "HTTP/1.1 101 WebSocket Protocol Handshake\r\n"
msg += "Upgrade: WebSocket\r\n"
msg += "Connection: Upgrade\r\n"
msg += "Sec-WebSocket-Location: " + request.ws_location + "\r\n"
msg += "Sec-WebSocket-Origin: " + request.ws_origin + "\r\n"
msg += "\xa5:\r\n"
msg += "\r\n"
msg += request.ws_challenge_md5
request.connection.write(msg)
print msg
raise handshake.AbortedByUserException("Abort the connection") # Prevents pywebsocket from sending its own handshake message.
def web_socket_transfer_data(request):
pass
CONSOLE MESSAGE: Wrong protocol for WebSocket '\u0000'
CONSOLE MESSAGE: Wrong protocol for WebSocket '\u0009'
CONSOLE MESSAGE: Wrong protocol for WebSocket '\u001B'
Test WebSocket bad sub-protocol names by control characters.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS new WebSocket("ws://127.0.0.1:8880/simple", "\0") threw exception Error: SYNTAX_ERR: DOM Exception 12.
PASS new WebSocket("ws://127.0.0.1:8880/simple", " ") threw exception Error: SYNTAX_ERR: DOM Exception 12.
PASS new WebSocket("ws://127.0.0.1:8880/simple", "
") threw exception SyntaxError: Unexpected EOF.
PASS new WebSocket("ws://127.0.0.1:8880/simple", "
") threw exception SyntaxError: Unexpected EOF.
PASS new WebSocket("ws://127.0.0.1:8880/simple", "") threw exception Error: SYNTAX_ERR: DOM Exception 12.
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../../js-test-resources/js-test-pre.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script type="text/javascript">
description("Test WebSocket bad sub-protocol names by control characters.");
if (window.layoutTestController)
layoutTestController.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 1);
// Fails if protocol contains an character less than U+0020.
shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\u0000")');
shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\u0009")');
shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\u000A")');
shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\u000D")');
shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\u001B")');
</script>
<script src="../../../../js-test-resources/js-test-post.js"></script>
</body>
</html>
CONSOLE MESSAGE: Wrong protocol for WebSocket ''
Test WebSocket bad sub-protocol names (empty).
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS new WebSocket("ws://127.0.0.1:8880/simple", "") threw exception Error: SYNTAX_ERR: DOM Exception 12.
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../../js-test-resources/js-test-pre.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script type="text/javascript">
description("Test WebSocket bad sub-protocol names (empty).");
if (window.layoutTestController)
layoutTestController.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 1);
// Fails if protocol is an empty string.
shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "")');
</script>
<script src="../../../../js-test-resources/js-test-post.js"></script>
</body>
</html>
CONSOLE MESSAGE: Wrong protocol for WebSocket '\u007F'
CONSOLE MESSAGE: Wrong protocol for WebSocket '\u0080'
CONSOLE MESSAGE: Wrong protocol for WebSocket '\u3042'
CONSOLE MESSAGE: Wrong protocol for WebSocket '\uFFFF'
CONSOLE MESSAGE: Wrong protocol for WebSocket '\uFEFF'
CONSOLE MESSAGE: Wrong protocol for WebSocket '\uFFFE'
CONSOLE MESSAGE: Wrong protocol for WebSocket '\uD840\uDC0B'
Test WebSocket bad sub-protocol names by non-ASCII chars.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS new WebSocket("ws://127.0.0.1:8880/simple", "") threw exception Error: SYNTAX_ERR: DOM Exception 12.
PASS new WebSocket("ws://127.0.0.1:8880/simple", "€") threw exception Error: SYNTAX_ERR: DOM Exception 12.
PASS new WebSocket("ws://127.0.0.1:8880/simple", "あ") threw exception Error: SYNTAX_ERR: DOM Exception 12.
PASS new WebSocket("ws://127.0.0.1:8880/simple", "￿") threw exception Error: SYNTAX_ERR: DOM Exception 12.
PASS new WebSocket("ws://127.0.0.1:8880/simple", "") threw exception Error: SYNTAX_ERR: DOM Exception 12.
PASS new WebSocket("ws://127.0.0.1:8880/simple", "￾") threw exception Error: SYNTAX_ERR: DOM Exception 12.
PASS new WebSocket("ws://127.0.0.1:8880/simple", "𠀋") threw exception Error: SYNTAX_ERR: DOM Exception 12.
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../../js-test-resources/js-test-pre.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script type="text/javascript">
description("Test WebSocket bad sub-protocol names by non-ASCII chars.");
if (window.layoutTestController)
layoutTestController.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 1);
// Fails if protocol contains an character greater than U+007E.
shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\u007F")');
shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\u0080")');
shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\u3042")');
shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\uFFFF")');
shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\uFEFF")');
shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\uFFFE")');
// Surrogate pairs
shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\uD840\uDC0B")');
</script>
<script src="../../../../js-test-resources/js-test-post.js"></script>
</body>
</html>
Web Socket bufferedAmount after closed
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Connected.
Closed.
PASS ws.readyState is 3
PASS ws.bufferedAmount is 0
PASS ws.send('send to closed socket') is false
PASS ws.bufferedAmount is 23
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../../js-test-resources/js-test-pre.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script type="text/javascript">
description("Web Socket bufferedAmount after closed");
window.jsTestIsAsync = true;
if (window.layoutTestController)
layoutTestController.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 1);
var ws = new WebSocket("ws://localhost:8880/websocket/tests/hixie76/simple");
ws.onopen = function()
{
debug("Connected.");
ws.close();
};
ws.onclose = function()
{
debug("Closed.");
shouldBe("ws.readyState", "3");
shouldBe("ws.bufferedAmount", "0");
shouldBeFalse("ws.send('send to closed socket')");
// If the connection is closed, bufferedAmount attribute's value will only
// increase with each call to the send() method.
// (the number does not reset to zero once the connection closes).
shouldBe("ws.bufferedAmount", "23");
finishJSTest();
};
</script>
<script src="../../../../js-test-resources/js-test-post.js"></script>
</body>
</html>
WebSocket: Test client-initiated close.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Connected
Received: close_frame='\xff\x00'
Closed
PASS receivedMessage is "close_frame='\\xff\\x00'"
PASS closeEvent.wasClean is true
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../../js-test-resources/js-test-pre.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script type="text/javascript">
description("WebSocket: Test client-initiated close.");
window.jsTestIsAsync = true;
if (window.layoutTestController)
layoutTestController.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 1);
var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hixie76/client-close");
var closeEvent;
var receivedMessage;
ws.onopen = function()
{
debug("Connected");
ws.close();
};
ws.onmessage = function(messageEvent)
{
debug("Received: " + messageEvent.data);
receivedMessage = messageEvent.data;
};
ws.onclose = function(event)
{
debug("Closed");
closeEvent = event;
shouldBeEqualToString("receivedMessage", "close_frame='\\xff\\x00'");
shouldBeTrue("closeEvent.wasClean");
finishJSTest();
};
</script>
<script src="../../../../js-test-resources/js-test-post.js"></script>
</body>
</html>
from mod_pywebsocket import msgutil
def web_socket_do_extra_handshake(request):
pass
def web_socket_transfer_data(request):
# Wait for a close frame sent from the client.
close_frame = request.ws_stream.receive_bytes(2)
# Tell the client what we have received.
msgutil.send_message(request, 'close_frame=%r' % close_frame)
# If the following assertion fails, AssertionError will be raised,
# which will prevent pywebsocket from sending a close frame.
# In this case, the client will fail to finish closing handshake, thus
# closeEvent.wasClean will become false.
assert close_frame == '\xff\x00'
# Pretend we have received a close frame from the client.
# After this function exits, pywebsocket will send a close frame automatically.
request.client_terminated = True
CONSOLE MESSAGE: WebSocket is closed before the connection is established.
Test if Web Socket fires close event when WebSocket is opened and closed fore open event is received.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
closed
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../../js-test-resources/js-test-pre.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script type="text/javascript">
description("Test if Web Socket fires close event when WebSocket is opened and closed fore open event is received.");
window.jsTestIsAsync = true;
if (window.layoutTestController)
layoutTestController.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 1);
var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hixie76/echo");
ws.onclose = function() {
debug("closed");
finishJSTest();
};
ws.close();
</script>
<script src="../../../../js-test-resources/js-test-post.js"></script>
</body>
</html>
Make sure WebSocket fires CloseEvent when closed.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
WebSocket is open
Received: 'Hello from Simple WSH.'
Closed
PASS closeEventType is "close"
PASS 'wasClean' in closeEvent is true
PASS closeEvent.wasClean is true
PASS Object.getPrototypeOf(closeEvent) === CloseEvent.prototype is true
PASS Object.getPrototypeOf(closeEvent) !== Event.prototype is true
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../../js-test-resources/js-test-pre.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script type="text/javascript">
description("Make sure WebSocket fires CloseEvent when closed.");
window.jsTestIsAsync = true;
if (window.layoutTestController)
layoutTestController.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 1);
var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hixie76/simple");
ws.onopen = function()
{
debug("WebSocket is open");
};
ws.onmessage = function(messageEvent)
{
debug("Received: '" + messageEvent.data + "'");
};
var closeEvent;
var closeEventType;
ws.onclose = function(event)
{
debug("Closed");
closeEvent = event;
closeEventType = closeEvent.type;
shouldBe("closeEventType", '"close"')
shouldBeTrue("'wasClean' in closeEvent");
shouldBeTrue("closeEvent.wasClean");
shouldBeTrue("Object.getPrototypeOf(closeEvent) === CloseEvent.prototype");
shouldBeTrue("Object.getPrototypeOf(closeEvent) !== Event.prototype");
finishJSTest();
};
</script>
<script src="../../../../js-test-resources/js-test-post.js"></script>
</body>
</html>
Test if Web Socket is closed when navigating to new location.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS ws on master document is ready.