Commit 3be4a6e9 authored by Adam Rice's avatar Adam Rice Committed by Commit Bot

[WebSocket] Test header + close frame in same packet

Modify the existing web platform test opening-handshake/005.html to send
the response header and the close frame in the same packet. This
verifies that Chrome passes the close data to JavaScript correctly in
this case.

This increases the coverage of the existing test, so there's no need to
retain the old behaviour.

Also remove the timeout expectations for this test, and make sure it
doesn't timeout on failure.

Closed: 1090210
Change-Id: I327c55d1517615511d6d71e1b464d5d3dc03b502
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2228252
Commit-Queue: Adam Rice <ricea@chromium.org>
Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#775124}
parent 25096f5f
......@@ -2239,10 +2239,6 @@ crbug.com/626703 crbug.com/946710 http/tests/devtools/extensions/extensions-side
crbug.com/751952 virtual/text-antialias/international/complex-text-rectangle.html [ Timeout Pass ]
crbug.com/751952 [ Win ] editing/selection/modify_extend/extend_by_character.html [ Failure Pass ]
# Websockets
# Cannot be rebaselined because the output contains a timestamp and a random number.
crbug.com/803200 external/wpt/websockets/opening-handshake/005.html?wss [ Pass Failure Timeout ]
crbug.com/805463 external/wpt/acid/acid3/numbered-tests.html [ Skip ]
crbug.com/828506 [ Win ] fast/events/touch/scroll-without-mouse-lacks-mousemove-events.html [ Pass Failure ]
......@@ -2883,9 +2879,6 @@ crbug.com/626703 [ Win ] external/wpt/webrtc/RTCPeerConnection-operations.https.
crbug.com/626703 [ Linux ] external/wpt/content-dpr/content-dpr-various-elements.html [ Failure ]
crbug.com/626703 [ Mac ] external/wpt/content-dpr/content-dpr-various-elements.html [ Failure ]
crbug.com/626703 [ Win ] external/wpt/content-dpr/content-dpr-various-elements.html [ Failure ]
crbug.com/626703 [ Linux ] external/wpt/websockets/opening-handshake/005.html [ Timeout ]
crbug.com/626703 [ Mac ] external/wpt/websockets/opening-handshake/005.html [ Timeout ]
crbug.com/626703 [ Win ] external/wpt/websockets/opening-handshake/005.html [ Timeout ]
crbug.com/626703 [ Mac10.14 ] external/wpt/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/open-features-tokenization-top-left.html [ Timeout ]
crbug.com/626703 [ Linux ] external/wpt/workers/abrupt-completion.html [ Timeout ]
crbug.com/626703 [ Mac ] external/wpt/workers/abrupt-completion.html [ Timeout ]
......
......@@ -5,8 +5,8 @@ from mod_pywebsocket.handshake import AbortedByUserException, hybi
def web_socket_do_extra_handshake(request):
# Send simple response header. This test implements the handshake
# manually. It's not clear why.
# Send simple response header. This test implements the handshake manually,
# so that we can send the header in the same packet as the close frame.
msg = (b'HTTP/1.1 101 Switching Protocols:\x0D\x0A'
b'Connection: Upgrade\x0D\x0A'
b'Upgrade: WebSocket\x0D\x0A'
......@@ -14,10 +14,11 @@ def web_socket_do_extra_handshake(request):
b'Sec-WebSocket-Origin: %s\x0D\x0A'
b'Sec-WebSocket-Accept: %s\x0D\x0A\x0D\x0A') % (request.ws_origin.encode(
'UTF-8'), hybi.compute_accept_from_unicode(request.headers_in.get(common.SEC_WEBSOCKET_KEY_HEADER)))
request.connection.write(msg)
# Send a clean close frame.
body = stream.create_closing_handshake_body(1000, '')
request.connection.write(stream.create_close_frame(body))
# Create a clean close frame.
close_body = stream.create_closing_handshake_body(1001, 'PASS')
close_frame = stream.create_close_frame(close_body)
# Concatenate the header and the close frame and write them to the socket.
request.connection.write(msg + close_frame)
# Wait for the responding close frame from the user agent. It's not possible
# to use the stream methods at this point because the stream hasn't been
# established from pywebsocket's point of view. Instead just read the
......
<!doctype html>
<title>WebSockets: proper first line</title>
<title>WebSockets: response header and close frame in same packet</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=../constants.js?pipe=sub></script>
......@@ -13,10 +13,13 @@ async_test(function(t) {
ws.onopen = t.step_func(function(e) {
ws.onclose = t.step_func(function(e) {
assert_equals(e.wasClean, true);
ws.onclose = t.unreached_func();
assert_equals(e.code, 1001);
assert_equals(e.reason, 'PASS');
ws.onclose = t.unreached_func('onclose should not be called twice');
t.step_timeout(() => t.done(), 50);
})
ws.close();
})
ws.onclose = t.unreached_func('onclose should not be called before onopen');
});
</script>
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