Title: [266057] trunk
Revision
266057
Author
you...@apple.com
Date
2020-08-24 07:57:58 -0700 (Mon, 24 Aug 2020)

Log Message

Cocoa WebSocketTask should expose WebSocket server extensions
https://bugs.webkit.org/show_bug.cgi?id=215696

Reviewed by Darin Adler.

Source/WebKit:

Send back to WebProcess the value of server WebSocket extensions.

* NetworkProcess/cocoa/WebSocketTaskCocoa.mm:
(WebKit::WebSocketTask::didConnect):

LayoutTests:

Make the tests agnostic of using the legacy or standard deflate extension.
If using the standard deflate extensions, do not expect subparameters (this matches Chrome, Firefox and NSURLSession code path).

* http/tests/websocket/tests/hybi/deflate-frame-parameter-expected.txt:
* http/tests/websocket/tests/hybi/deflate-frame-parameter.html:
* http/tests/websocket/tests/hybi/extensions-expected.txt:
* http/tests/websocket/tests/hybi/extensions.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (266056 => 266057)


--- trunk/LayoutTests/ChangeLog	2020-08-24 14:50:31 UTC (rev 266056)
+++ trunk/LayoutTests/ChangeLog	2020-08-24 14:57:58 UTC (rev 266057)
@@ -1,3 +1,18 @@
+2020-08-24  Youenn Fablet  <you...@apple.com>
+
+        Cocoa WebSocketTask should expose WebSocket server extensions
+        https://bugs.webkit.org/show_bug.cgi?id=215696
+
+        Reviewed by Darin Adler.
+
+        Make the tests agnostic of using the legacy or standard deflate extension.
+        If using the standard deflate extensions, do not expect subparameters (this matches Chrome, Firefox and NSURLSession code path).
+
+        * http/tests/websocket/tests/hybi/deflate-frame-parameter-expected.txt:
+        * http/tests/websocket/tests/hybi/deflate-frame-parameter.html:
+        * http/tests/websocket/tests/hybi/extensions-expected.txt:
+        * http/tests/websocket/tests/hybi/extensions.html:
+
 2020-08-24  Rob Buis  <rb...@igalia.com>
 
         Make window.find not default the search string to undefined

Modified: trunk/LayoutTests/http/tests/websocket/tests/hybi/deflate-frame-parameter-expected.txt (266056 => 266057)


--- trunk/LayoutTests/http/tests/websocket/tests/hybi/deflate-frame-parameter-expected.txt	2020-08-24 14:50:31 UTC (rev 266056)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/deflate-frame-parameter-expected.txt	2020-08-24 14:57:58 UTC (rev 266057)
@@ -3,23 +3,19 @@
 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 testResult 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 testResult 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 testResult is true
 PASS event.data is firstMessage
 PASS event.data is secondMessage
 onclose() was called.

Modified: trunk/LayoutTests/http/tests/websocket/tests/hybi/deflate-frame-parameter.html (266056 => 266057)


--- trunk/LayoutTests/http/tests/websocket/tests/hybi/deflate-frame-parameter.html	2020-08-24 14:50:31 UTC (rev 266056)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/deflate-frame-parameter.html	2020-08-24 14:57:58 UTC (rev 266057)
@@ -38,6 +38,7 @@
     secondMessage += 'a';
 }
 
+let testResult;
 function doTest(queryIndex)
 {
     var query = queries[queryIndex];
@@ -49,10 +50,15 @@
 
     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");
+        const isUsingLegacyExtension = ws.extensions.search('x-webkit-deflate-frame') != -1;
+        if (isUsingLegacyExtension) {
+            testResult = true;
+            parameters = query.split('&');
+            for (var i = 0; i < parameters.length; ++i)
+                testResult = testResult && (ws.extensions.search(parameters[i]) != -1);
+        } else
+            testResult = ws.extensions.search('permessage-deflate') != -1;
+        shouldBeTrue('testResult');
         ws.send(firstMessage);
     };
 

Modified: trunk/LayoutTests/http/tests/websocket/tests/hybi/extensions-expected.txt (266056 => 266057)


--- trunk/LayoutTests/http/tests/websocket/tests/hybi/extensions-expected.txt	2020-08-24 14:50:31 UTC (rev 266056)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/extensions-expected.txt	2020-08-24 14:57:58 UTC (rev 266057)
@@ -7,7 +7,7 @@
 Check if the value is read only:
 PASS ws.extensions = 'foo'; ws.extensions is ""
 Check the value after the connection is established:
-PASS ws.extensions is "x-webkit-deflate-frame"
+PASS hasDeflateExtension is true
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/http/tests/websocket/tests/hybi/extensions.html (266056 => 266057)


--- trunk/LayoutTests/http/tests/websocket/tests/hybi/extensions.html	2020-08-24 14:50:31 UTC (rev 266056)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/extensions.html	2020-08-24 14:57:58 UTC (rev 266057)
@@ -19,10 +19,12 @@
 debug("Check if the value is read only:");
 shouldBeEqualToString("ws.extensions = 'foo'; ws.extensions", "");
 
+let hasDeflateExtension;
 ws._onopen_ = function(event)
 {
     debug("Check the value after the connection is established:");
-    shouldBeEqualToString("ws.extensions", "x-webkit-deflate-frame");
+    hasDeflateExtension = ws.extensions === "x-webkit-deflate-frame" || ws.extensions === "permessage-deflate"
+    shouldBeTrue("hasDeflateExtension");
     finishJSTest();
 };
 

Modified: trunk/Source/WebKit/ChangeLog (266056 => 266057)


--- trunk/Source/WebKit/ChangeLog	2020-08-24 14:50:31 UTC (rev 266056)
+++ trunk/Source/WebKit/ChangeLog	2020-08-24 14:57:58 UTC (rev 266057)
@@ -1,3 +1,15 @@
+2020-08-24  Youenn Fablet  <you...@apple.com>
+
+        Cocoa WebSocketTask should expose WebSocket server extensions
+        https://bugs.webkit.org/show_bug.cgi?id=215696
+
+        Reviewed by Darin Adler.
+
+        Send back to WebProcess the value of server WebSocket extensions.
+
+        * NetworkProcess/cocoa/WebSocketTaskCocoa.mm:
+        (WebKit::WebSocketTask::didConnect):
+
 2020-08-24  Carlos Garcia Campos  <cgar...@igalia.com>
 
         Unreviewed. Fix GTK4 build

Modified: trunk/Source/WebKit/NetworkProcess/cocoa/WebSocketTaskCocoa.mm (266056 => 266057)


--- trunk/Source/WebKit/NetworkProcess/cocoa/WebSocketTaskCocoa.mm	2020-08-24 14:50:31 UTC (rev 266056)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/WebSocketTaskCocoa.mm	2020-08-24 14:57:58 UTC (rev 266057)
@@ -95,9 +95,13 @@
 
 void WebSocketTask::didConnect(const String& protocol)
 {
-    // FIXME: support extensions.
+    String extensionsValue;
+    auto response = [m_task response];
+    if ([response isKindOfClass:[NSHTTPURLResponse class]])
+        extensionsValue = [(NSHTTPURLResponse *)response valueForHTTPHeaderField:@"Sec-WebSocket-Extensions"];
+
     m_receivedDidConnect = true;
-    m_channel.didConnect(protocol, { });
+    m_channel.didConnect(protocol, extensionsValue);
     m_channel.didReceiveHandshakeResponse(ResourceResponse { [m_task response] });
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to