Diff
Modified: trunk/LayoutTests/ChangeLog (248101 => 248102)
--- trunk/LayoutTests/ChangeLog 2019-08-01 14:05:13 UTC (rev 248101)
+++ trunk/LayoutTests/ChangeLog 2019-08-01 14:21:26 UTC (rev 248102)
@@ -1,5 +1,50 @@
2019-08-01 Carlos Garcia Campos <cgar...@igalia.com>
+ [SOUP] WebSockets: add support for extensions when using web sockets libsoup API
+ https://bugs.webkit.org/show_bug.cgi?id=199943
+
+ Reviewed by Alex Christensen.
+
+ Add new tests for permessage-deflate imported from blink and rebaseline existing tests.
+
+ * TestExpectations: Skip permessage-deflate tests by default.
+ * http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-comp-bit-onoff.html: Added.
+ * http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-invalid-parameter.html: Added.
+ * http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-invalid-parameter_wsh.py: Added.
+ * http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-manual_wsh.py: Added.
+ * http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-parameter.html: Added.
+ * http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-set-bfinal.html: Added.
+ * http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-split-frames.html: Added.
+ * http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-split-frames_wsh.py: Added.
+ * http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-unsolicited-negotiation-response.html: Added.
+ * http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-unsolicited-negotiation-response_wsh.py: Added.
+ * http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-window-bits.html: Added.
+ * http/tests/websocket/tests/hybi/imported/blink/permessage-deflate_wsh.py: Added.
+ * platform/gtk/TestExpectations: Enable permessage-deflate tests.
+ * platform/gtk/http/tests/websocket/tests/hybi/deflate-frame-invalid-parameter-expected.txt: Added.
+ * platform/gtk/http/tests/websocket/tests/hybi/deflate-frame-parameter-expected.txt: Added.
+ * platform/gtk/http/tests/websocket/tests/hybi/extensions-expected.txt: Added.
+ * platform/gtk/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-comp-bit-onoff-expected.txt: Added.
+ * platform/gtk/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-invalid-parameter-expected.txt: Added.
+ * platform/gtk/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-parameter-expected.txt: Added.
+ * platform/gtk/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-set-bfinal-expected.txt: Added.
+ * platform/gtk/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-split-frames-expected.txt: Added.
+ * platform/gtk/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-unsolicited-negotiation-response-expected.txt: Added.
+ * platform/gtk/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-window-bits-expected.txt: Added.
+ * platform/wpe/TestExpectations: Enable permessage-deflate tests.
+ * platform/wpe/http/tests/websocket/tests/hybi/deflate-frame-invalid-parameter-expected.txt: Added.
+ * platform/wpe/http/tests/websocket/tests/hybi/deflate-frame-parameter-expected.txt: Added.
+ * platform/wpe/http/tests/websocket/tests/hybi/extensions-expected.txt: Added.
+ * platform/wpe/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-comp-bit-onoff-expected.txt: Added.
+ * platform/wpe/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-invalid-parameter-expected.txt: Added.
+ * platform/wpe/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-parameter-expected.txt: Added.
+ * platform/wpe/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-set-bfinal-expected.txt: Added.
+ * platform/wpe/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-split-frames-expected.txt: Added.
+ * platform/wpe/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-unsolicited-negotiation-response-expected.txt: Added.
+ * platform/wpe/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-window-bits-expected.txt: Added.
+
+2019-08-01 Carlos Garcia Campos <cgar...@igalia.com>
+
[SOUP] Switch to use libsoup WebSockets API
https://bugs.webkit.org/show_bug.cgi?id=200162
Modified: trunk/LayoutTests/TestExpectations (248101 => 248102)
--- trunk/LayoutTests/TestExpectations 2019-08-01 14:05:13 UTC (rev 248101)
+++ trunk/LayoutTests/TestExpectations 2019-08-01 14:21:26 UTC (rev 248102)
@@ -657,6 +657,15 @@
imported/w3c/web-platform-tests/pointerevents [ Skip ]
pointerevents [ Skip ]
+# permessage-deflate WebSocket extension only supported by Soup based ports
+http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-comp-bit-onoff.html [ Skip ]
+http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-invalid-parameter.html [ Skip ]
+http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-parameter.html [ Skip ]
+http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-set-bfinal.html [ Skip ]
+http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-split-frames.html [ Skip ]
+http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-unsolicited-negotiation-response.html [ Skip ]
+http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-window-bits.html [ Skip ]
+
#//////////////////////////////////////////////////////////////////////////////////////////
# End platform-specific tests.
#//////////////////////////////////////////////////////////////////////////////////////////
Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-comp-bit-onoff.html (0 => 248102)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-comp-bit-onoff.html (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-comp-bit-onoff.html 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,59 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src=""
+</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/websocket/tests/hybi/imported/blink/permessage-deflate");
+
+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>
Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-invalid-parameter.html (0 => 248102)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-invalid-parameter.html (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-invalid-parameter.html 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,59 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+description("Test whether WebSocket rejects invalid permessage-deflate parameters.");
+
+window.jsTestIsAsync = true;
+
+var closeEvent;
+
+var testCase = [
+ "x-foo",
+ "client_max_window_bits=7",
+ "client_max_window_bits=16",
+ "client_no_context_takeover=foo",
+ "client_max_window_bits=8; client_no_context_takeover; x-foo"
+];
+
+function doTest(index)
+{
+ var parameter = testCase[index];
+ var url = "" + 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);
+ };
+
+ ws._onerror_ = function(errorEvent)
+ {
+ testPassed("onerror() was called");
+ };
+}
+
+doTest(0);
+
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-invalid-parameter_wsh.py (0 => 248102)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-invalid-parameter_wsh.py (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-invalid-parameter_wsh.py 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,57 @@
+# Copyright 2013, 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: permessage-deflate'
+ 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
Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-manual_wsh.py (0 => 248102)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-manual_wsh.py (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-manual_wsh.py 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,119 @@
+# Copyright 2013, 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
+import zlib
+from mod_pywebsocket import common, util
+from mod_pywebsocket.extensions import PerMessageDeflateExtensionProcessor
+from mod_pywebsocket.extensions import ExtensionProcessorInterface
+from mod_pywebsocket.common import ExtensionParameter
+
+_GOODBYE_MESSAGE = u'Goodbye'
+_ENABLE_MESSAGE = u'EnableCompression'
+_DISABLE_MESSAGE = u'DisableCompression'
+_bfinal = False
+_client_max_window_bits = 15
+
+
+def _get_permessage_deflate_extension_processor(request):
+ for extension_processor in request.ws_extension_processors:
+ if isinstance(extension_processor, PerMessageDeflateExtensionProcessor):
+ return extension_processor
+ return None
+
+
+def web_socket_do_extra_handshake(request):
+ global _bfinal
+ global _client_max_window_bits
+ processor = _get_permessage_deflate_extension_processor(request)
+ # Remove extension processors other than
+ # PerMessageDeflateExtensionProcessor to avoid conflict.
+ request.ws_extension_processors = [processor]
+ if not processor:
+ return
+ r = request.ws_resource.split('?', 1)
+ if len(r) == 1:
+ return
+ parameters = urlparse.parse_qs(r[1], keep_blank_values=True)
+ if 'client_max_window_bits' in parameters:
+ window_bits = int(parameters['client_max_window_bits'][0])
+ processor.set_client_max_window_bits(window_bits)
+ _client_max_window_bits = window_bits
+ if 'client_no_context_takeover' in parameters:
+ processor.set_client_no_context_takeover(True)
+ if 'set_bfinal' in parameters:
+ _bfinal = True
+
+
+def receive(request):
+ stream = request.ws_stream
+ possibly_compressed_body = b''
+ compress = False
+ while True:
+ frame = stream._receive_frame_as_frame_object()
+ if frame.opcode == common.OPCODE_CLOSE:
+ message = stream._get_message_from_frame(frame)
+ stream._process_close_message(message)
+ return (False, None)
+ compress = compress or frame.rsv1
+ possibly_compressed_body += frame.payload
+ if frame.fin:
+ break
+ if compress:
+ return (compress, possibly_compressed_body + b'\x00\x00\xff\xff')
+ else:
+ return (compress, possibly_compressed_body)
+
+
+def web_socket_transfer_data(request):
+ processor = _get_permessage_deflate_extension_processor(request)
+ processor.set_bfinal(_bfinal)
+ inflater = util._Inflater(_client_max_window_bits)
+ while True:
+ compress, possibly_compressed_body = receive(request)
+ body = None
+ if possibly_compressed_body is None:
+ return
+ if compress:
+ inflater.append(possibly_compressed_body)
+ body = inflater.decompress(-1)
+ else:
+ body = possibly_compressed_body
+
+ text = body.decode('utf-8')
+ if processor:
+ if text == _ENABLE_MESSAGE:
+ processor.enable_outgoing_compression()
+ elif text == _DISABLE_MESSAGE:
+ processor.disable_outgoing_compression()
+ request.ws_stream.send_message(text, binary=False)
+ if text == _GOODBYE_MESSAGE:
+ return
+
+
+# vi:sts=4 sw=4 et
Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-parameter.html (0 => 248102)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-parameter.html (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-parameter.html 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,87 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+description("Test WebSocket permessage-deflate extension.");
+
+window.jsTestIsAsync = true;
+
+var closeEvent;
+var ws;
+var messageIndex;
+
+var queries = [
+ "client_max_window_bits=8",
+ "client_no_context_takeover",
+ "client_max_window_bits=8&client_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 = "" + query;
+ ws = new WebSocket(url);
+ messageIndex = 0;
+
+ ws._onopen_ = function(event)
+ {
+ shouldBeTrue("ws.extensions.search('permessage-deflate') != -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>
Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-set-bfinal.html (0 => 248102)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-set-bfinal.html (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-set-bfinal.html 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,55 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src=""
+</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/websocket/tests/hybi/imported/blink/permessage-deflate?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>
Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-split-frames.html (0 => 248102)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-split-frames.html (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-split-frames.html 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,31 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script type="text/_javascript_">
+description("Deflated message is split to multiple frames.");
+
+window.jsTestIsAsync = true;
+
+var ws = new WebSocket('ws://localhost:8880/websocket/tests/hybi/imported/blink/permessage-deflate-split-frames');
+ws._onopen_ = function()
+{
+ ws.send('kick');
+};
+
+ws._onmessage_ = function(e)
+{
+ debug('onmessage: ' + e.data);
+}
+
+ws._onclose_ = function(e)
+{
+ debug('onclose');
+ finishJSTest();
+};
+
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-split-frames_wsh.py (0 => 248102)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-split-frames_wsh.py (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-split-frames_wsh.py 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,53 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from mod_pywebsocket import common
+from mod_pywebsocket.extensions import PerMessageDeflateExtensionProcessor
+from mod_pywebsocket.stream import create_header
+
+
+def _get_permessage_deflate_extension_processor(request):
+ for extension_processor in request.ws_extension_processors:
+ if isinstance(extension_processor, PerMessageDeflateExtensionProcessor):
+ return extension_processor
+ return None
+
+
+def web_socket_do_extra_handshake(request):
+ processor = _get_permessage_deflate_extension_processor(request)
+ assert processor is not None
+ # Remove extension processors other than
+ # PerMessageDeflateExtensionProcessor to avoid conflict.
+ request.ws_extension_processors = [processor]
+
+
+def web_socket_transfer_data(request):
+ line = request.ws_stream.receive_message()
+ # Hello
+ payload = b'\xf2\x48\xcd\xc9\xc9\x07\x00\x00\x00\xff\xff'
+ # Strip \x00\x00\xff\xff
+ stripped = payload[:-4]
+
+ header = create_header(
+ common.OPCODE_TEXT,
+ len(payload),
+ fin=0,
+ rsv1=1,
+ rsv2=0,
+ rsv3=0,
+ mask=False)
+ request.ws_stream._write(header + payload)
+
+ header = create_header(
+ common.OPCODE_CONTINUATION,
+ len(stripped),
+ fin=1,
+ rsv1=0,
+ rsv2=0,
+ rsv3=0,
+ mask=False)
+ request.ws_stream._write(header + stripped)
+
+
+# vi:sts=4 sw=4 et
Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-unsolicited-negotiation-response.html (0 => 248102)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-unsolicited-negotiation-response.html (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-unsolicited-negotiation-response.html 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,35 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+description("Test whether WebSocket ignores unsolicited negotiation response.");
+
+window.jsTestIsAsync = true;
+
+var closeEvent;
+
+var url = ""
+var ws = new WebSocket(url);
+
+ws._onopen_ = function()
+{
+ debug('PASS onopen');
+ shouldBeEqualToString('ws.extensions', 'permessage-deflate; server_max_window_bits=15; server_no_context_takeover');
+ ws.close();
+}
+
+ws._onclose_ = function(event)
+{
+ window.event = event;
+ shouldBeTrue('event.wasClean');
+ finishJSTest();
+};
+
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-unsolicited-negotiation-response_wsh.py (0 => 248102)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-unsolicited-negotiation-response_wsh.py (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-unsolicited-negotiation-response_wsh.py 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,57 @@
+# Copyright 2013, 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 PerMessageDeflateExtensionProcessor
+
+
+def _get_permessage_deflate_extension_processor(request):
+ for extension_processor in request.ws_extension_processors:
+ if isinstance(extension_processor, PerMessageDeflateExtensionProcessor):
+ return extension_processor
+ return None
+
+
+def web_socket_do_extra_handshake(request):
+ processor = _get_permessage_deflate_extension_processor(request)
+ # Remove extension processors other than PerMessageDeflateProcessor
+ # to avoid conflict.
+ request.ws_extension_processors = [processor]
+ if not processor:
+ return
+ # Insert fake server_... parameters to make the server create
+ # a negotiation response including the parameters.
+ processor._request.add_parameter('server_no_context_takeover', None)
+ processor._request.add_parameter('server_max_window_bits', '15')
+
+
+def web_socket_transfer_data(request):
+ pass
+
+
+# vi:sts=4 sw=4 et
Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-window-bits.html (0 => 248102)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-window-bits.html (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-window-bits.html 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,79 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+description("Test WebSocket permessage-deflate extension: window bits.");
+
+window.jsTestIsAsync = true;
+
+var closeEvent;
+var ws;
+var messageIndex;
+
+var queries = [
+ "client_max_window_bits=8",
+ "client_max_window_bits=15",
+ "client_no_context_takeover",
+ "client_max_window_bits=8&client_no_context_takeover"
+];
+
+// We construct this message so that the test will fail if the client deflater
+// doesn't care about client_max_window_bits.
+var alpha = 'abcdefghijklmnopqrstuvwxyz'
+var message = '';
+for (var i = 0; i < 30000; ++i) {
+ message += '-';
+}
+message = alpha + message + alpha;
+
+function doTest(queryIndex)
+{
+ var query = queries[queryIndex];
+ debug("Testing query: \"" + query + "\"");
+
+ var url = "" + query;
+ ws = new WebSocket(url);
+
+ ws._onopen_ = function(event)
+ {
+ shouldBeTrue("ws.extensions.search('permessage-deflate') != -1");
+ parameters = query.split('&');
+ for (var i = 0; i < parameters.length; ++i)
+ shouldBeTrue("ws.extensions.search('" + parameters[i] + "') != -1");
+ ws.send(message);
+ };
+
+ ws._onmessage_ = function(event)
+ {
+ // Because message is too long and shouldBe tends to be timed out on fail,
+ // we use custom output rather than shouldBe.
+ if (event.data ="" message) {
+ debug('PASS event.data is message');
+ } else {
+ debug('FAIL event.data should be message but is ' + event.data);
+ }
+ 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>
Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate_wsh.py (0 => 248102)
--- trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate_wsh.py (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate_wsh.py 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,88 @@
+# Copyright 2013, 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 PerMessageDeflateExtensionProcessor
+from mod_pywebsocket.extensions import ExtensionProcessorInterface
+from mod_pywebsocket.common import ExtensionParameter
+
+_GOODBYE_MESSAGE = u'Goodbye'
+_ENABLE_MESSAGE = u'EnableCompression'
+_DISABLE_MESSAGE = u'DisableCompression'
+_bfinal = False
+
+
+def _get_permessage_deflate_extension_processor(request):
+ for extension_processor in request.ws_extension_processors:
+ if isinstance(extension_processor, PerMessageDeflateExtensionProcessor):
+ return extension_processor
+ return None
+
+
+def web_socket_do_extra_handshake(request):
+ global _bfinal
+ processor = _get_permessage_deflate_extension_processor(request)
+ # Remove extension processors other than PerMessageDeflateProcessor
+ # to avoid conflict.
+ request.ws_extension_processors = [processor]
+ if not processor:
+ return
+ r = request.ws_resource.split('?', 1)
+ if len(r) == 1:
+ return
+ parameters = urlparse.parse_qs(r[1], keep_blank_values=True)
+ if 'client_max_window_bits' in parameters:
+ window_bits = int(parameters['client_max_window_bits'][0])
+ processor.set_client_max_window_bits(window_bits)
+ if 'client_no_context_takeover' in parameters:
+ processor.set_client_no_context_takeover(True)
+ if 'set_bfinal' in parameters:
+ _bfinal = True
+
+
+def web_socket_transfer_data(request):
+ processor = _get_permessage_deflate_extension_processor(request)
+ processor.set_bfinal(_bfinal)
+ 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
Modified: trunk/LayoutTests/platform/gtk/TestExpectations (248101 => 248102)
--- trunk/LayoutTests/platform/gtk/TestExpectations 2019-08-01 14:05:13 UTC (rev 248101)
+++ trunk/LayoutTests/platform/gtk/TestExpectations 2019-08-01 14:21:26 UTC (rev 248102)
@@ -1175,11 +1175,6 @@
# Inspector tests don't work with platform WebSockets API
webkit.org/b/200162 http/tests/websocket/tests/hybi/inspector/ [ Skip ]
-# Extensions not supported with platform WebSockets API
-webkit.org/b/199943 http/tests/websocket/tests/hybi/extensions.html [ Failure ]
-webkit.org/b/199943 http/tests/websocket/tests/hybi/deflate-frame-invalid-parameter.html [ Failure ]
-webkit.org/b/199943 http/tests/websocket/tests/hybi/deflate-frame-parameter.html [ Failure ]
-
# Server cookie not handled with platform WebSockets API
webkit.org/b/200165 imported/w3c/web-platform-tests/websockets/cookies/002.html [ Failure ]
webkit.org/b/200165 imported/w3c/web-platform-tests/websockets/cookies/007.html [ Failure ]
@@ -3952,6 +3947,15 @@
imported/w3c/web-platform-tests/service-workers/service-worker/svg-target-reftest.https.html [ Pass ]
+# permessage-deflate WebSocket extension
+http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-comp-bit-onoff.html [ Pass ]
+http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-invalid-parameter.html [ Pass ]
+http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-parameter.html [ Pass ]
+http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-set-bfinal.html [ Pass ]
+http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-split-frames.html [ Pass ]
+http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-unsolicited-negotiation-response.html [ Pass ]
+http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-window-bits.html [ Pass ]
+
#////////////////////////////////////////////////////////////////////////////////////////
# End of PASSING tests. See top of file where to put new expectations.
#////////////////////////////////////////////////////////////////////////////////////////
Added: trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/deflate-frame-invalid-parameter-expected.txt (0 => 248102)
--- trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/deflate-frame-invalid-parameter-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/deflate-frame-invalid-parameter-expected.txt 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,23 @@
+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
+
Added: trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/deflate-frame-parameter-expected.txt (0 => 248102)
--- trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/deflate-frame-parameter-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/deflate-frame-parameter-expected.txt 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,30 @@
+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"
+FAIL ws.extensions.search('x-webkit-deflate-frame') != -1 should be true. Was false.
+FAIL ws.extensions.search('max_window_bits=8') != -1 should be true. Was false.
+PASS event.data is firstMessage
+PASS event.data is secondMessage
+onclose() was called.
+PASS closeEvent.wasClean is true
+Testing query: "no_context_takeover"
+FAIL ws.extensions.search('x-webkit-deflate-frame') != -1 should be true. Was false.
+FAIL ws.extensions.search('no_context_takeover') != -1 should be true. Was false.
+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"
+FAIL ws.extensions.search('x-webkit-deflate-frame') != -1 should be true. Was false.
+FAIL ws.extensions.search('max_window_bits=8') != -1 should be true. Was false.
+FAIL ws.extensions.search('no_context_takeover') != -1 should be true. Was false.
+PASS event.data is firstMessage
+PASS event.data is secondMessage
+onclose() was called.
+PASS closeEvent.wasClean is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/extensions-expected.txt (0 => 248102)
--- trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/extensions-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/extensions-expected.txt 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,14 @@
+Test WebSocket.extensions attribute.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Check the value before opening the connection:
+PASS ws.extensions is ""
+Check if the value is read only:
+PASS ws.extensions = 'foo'; ws.extensions is ""
+Check the value after the connection is established:
+FAIL ws.extensions should be x-webkit-deflate-frame. Was permessage-deflate.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-comp-bit-onoff-expected.txt (0 => 248102)
--- trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-comp-bit-onoff-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-comp-bit-onoff-expected.txt 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,24 @@
+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: ""
+PASS event.data is ''
+Sending message: ""
+PASS event.data is ''
+Sending message: "Goodbye"
+PASS event.data is 'Goodbye'
+onclose() was called.
+PASS closeEvent.wasClean is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-invalid-parameter-expected.txt (0 => 248102)
--- trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-invalid-parameter-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-invalid-parameter-expected.txt 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,28 @@
+Test whether WebSocket rejects invalid permessage-deflate parameters.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Testing parameter: "x-foo"
+PASS onerror() was called
+onclose() was called.
+PASS closeEvent.wasClean is false
+Testing parameter: "client_max_window_bits=7"
+PASS onerror() was called
+onclose() was called.
+PASS closeEvent.wasClean is false
+Testing parameter: "client_max_window_bits=16"
+PASS onerror() was called
+onclose() was called.
+PASS closeEvent.wasClean is false
+Testing parameter: "client_no_context_takeover=foo"
+PASS onerror() was called
+onclose() was called.
+PASS closeEvent.wasClean is false
+Testing parameter: "client_max_window_bits=8; client_no_context_takeover; x-foo"
+PASS onerror() was called
+onclose() was called.
+PASS closeEvent.wasClean is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-parameter-expected.txt (0 => 248102)
--- trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-parameter-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-parameter-expected.txt 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,30 @@
+Test WebSocket permessage-deflate extension.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Testing query: "client_max_window_bits=8"
+PASS ws.extensions.search('permessage-deflate') != -1 is true
+PASS ws.extensions.search('client_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: "client_no_context_takeover"
+PASS ws.extensions.search('permessage-deflate') != -1 is true
+PASS ws.extensions.search('client_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: "client_max_window_bits=8&client_no_context_takeover"
+PASS ws.extensions.search('permessage-deflate') != -1 is true
+PASS ws.extensions.search('client_max_window_bits=8') != -1 is true
+PASS ws.extensions.search('client_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
+
Added: trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-set-bfinal-expected.txt (0 => 248102)
--- trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-set-bfinal-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-set-bfinal-expected.txt 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,16 @@
+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
+
Added: trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-split-frames-expected.txt (0 => 248102)
--- trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-split-frames-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-split-frames-expected.txt 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,11 @@
+Deflated message is split to multiple frames.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+onmessage: HelloHello
+onclose
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-unsolicited-negotiation-response-expected.txt (0 => 248102)
--- trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-unsolicited-negotiation-response-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-unsolicited-negotiation-response-expected.txt 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,12 @@
+Test whether WebSocket ignores unsolicited negotiation response.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS onopen
+FAIL ws.extensions should be permessage-deflate; server_max_window_bits=15; server_no_context_takeover. Was permessage-deflate; server_no_context_takeover; server_max_window_bits=15.
+PASS event.wasClean is true
+PASS successfullyParsed is true
+Some tests failed.
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-window-bits-expected.txt (0 => 248102)
--- trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-window-bits-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/gtk/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-window-bits-expected.txt 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,33 @@
+Test WebSocket permessage-deflate extension: window bits.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Testing query: "client_max_window_bits=8"
+PASS ws.extensions.search('permessage-deflate') != -1 is true
+PASS ws.extensions.search('client_max_window_bits=8') != -1 is true
+PASS event.data is message
+onclose() was called.
+PASS closeEvent.wasClean is true
+Testing query: "client_max_window_bits=15"
+PASS ws.extensions.search('permessage-deflate') != -1 is true
+PASS ws.extensions.search('client_max_window_bits=15') != -1 is true
+PASS event.data is message
+onclose() was called.
+PASS closeEvent.wasClean is true
+Testing query: "client_no_context_takeover"
+PASS ws.extensions.search('permessage-deflate') != -1 is true
+PASS ws.extensions.search('client_no_context_takeover') != -1 is true
+PASS event.data is message
+onclose() was called.
+PASS closeEvent.wasClean is true
+Testing query: "client_max_window_bits=8&client_no_context_takeover"
+PASS ws.extensions.search('permessage-deflate') != -1 is true
+PASS ws.extensions.search('client_max_window_bits=8') != -1 is true
+PASS ws.extensions.search('client_no_context_takeover') != -1 is true
+PASS event.data is message
+onclose() was called.
+PASS closeEvent.wasClean is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Modified: trunk/LayoutTests/platform/wpe/TestExpectations (248101 => 248102)
--- trunk/LayoutTests/platform/wpe/TestExpectations 2019-08-01 14:05:13 UTC (rev 248101)
+++ trunk/LayoutTests/platform/wpe/TestExpectations 2019-08-01 14:21:26 UTC (rev 248102)
@@ -484,11 +484,6 @@
# Inspector tests don't work with platform WebSockets API
webkit.org/b/200162 http/tests/websocket/tests/hybi/inspector/ [ Skip ]
-# Extensions not supported with platform WebSockets API
-webkit.org/b/199943 http/tests/websocket/tests/hybi/extensions.html [ Failure ]
-webkit.org/b/199943 http/tests/websocket/tests/hybi/deflate-frame-invalid-parameter.html [ Failure ]
-webkit.org/b/199943 http/tests/websocket/tests/hybi/deflate-frame-parameter.html [ Failure ]
-
# Server cookie not handled with platform WebSockets API
webkit.org/b/200165 imported/w3c/web-platform-tests/websockets/cookies/002.html [ Failure ]
webkit.org/b/200165 imported/w3c/web-platform-tests/websockets/cookies/007.html [ Failure ]
@@ -676,6 +671,15 @@
http/tests/contentextensions [ Pass ]
http/tests/inspector/network/contentextensions [ Pass ]
+# permessage-deflate WebSocket extension
+http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-comp-bit-onoff.html [ Pass ]
+http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-invalid-parameter.html [ Pass ]
+http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-parameter.html [ Pass ]
+http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-set-bfinal.html [ Pass ]
+http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-split-frames.html [ Pass ]
+http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-unsolicited-negotiation-response.html [ Pass ]
+http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-window-bits.html [ Pass ]
+
#////////////////////////////////////////////////////////////////////////////////////////
# 5. TESTS CRASHING
#////////////////////////////////////////////////////////////////////////////////////////
Added: trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/deflate-frame-invalid-parameter-expected.txt (0 => 248102)
--- trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/deflate-frame-invalid-parameter-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/deflate-frame-invalid-parameter-expected.txt 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,23 @@
+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
+
Added: trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/deflate-frame-parameter-expected.txt (0 => 248102)
--- trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/deflate-frame-parameter-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/deflate-frame-parameter-expected.txt 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,30 @@
+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"
+FAIL ws.extensions.search('x-webkit-deflate-frame') != -1 should be true. Was false.
+FAIL ws.extensions.search('max_window_bits=8') != -1 should be true. Was false.
+PASS event.data is firstMessage
+PASS event.data is secondMessage
+onclose() was called.
+PASS closeEvent.wasClean is true
+Testing query: "no_context_takeover"
+FAIL ws.extensions.search('x-webkit-deflate-frame') != -1 should be true. Was false.
+FAIL ws.extensions.search('no_context_takeover') != -1 should be true. Was false.
+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"
+FAIL ws.extensions.search('x-webkit-deflate-frame') != -1 should be true. Was false.
+FAIL ws.extensions.search('max_window_bits=8') != -1 should be true. Was false.
+FAIL ws.extensions.search('no_context_takeover') != -1 should be true. Was false.
+PASS event.data is firstMessage
+PASS event.data is secondMessage
+onclose() was called.
+PASS closeEvent.wasClean is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/extensions-expected.txt (0 => 248102)
--- trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/extensions-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/extensions-expected.txt 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,14 @@
+Test WebSocket.extensions attribute.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Check the value before opening the connection:
+PASS ws.extensions is ""
+Check if the value is read only:
+PASS ws.extensions = 'foo'; ws.extensions is ""
+Check the value after the connection is established:
+FAIL ws.extensions should be x-webkit-deflate-frame. Was permessage-deflate.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-comp-bit-onoff-expected.txt (0 => 248102)
--- trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-comp-bit-onoff-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-comp-bit-onoff-expected.txt 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,24 @@
+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: ""
+PASS event.data is ''
+Sending message: ""
+PASS event.data is ''
+Sending message: "Goodbye"
+PASS event.data is 'Goodbye'
+onclose() was called.
+PASS closeEvent.wasClean is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-invalid-parameter-expected.txt (0 => 248102)
--- trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-invalid-parameter-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-invalid-parameter-expected.txt 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,28 @@
+Test whether WebSocket rejects invalid permessage-deflate parameters.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Testing parameter: "x-foo"
+PASS onerror() was called
+onclose() was called.
+PASS closeEvent.wasClean is false
+Testing parameter: "client_max_window_bits=7"
+PASS onerror() was called
+onclose() was called.
+PASS closeEvent.wasClean is false
+Testing parameter: "client_max_window_bits=16"
+PASS onerror() was called
+onclose() was called.
+PASS closeEvent.wasClean is false
+Testing parameter: "client_no_context_takeover=foo"
+PASS onerror() was called
+onclose() was called.
+PASS closeEvent.wasClean is false
+Testing parameter: "client_max_window_bits=8; client_no_context_takeover; x-foo"
+PASS onerror() was called
+onclose() was called.
+PASS closeEvent.wasClean is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-parameter-expected.txt (0 => 248102)
--- trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-parameter-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-parameter-expected.txt 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,30 @@
+Test WebSocket permessage-deflate extension.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Testing query: "client_max_window_bits=8"
+PASS ws.extensions.search('permessage-deflate') != -1 is true
+PASS ws.extensions.search('client_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: "client_no_context_takeover"
+PASS ws.extensions.search('permessage-deflate') != -1 is true
+PASS ws.extensions.search('client_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: "client_max_window_bits=8&client_no_context_takeover"
+PASS ws.extensions.search('permessage-deflate') != -1 is true
+PASS ws.extensions.search('client_max_window_bits=8') != -1 is true
+PASS ws.extensions.search('client_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
+
Added: trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-set-bfinal-expected.txt (0 => 248102)
--- trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-set-bfinal-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-set-bfinal-expected.txt 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,16 @@
+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
+
Added: trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-split-frames-expected.txt (0 => 248102)
--- trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-split-frames-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-split-frames-expected.txt 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,11 @@
+Deflated message is split to multiple frames.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+onmessage: HelloHello
+onclose
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-unsolicited-negotiation-response-expected.txt (0 => 248102)
--- trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-unsolicited-negotiation-response-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-unsolicited-negotiation-response-expected.txt 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,12 @@
+Test whether WebSocket ignores unsolicited negotiation response.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS onopen
+FAIL ws.extensions should be permessage-deflate; server_max_window_bits=15; server_no_context_takeover. Was permessage-deflate; server_no_context_takeover; server_max_window_bits=15.
+PASS event.wasClean is true
+PASS successfullyParsed is true
+Some tests failed.
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-window-bits-expected.txt (0 => 248102)
--- trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-window-bits-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/wpe/http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-window-bits-expected.txt 2019-08-01 14:21:26 UTC (rev 248102)
@@ -0,0 +1,33 @@
+Test WebSocket permessage-deflate extension: window bits.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Testing query: "client_max_window_bits=8"
+PASS ws.extensions.search('permessage-deflate') != -1 is true
+PASS ws.extensions.search('client_max_window_bits=8') != -1 is true
+PASS event.data is message
+onclose() was called.
+PASS closeEvent.wasClean is true
+Testing query: "client_max_window_bits=15"
+PASS ws.extensions.search('permessage-deflate') != -1 is true
+PASS ws.extensions.search('client_max_window_bits=15') != -1 is true
+PASS event.data is message
+onclose() was called.
+PASS closeEvent.wasClean is true
+Testing query: "client_no_context_takeover"
+PASS ws.extensions.search('permessage-deflate') != -1 is true
+PASS ws.extensions.search('client_no_context_takeover') != -1 is true
+PASS event.data is message
+onclose() was called.
+PASS closeEvent.wasClean is true
+Testing query: "client_max_window_bits=8&client_no_context_takeover"
+PASS ws.extensions.search('permessage-deflate') != -1 is true
+PASS ws.extensions.search('client_max_window_bits=8') != -1 is true
+PASS ws.extensions.search('client_no_context_takeover') != -1 is true
+PASS event.data is message
+onclose() was called.
+PASS closeEvent.wasClean is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Modified: trunk/Source/WebCore/ChangeLog (248101 => 248102)
--- trunk/Source/WebCore/ChangeLog 2019-08-01 14:05:13 UTC (rev 248101)
+++ trunk/Source/WebCore/ChangeLog 2019-08-01 14:21:26 UTC (rev 248102)
@@ -1,3 +1,23 @@
+2019-08-01 Carlos Garcia Campos <cgar...@igalia.com>
+
+ [SOUP] WebSockets: add support for extensions when using web sockets libsoup API
+ https://bugs.webkit.org/show_bug.cgi?id=199943
+
+ Reviewed by Alex Christensen.
+
+ Add SOUP_TYPE_WEBSOCKET_EXTENSION_MANAGER feature to the soup session to enable WebSocket extensions.
+
+ Tests: http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-comp-bit-onoff.html
+ http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-invalid-parameter.html
+ http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-parameter.html
+ http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-set-bfinal.html
+ http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-split-frames.html
+ http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-unsolicited-negotiation-response.html
+ http/tests/websocket/tests/hybi/imported/blink/permessage-deflate-window-bits.html
+
+ * platform/network/soup/SoupNetworkSession.cpp:
+ (WebCore::SoupNetworkSession::SoupNetworkSession):
+
2019-08-01 Chris Dumez <cdu...@apple.com>
[iOS][WK1] Unsafe unsafe of WeakPtr<Document> from UIThread under PlaybackSessionInterfaceAVKit::PlaybackSessionInterfaceAVKit()
Modified: trunk/Source/WebCore/platform/network/soup/SoupNetworkSession.cpp (248101 => 248102)
--- trunk/Source/WebCore/platform/network/soup/SoupNetworkSession.cpp 2019-08-01 14:05:13 UTC (rev 248101)
+++ trunk/Source/WebCore/platform/network/soup/SoupNetworkSession.cpp 2019-08-01 14:21:26 UTC (rev 248102)
@@ -122,6 +122,9 @@
SOUP_SESSION_TIMEOUT, 0,
SOUP_SESSION_IDLE_TIMEOUT, 0,
SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_CONTENT_SNIFFER,
+#if SOUP_CHECK_VERSION(2, 67, 90)
+ SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_WEBSOCKET_EXTENSION_MANAGER,
+#endif
nullptr);
setupCustomProtocols();
Modified: trunk/Source/WebKit/ChangeLog (248101 => 248102)
--- trunk/Source/WebKit/ChangeLog 2019-08-01 14:05:13 UTC (rev 248101)
+++ trunk/Source/WebKit/ChangeLog 2019-08-01 14:21:26 UTC (rev 248102)
@@ -1,5 +1,27 @@
2019-08-01 Carlos Garcia Campos <cgar...@igalia.com>
+ [SOUP] WebSockets: add support for extensions when using web sockets libsoup API
+ https://bugs.webkit.org/show_bug.cgi?id=199943
+
+ Reviewed by Alex Christensen.
+
+ * NetworkProcess/NetworkSocketChannel.cpp:
+ (WebKit::NetworkSocketChannel::didConnect): Add extensions parameter and pass it to the IPC message.
+ * NetworkProcess/NetworkSocketChannel.h:
+ * NetworkProcess/cocoa/WebSocketTaskCocoa.mm:
+ (WebKit::WebSocketTask::didConnect): Pass empty extensions string.
+ * NetworkProcess/soup/WebSocketTaskSoup.cpp:
+ (WebKit::WebSocketTask::acceptedExtensions const): Build the accepted extensions string.
+ (WebKit::WebSocketTask::didConnect): Pass accepted extensions to NetworkSocketChannel::didConnect().
+ * NetworkProcess/soup/WebSocketTaskSoup.h:
+ * WebProcess/Network/WebSocketChannel.cpp:
+ (WebKit::WebSocketChannel::extensions): Return the extensions string received from the network process.
+ (WebKit::WebSocketChannel::didConnect): Save the extensions string.
+ * WebProcess/Network/WebSocketChannel.h:
+ * WebProcess/Network/WebSocketChannel.messages.in:
+
+2019-08-01 Carlos Garcia Campos <cgar...@igalia.com>
+
[SOUP] Switch to use libsoup WebSockets API
https://bugs.webkit.org/show_bug.cgi?id=200162
Modified: trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.cpp (248101 => 248102)
--- trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.cpp 2019-08-01 14:05:13 UTC (rev 248101)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.cpp 2019-08-01 14:21:26 UTC (rev 248102)
@@ -97,9 +97,9 @@
finishClosingIfPossible();
}
-void NetworkSocketChannel::didConnect(const String& subprotocol)
+void NetworkSocketChannel::didConnect(const String& subprotocol, const String& extensions)
{
- send(Messages::WebSocketChannel::DidConnect { subprotocol });
+ send(Messages::WebSocketChannel::DidConnect { subprotocol, extensions });
}
void NetworkSocketChannel::didReceiveText(const String& text)
Modified: trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.h (248101 => 248102)
--- trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.h 2019-08-01 14:05:13 UTC (rev 248101)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.h 2019-08-01 14:21:26 UTC (rev 248102)
@@ -59,7 +59,7 @@
friend class WebSocketTask;
private:
- void didConnect(const String& subprotocol);
+ void didConnect(const String& subprotocol, const String& extensions);
void didReceiveText(const String&);
void didReceiveBinaryData(const uint8_t* data, size_t length);
void didClose(unsigned short code, const String& reason);
Modified: trunk/Source/WebKit/NetworkProcess/cocoa/WebSocketTaskCocoa.mm (248101 => 248102)
--- trunk/Source/WebKit/NetworkProcess/cocoa/WebSocketTaskCocoa.mm 2019-08-01 14:05:13 UTC (rev 248101)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/WebSocketTaskCocoa.mm 2019-08-01 14:21:26 UTC (rev 248102)
@@ -84,7 +84,8 @@
void WebSocketTask::didConnect(const String& protocol)
{
- m_channel.didConnect(protocol);
+ // FIXME: support extensions.
+ m_channel.didConnect(protocol, { });
}
void WebSocketTask::didClose(unsigned short code, const String& reason)
Modified: trunk/Source/WebKit/NetworkProcess/soup/WebSocketTaskSoup.cpp (248101 => 248102)
--- trunk/Source/WebKit/NetworkProcess/soup/WebSocketTaskSoup.cpp 2019-08-01 14:05:13 UTC (rev 248101)
+++ trunk/Source/WebKit/NetworkProcess/soup/WebSocketTaskSoup.cpp 2019-08-01 14:21:26 UTC (rev 248102)
@@ -30,6 +30,7 @@
#include "NetworkSocketChannel.h"
#include <WebCore/HTTPParsers.h>
#include <wtf/glib/GUniquePtr.h>
+#include <wtf/text/StringBuilder.h>
namespace WebKit {
@@ -64,6 +65,28 @@
cancel();
}
+String WebSocketTask::acceptedExtensions() const
+{
+#if SOUP_CHECK_VERSION(2, 67, 90)
+ StringBuilder result;
+ GList* extensions = soup_websocket_connection_get_extensions(m_connection.get());
+ for (auto* it = extensions; it; it = g_list_next(it)) {
+ auto* extension = SOUP_WEBSOCKET_EXTENSION(it->data);
+
+ if (!result.isEmpty())
+ result.appendLiteral(", ");
+ result.append(String::fromUTF8(SOUP_WEBSOCKET_EXTENSION_GET_CLASS(extension)->name));
+
+ GUniquePtr<char> params(soup_websocket_extension_get_response_params(extension));
+ if (params)
+ result.append(String::fromUTF8(params.get()));
+ }
+ return result.toStringPreserveCapacity();
+#else
+ return { };
+#endif
+}
+
void WebSocketTask::didConnect(GRefPtr<SoupWebsocketConnection>&& connection)
{
m_connection = WTFMove(connection);
@@ -78,7 +101,7 @@
g_signal_connect_swapped(m_connection.get(), "error", reinterpret_cast<GCallback>(didReceiveErrorCallback), this);
g_signal_connect_swapped(m_connection.get(), "closed", reinterpret_cast<GCallback>(didCloseCallback), this);
- m_channel.didConnect(soup_websocket_connection_get_protocol(m_connection.get()));
+ m_channel.didConnect(soup_websocket_connection_get_protocol(m_connection.get()), acceptedExtensions());
}
void WebSocketTask::didReceiveMessageCallback(WebSocketTask* task, SoupWebsocketDataType dataType, GBytes* message)
Modified: trunk/Source/WebKit/NetworkProcess/soup/WebSocketTaskSoup.h (248101 => 248102)
--- trunk/Source/WebKit/NetworkProcess/soup/WebSocketTaskSoup.h 2019-08-01 14:05:13 UTC (rev 248101)
+++ trunk/Source/WebKit/NetworkProcess/soup/WebSocketTaskSoup.h 2019-08-01 14:21:26 UTC (rev 248102)
@@ -52,6 +52,8 @@
void didFail(const String&);
void didClose(unsigned short code, const String& reason);
+ String acceptedExtensions() const;
+
static void didReceiveMessageCallback(WebSocketTask*, SoupWebsocketDataType, GBytes*);
static void didReceiveErrorCallback(WebSocketTask*, GError*);
static void didCloseCallback(WebSocketTask*);
Modified: trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp (248101 => 248102)
--- trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp 2019-08-01 14:05:13 UTC (rev 248101)
+++ trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp 2019-08-01 14:21:26 UTC (rev 248102)
@@ -76,8 +76,7 @@
String WebSocketChannel::extensions()
{
- // FIXME: support extensions.
- return emptyString();
+ return m_extensions.isNull() ? emptyString() : m_extensions;
}
WebSocketChannel::ConnectStatus WebSocketChannel::connect(const URL& url, const String& protocol)
@@ -322,7 +321,7 @@
MessageSender::send(Messages::NetworkSocketChannel::Close { 0, { } });
}
-void WebSocketChannel::didConnect(String&& subprotocol)
+void WebSocketChannel::didConnect(String&& subprotocol, String&& extensions)
{
if (m_isClosing)
return;
@@ -331,13 +330,14 @@
return;
if (m_isSuspended) {
- enqueueTask([this, subprotocol = WTFMove(subprotocol)] () mutable {
- didConnect(WTFMove(subprotocol));
+ enqueueTask([this, subprotocol = WTFMove(subprotocol), extensions = WTFMove(extensions)] () mutable {
+ didConnect(WTFMove(subprotocol), WTFMove(extensions));
});
return;
}
m_subprotocol = WTFMove(subprotocol);
+ m_extensions = WTFMove(extensions);
m_client->didConnect();
}
Modified: trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.h (248101 => 248102)
--- trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.h 2019-08-01 14:05:13 UTC (rev 248101)
+++ trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.h 2019-08-01 14:21:26 UTC (rev 248102)
@@ -75,7 +75,7 @@
void derefThreadableWebSocketChannel() final { deref(); }
// Message receivers
- void didConnect(String&&);
+ void didConnect(String&& subprotocol, String&& extensions);
void didReceiveText(String&&);
void didReceiveBinaryData(IPC::DataReference&&);
void didClose(unsigned short code, String&&);
@@ -93,6 +93,7 @@
WeakPtr<WebCore::Document> m_document;
WeakPtr<WebCore::WebSocketChannelClient> m_client;
String m_subprotocol;
+ String m_extensions;
size_t m_bufferedAmount { 0 };
bool m_isClosing { false };
bool m_isSuspended { false };
Modified: trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.messages.in (248101 => 248102)
--- trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.messages.in 2019-08-01 14:05:13 UTC (rev 248101)
+++ trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.messages.in 2019-08-01 14:21:26 UTC (rev 248102)
@@ -21,7 +21,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
messages -> WebSocketChannel {
- DidConnect(String subprotocol)
+ DidConnect(String subprotocol, String extensions)
DidClose(unsigned short code, String reason)
DidReceiveText(String message)
DidReceiveBinaryData(IPC::DataReference data)