Commit 7991f6af authored by tyoshino@chromium.org's avatar tyoshino@chromium.org

[WebSocket] Remove layout tests about deflate-frame extension

The new WebSocket implementation doesn't support the extension.

R=yhirano
BUG=339373

Review URL: https://codereview.chromium.org/706573003

git-svn-id: svn://svn.chromium.org/blink/trunk@184871 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 1d92a092
...@@ -697,15 +697,6 @@ crbug.com/393095 [ Win7 ] fast/events/touch/compositor-touch-hit-rects-iframes.h ...@@ -697,15 +697,6 @@ crbug.com/393095 [ Win7 ] fast/events/touch/compositor-touch-hit-rects-iframes.h
crbug.com/393095 [ Win7 ] fast/events/touch/compositor-touch-hit-rects.html [ Pass Failure ] crbug.com/393095 [ Win7 ] fast/events/touch/compositor-touch-hit-rects.html [ Pass Failure ]
crbug.com/393096 [ Win7 ] fast/flexbox/overhanging-floats-removed.html [ Failure Pass ] crbug.com/393096 [ Win7 ] fast/flexbox/overhanging-floats-removed.html [ Failure Pass ]
# Tests of functionality not implemented in the new WebSocket
# implementation. These tests will be removed when the old implementation is
# removed.
crbug.com/339373 http/tests/websocket/deflate-frame-comp-bit-onoff.html [ Skip ]
crbug.com/339373 http/tests/websocket/deflate-frame-invalid-parameter.html [ Skip ]
crbug.com/339373 http/tests/websocket/deflate-frame-parameter.html [ Skip ]
crbug.com/339373 http/tests/websocket/deflate-frame-set-bfinal.html [ Skip ]
crbug.com/339373 http/tests/websocket/handshake-fail-by-no-cr.html [ Skip ]
crbug.com/393217 [ Debug ] editing/selection/move-by-word-visually-crash-test-5.html [ Pass Crash Timeout ] crbug.com/393217 [ Debug ] editing/selection/move-by-word-visually-crash-test-5.html [ Pass Crash Timeout ]
crbug.com/339778 crbug.com/412273 fast/dom/timer-throttling-hidden-page.html [ Failure Pass ] crbug.com/339778 crbug.com/412273 fast/dom/timer-throttling-hidden-page.html [ Failure Pass ]
......
CONSOLE WARNING: line 26: WebSocket extension "x-webkit-deflate-frame" is deprecated
Test compression enabled/disabled frame receiving.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Sending message: "Hello"
PASS event.data is 'Hello'
Sending message: "DisableCompression"
PASS event.data is 'DisableCompression'
Sending message: "World"
PASS event.data is 'World'
Sending message: "EnableCompression"
PASS event.data is 'EnableCompression'
Sending message: "Goodbye"
PASS event.data is 'Goodbye'
onclose() was called.
PASS closeEvent.wasClean is true
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML>
<html>
<head>
<script src="/js-test-resources/js-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description("Test compression enabled/disabled frame receiving.");
window.jsTestIsAsync = true;
var closeEvent;
var ws;
var messageIndex;
var messages = [
"Hello",
"DisableCompression", // This disables compression
"World",
"EnableCompression", // This enables compression
"Goodbye"
];
ws = new WebSocket("ws://localhost:8880/deflate-frame");
ws.onopen = function(event)
{
messageIndex = 0;
debug("Sending message: \"" + messages[messageIndex] + "\"");
ws.send(messages[messageIndex]);
};
ws.onmessage = function(event)
{
shouldBe("event.data", "'" + messages[messageIndex] + "'");
if (messageIndex === messages.length - 1)
ws.close();
else {
messageIndex += 1;
debug("Sending message: \"" + messages[messageIndex] + "\"");
ws.send(messages[messageIndex]);
}
};
ws.onclose = function(event)
{
debug("onclose() was called.");
closeEvent = event;
shouldBeTrue("closeEvent.wasClean");
finishJSTest();
};
</script>
</body>
</html>
CONSOLE ERROR: line 28: WebSocket connection to 'ws://localhost:8880/deflate-frame-invalid-parameter?x-foo' failed: Error during WebSocket handshake: Error in x-webkit-deflate-frame: Received unexpected deflate-frame parameter
CONSOLE ERROR: line 28: WebSocket connection to 'ws://localhost:8880/deflate-frame-invalid-parameter?max_window_bits=7' failed: Error during WebSocket handshake: Error in x-webkit-deflate-frame: Received invalid max_window_bits parameter
CONSOLE ERROR: line 28: WebSocket connection to 'ws://localhost:8880/deflate-frame-invalid-parameter?max_window_bits=16' failed: Error during WebSocket handshake: Error in x-webkit-deflate-frame: Received invalid max_window_bits parameter
CONSOLE ERROR: line 28: WebSocket connection to 'ws://localhost:8880/deflate-frame-invalid-parameter?no_context_takeover=foo' failed: Error during WebSocket handshake: Error in x-webkit-deflate-frame: Received invalid no_context_takeover parameter
CONSOLE ERROR: line 28: WebSocket connection to 'ws://localhost:8880/deflate-frame-invalid-parameter?max_window_bits=8;%20no_context_takeover;%20x-foo' failed: Error during WebSocket handshake: Error in x-webkit-deflate-frame: Received unexpected deflate-frame parameter
Test whether WebSocket rejects invalid deflate-frame parameters.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Testing parameter: "x-foo"
onclose() was called.
PASS closeEvent.wasClean is false
Testing parameter: "max_window_bits=7"
onclose() was called.
PASS closeEvent.wasClean is false
Testing parameter: "max_window_bits=16"
onclose() was called.
PASS closeEvent.wasClean is false
Testing parameter: "no_context_takeover=foo"
onclose() was called.
PASS closeEvent.wasClean is false
Testing parameter: "max_window_bits=8; no_context_takeover; x-foo"
onclose() was called.
PASS closeEvent.wasClean is false
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML>
<html>
<head>
<script src="/js-test-resources/js-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description("Test whether WebSocket rejects invalid deflate-frame parameters.");
window.jsTestIsAsync = true;
var closeEvent;
var testCase = [
"x-foo",
"max_window_bits=7",
"max_window_bits=16",
"no_context_takeover=foo",
"max_window_bits=8; no_context_takeover; x-foo"
];
function doTest(index)
{
var parameter = testCase[index];
var url = "ws://localhost:8880/deflate-frame-invalid-parameter?" + encodeURI(parameter);
var ws = new WebSocket(url);
debug("Testing parameter: \"" + parameter + "\"");
ws.onmessage = function(event)
{
var message = event.data;
testFailed("onmessage() was called. (message = \"" + message + "\")");
};
ws.onclose = function(event)
{
debug("onclose() was called.");
closeEvent = event;
shouldBeFalse("closeEvent.wasClean");
if (index === testCase.length - 1)
finishJSTest();
else
doTest(index + 1);
};
}
doTest(0);
</script>
</body>
</html>
# Copyright 2012, Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import urllib
from mod_pywebsocket import handshake
from mod_pywebsocket.handshake.hybi import compute_accept
def web_socket_do_extra_handshake(request):
resources = request.ws_resource.split('?', 1)
parameters = None
if len(resources) == 2:
parameters = urllib.unquote(resources[1])
message = 'HTTP/1.1 101 Switching Protocols\r\n'
message += 'Upgrade: websocket\r\n'
message += 'Connection: Upgrade\r\n'
message += 'Sec-WebSocket-Accept: %s\r\n' % compute_accept(request.headers_in['Sec-WebSocket-Key'])[0]
message += 'Sec-WebSocket-Extensions: x-webkit-deflate-frame'
if parameters:
message += '; %s\r\n' % parameters
else:
message += '\r\n'
message += '\r\n'
request.connection.write(message)
# Prevents pywebsocket from sending its own handshake message.
raise handshake.AbortedByUserException('Abort the connection')
def web_socket_transfer_data(request):
pass
CONSOLE WARNING: line 47: WebSocket extension "x-webkit-deflate-frame" is deprecated
CONSOLE WARNING: line 47: WebSocket extension "x-webkit-deflate-frame" is deprecated
CONSOLE WARNING: line 47: WebSocket extension "x-webkit-deflate-frame" is deprecated
Test WebSocket deflate-frame extension.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Testing query: "max_window_bits=8"
PASS ws.extensions.search('x-webkit-deflate-frame') != -1 is true
PASS ws.extensions.search('max_window_bits=8') != -1 is true
PASS event.data is firstMessage
PASS event.data is secondMessage
onclose() was called.
PASS closeEvent.wasClean is true
Testing query: "no_context_takeover"
PASS ws.extensions.search('x-webkit-deflate-frame') != -1 is true
PASS ws.extensions.search('no_context_takeover') != -1 is true
PASS event.data is firstMessage
PASS event.data is secondMessage
onclose() was called.
PASS closeEvent.wasClean is true
Testing query: "max_window_bits=8&no_context_takeover"
PASS ws.extensions.search('x-webkit-deflate-frame') != -1 is true
PASS ws.extensions.search('max_window_bits=8') != -1 is true
PASS ws.extensions.search('no_context_takeover') != -1 is true
PASS event.data is firstMessage
PASS event.data is secondMessage
onclose() was called.
PASS closeEvent.wasClean is true
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML>
<html>
<head>
<script src="/js-test-resources/js-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description("Test WebSocket deflate-frame extension.");
window.jsTestIsAsync = true;
var closeEvent;
var ws;
var messageIndex;
var queries = [
"max_window_bits=8",
"no_context_takeover",
"max_window_bits=8&no_context_takeover"
];
// The first message consists of a lot of 'b' and a few 'a' at the head and
// the tail, while the second one consists of 'a'.
var firstMessage = '';
var secondMessage = '';
for (var i = 0; i < 16; ++i) {
firstMessage += 'a';
secondMessage += 'a';
}
for (var i = 0; i < 1024; ++i) {
firstMessage += 'b';
secondMessage += 'a';
}
for (var i = 0; i < 16; ++i) {
firstMessage += 'a';
secondMessage += 'a';
}
function doTest(queryIndex)
{
var query = queries[queryIndex];
debug("Testing query: \"" + query + "\"");
var url = "ws://localhost:8880/deflate-frame?" + query;
ws = new WebSocket(url);
messageIndex = 0;
ws.onopen = function(event)
{
shouldBeTrue("ws.extensions.search('x-webkit-deflate-frame') != -1");
parameters = query.split('&');
for (var i = 0; i < parameters.length; ++i)
shouldBeTrue("ws.extensions.search('" + parameters[i] + "') != -1");
ws.send(firstMessage);
};
ws.onmessage = function(event)
{
if (messageIndex === 0) {
shouldBe("event.data", "firstMessage");
messageIndex += 1
ws.send(secondMessage);
} else {
shouldBe("event.data", "secondMessage");
ws.close();
}
};
ws.onclose = function(event)
{
debug("onclose() was called.");
closeEvent = event;
shouldBeTrue("closeEvent.wasClean");
if (queryIndex === queries.length - 1)
finishJSTest();
else
doTest(queryIndex + 1);
};
}
doTest(0);
</script>
</body>
</html>
CONSOLE WARNING: line 24: WebSocket extension "x-webkit-deflate-frame" is deprecated
Test receiving compressed frames with BFINAL = 1.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Sending message: "Hello"
PASS event.data is 'Hello'
Sending message: "World"
PASS event.data is 'World'
Sending message: "Goodbye"
PASS event.data is 'Goodbye'
onclose() was called.
PASS closeEvent.wasClean is true
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML>
<html>
<head>
<script src="/js-test-resources/js-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description("Test receiving compressed frames with BFINAL = 1.");
window.jsTestIsAsync = true;
var closeEvent;
var ws;
var messageIndex;
var messages = [
"Hello",
"World",
"Goodbye"
];
ws = new WebSocket("ws://localhost:8880/deflate-frame?set_bfinal");
ws.onopen = function(event)
{
messageIndex = 0;
debug("Sending message: \"" + messages[messageIndex] + "\"");
ws.send(messages[messageIndex]);
};
ws.onmessage = function(event)
{
shouldBe("event.data", "'" + messages[messageIndex] + "'");
if (messageIndex === messages.length - 1)
ws.close();
else {
messageIndex += 1;
debug("Sending message: \"" + messages[messageIndex] + "\"");
ws.send(messages[messageIndex]);
}
};
ws.onclose = function(event)
{
debug("onclose() was called.");
closeEvent = event;
shouldBeTrue("closeEvent.wasClean");
finishJSTest();
};
</script>
</body>
</html>
# Copyright 2012, Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import urlparse
from mod_pywebsocket.extensions import DeflateFrameExtensionProcessor
from mod_pywebsocket.extensions import ExtensionProcessorInterface
from mod_pywebsocket.common import ExtensionParameter
_GOODBYE_MESSAGE = u'Goodbye'
_ENABLE_MESSAGE = u'EnableCompression'
_DISABLE_MESSAGE = u'DisableCompression'
def _get_deflate_frame_extension_processor(request):
for extension_processor in request.ws_extension_processors:
if isinstance(extension_processor, DeflateFrameExtensionProcessor):
return extension_processor
return None
def web_socket_do_extra_handshake(request):
processor = _get_deflate_frame_extension_processor(request)
if not processor:
return
# Avoid extension conflict.
request.ws_extension_processors = [processor]
r = request.ws_resource.split('?', 1)
if len(r) == 1:
return
parameters = urlparse.parse_qs(r[1], keep_blank_values=True)
if 'max_window_bits' in parameters:
window_bits = int(parameters['max_window_bits'][0])
processor.set_response_window_bits(window_bits)
if 'no_context_takeover' in parameters:
processor.set_response_no_context_takeover(True)
if 'set_bfinal' in parameters:
processor.set_bfinal(True)
def web_socket_transfer_data(request):
processor = _get_deflate_frame_extension_processor(request)
while True:
line = request.ws_stream.receive_message()
if line is None:
return
if isinstance(line, unicode):
if processor:
if line == _ENABLE_MESSAGE:
processor.enable_outgoing_compression()
elif line == _DISABLE_MESSAGE:
processor.disable_outgoing_compression()
request.ws_stream.send_message(line, binary=False)
if line == _GOODBYE_MESSAGE:
return
else:
request.ws_stream.send_message(line, binary=True)
# vi:sts=4 sw=4 et
CONSOLE ERROR: line 25: WebSocket connection to 'ws://localhost:8880/handshake-fail-by-no-cr' failed: Error during WebSocket handshake: Status line does not end with CRLF
Handshake should fail when the first line does not end with CRLF.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS connected is false
PASS origin is undefined.
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="/js-test-resources/js-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script type="text/javascript">
description('Handshake should fail when the first line does not end with CRLF.');
window.jsTestIsAsync = true;
var connected = false;
var origin;
function endTest() {
shouldBeFalse('connected');
shouldBeUndefined('origin');
clearTimeout(timeoutID);
finishJSTest();
}
var url = 'ws://localhost:8880/handshake-fail-by-no-cr';
var ws = new WebSocket(url);
ws.onopen = function()
{
debug('Connected');
connected = true;
}
ws.onmessage = function(messageEvent)
{
origin = messageEvent.data;
debug('origin = ' + origin);
ws.close();
}
ws.onclose = function()
{
endTest();
}
function timeoutCallback()
{
debug('Timed out (state = ' + ws.readyState + ')');
endTest();
}
var timeoutID = setTimeout(timeoutCallback, 3000);
</script>
</body>
</html>
from mod_pywebsocket import handshake
from mod_pywebsocket.handshake.hybi import compute_accept
def web_socket_do_extra_handshake(request):
msg = 'HTTP/1.1 101 Switching Protocols\n' # Does not end with "\r\n".
msg += 'Upgrade: websocket\r\n'
msg += 'Connection: Upgrade\r\n'
msg += 'Sec-WebSocket-Accept: %s\r\n' % compute_accept(request.headers_in['Sec-WebSocket-Key'])[0]
msg += '\r\n'
request.connection.write(msg)
print msg
# Prevents pywebsocket from sending its own handshake message.
raise handshake.AbortedByUserException('Abort the connection')
def web_socket_transfer_data(request):
pass
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