<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[287611] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/287611">287611</a></dd>
<dt>Author</dt> <dd>youenn@apple.com</dd>
<dt>Date</dt> <dd>2022-01-05 02:35:47 -0800 (Wed, 05 Jan 2022)</dd>
</dl>

<h3>Log Message</h3>
<pre>Make sure secure websocket connections in service workers can trigger authentication challenge callbacks
https://bugs.webkit.org/show_bug.cgi?id=234809
<rdar://85888177>

Reviewed by Chris Dumez.

Source/WebCore:

* dom/Document.h:

Source/WebKit:

In case we are not using fast server trust evaluation, we are going to the UIProcess to check certificates.
This is an issue for web socket loads triggered for service workers that have an invalid certificate.
Before the patch, the challenge was not provided a top origin, so the default action would be triggered by UIProcess.
To make sure this is working as expected, we now always pass the origin if it is the same as the top origin for web socket challenges.
This makes sure we get a page with the same top origin and the challenge callback is called on the page.

Covered by updated tests.

* NetworkProcess/NetworkConnectionToWebProcess.cpp:
* NetworkProcess/NetworkConnectionToWebProcess.h:
* NetworkProcess/NetworkConnectionToWebProcess.messages.in:
* NetworkProcess/NetworkSession.cpp:
* NetworkProcess/NetworkSession.h:
* NetworkProcess/NetworkSocketChannel.cpp:
* NetworkProcess/NetworkSocketChannel.h:
* NetworkProcess/cocoa/NetworkSessionCocoa.h:
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
* NetworkProcess/cocoa/WebSocketTaskCocoa.h:
* NetworkProcess/cocoa/WebSocketTaskCocoa.mm:
* NetworkProcess/soup/NetworkSessionSoup.cpp:
* NetworkProcess/soup/NetworkSessionSoup.h:
* WebProcess/Network/WebSocketChannel.cpp:

LayoutTests:

* http/tests/workers/service/serviceworker-websocket.https-expected.txt:
* http/tests/workers/service/serviceworker-websocket.https.html:
* platform/gtk/http/tests/workers/service/serviceworker-websocket.https-expected.txt: Copied from LayoutTests/http/tests/workers/service/serviceworker-websocket.https-expected.txt.
* platform/ios-wk2/http/tests/workers/service/serviceworker-websocket.https-expected.txt: Removed.
* platform/mac-bigsur-wk2/http/tests/workers/service/serviceworker-websocket.https-expected.txt: Copied from LayoutTests/http/tests/workers/service/serviceworker-websocket.https-expected.txt.
* platform/mac-catalina-wk2/http/tests/workers/service/serviceworker-websocket.https-expected.txt: Copied from LayoutTests/http/tests/workers/service/serviceworker-websocket.https-expected.txt.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestshttptestsworkersserviceserviceworkerwebsockethttpsexpectedtxt">trunk/LayoutTests/http/tests/workers/service/serviceworker-websocket.https-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestsworkersserviceserviceworkerwebsockethttpshtml">trunk/LayoutTests/http/tests/workers/service/serviceworker-websocket.https.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomDocumenth">trunk/Source/WebCore/dom/Document.h</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessNetworkConnectionToWebProcesscpp">trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessNetworkConnectionToWebProcessh">trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessNetworkConnectionToWebProcessmessagesin">trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessNetworkSessioncpp">trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessNetworkSessionh">trunk/Source/WebKit/NetworkProcess/NetworkSession.h</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessNetworkSocketChannelcpp">trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.cpp</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessNetworkSocketChannelh">trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.h</a></li>
<li><a href="#trunkSourceWebKitNetworkProcesscocoaNetworkSessionCocoah">trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h</a></li>
<li><a href="#trunkSourceWebKitNetworkProcesscocoaNetworkSessionCocoamm">trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm</a></li>
<li><a href="#trunkSourceWebKitNetworkProcesscocoaWebSocketTaskCocoah">trunk/Source/WebKit/NetworkProcess/cocoa/WebSocketTaskCocoa.h</a></li>
<li><a href="#trunkSourceWebKitNetworkProcesscocoaWebSocketTaskCocoamm">trunk/Source/WebKit/NetworkProcess/cocoa/WebSocketTaskCocoa.mm</a></li>
<li><a href="#trunkSourceWebKitNetworkProcesssoupNetworkSessionSoupcpp">trunk/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.cpp</a></li>
<li><a href="#trunkSourceWebKitNetworkProcesssoupNetworkSessionSouph">trunk/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessNetworkWebSocketChannelcpp">trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/LayoutTests/platform/gtk/http/tests/workers/</li>
<li>trunk/LayoutTests/platform/gtk/http/tests/workers/service/</li>
<li><a href="#trunkLayoutTestsplatformgtkhttptestsworkersserviceserviceworkerwebsockethttpsexpectedtxt">trunk/LayoutTests/platform/gtk/http/tests/workers/service/serviceworker-websocket.https-expected.txt</a></li>
<li>trunk/LayoutTests/platform/mac-bigsur-wk2/http/tests/workers/</li>
<li>trunk/LayoutTests/platform/mac-bigsur-wk2/http/tests/workers/service/</li>
<li><a href="#trunkLayoutTestsplatformmacbigsurwk2httptestsworkersserviceserviceworkerwebsockethttpsexpectedtxt">trunk/LayoutTests/platform/mac-bigsur-wk2/http/tests/workers/service/serviceworker-websocket.https-expected.txt</a></li>
<li>trunk/LayoutTests/platform/mac-catalina-wk2/http/tests/workers/</li>
<li>trunk/LayoutTests/platform/mac-catalina-wk2/http/tests/workers/service/</li>
<li><a href="#trunkLayoutTestsplatformmaccatalinawk2httptestsworkersserviceserviceworkerwebsockethttpsexpectedtxt">trunk/LayoutTests/platform/mac-catalina-wk2/http/tests/workers/service/serviceworker-websocket.https-expected.txt</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li>trunk/LayoutTests/platform/ios-14-wk2/http/tests/workers/</li>
<li>trunk/LayoutTests/platform/ios-wk2/http/tests/workers/</li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (287610 => 287611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2022-01-05 10:01:06 UTC (rev 287610)
+++ trunk/LayoutTests/ChangeLog 2022-01-05 10:35:47 UTC (rev 287611)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2022-01-05  Youenn Fablet  <youenn@apple.com>
+
+        Make sure secure websocket connections in service workers can trigger authentication challenge callbacks
+        https://bugs.webkit.org/show_bug.cgi?id=234809
+        <rdar://85888177>
+
+        Reviewed by Chris Dumez.
+
+        * http/tests/workers/service/serviceworker-websocket.https-expected.txt:
+        * http/tests/workers/service/serviceworker-websocket.https.html:
+        * platform/gtk/http/tests/workers/service/serviceworker-websocket.https-expected.txt: Copied from LayoutTests/http/tests/workers/service/serviceworker-websocket.https-expected.txt.
+        * platform/ios-wk2/http/tests/workers/service/serviceworker-websocket.https-expected.txt: Removed.
+        * platform/mac-bigsur-wk2/http/tests/workers/service/serviceworker-websocket.https-expected.txt: Copied from LayoutTests/http/tests/workers/service/serviceworker-websocket.https-expected.txt.
+        * platform/mac-catalina-wk2/http/tests/workers/service/serviceworker-websocket.https-expected.txt: Copied from LayoutTests/http/tests/workers/service/serviceworker-websocket.https-expected.txt.
+
</ins><span class="cx"> 2022-01-05  Martin Robinson  <mrobinson@webkit.org>
</span><span class="cx"> 
</span><span class="cx">         Change offsetParent to match spec change
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsworkersserviceserviceworkerwebsockethttpsexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/workers/service/serviceworker-websocket.https-expected.txt (287610 => 287611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/workers/service/serviceworker-websocket.https-expected.txt  2022-01-05 10:01:06 UTC (rev 287610)
+++ trunk/LayoutTests/http/tests/workers/service/serviceworker-websocket.https-expected.txt     2022-01-05 10:35:47 UTC (rev 287611)
</span><span class="lines">@@ -1,3 +1,4 @@
</span><ins>+canAuthenticateAgainstProtectionSpace
</ins><span class="cx"> 
</span><span class="cx"> PASS Setup worker
</span><span class="cx"> PASS Open a WebSocket in service worker
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsworkersserviceserviceworkerwebsockethttpshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/workers/service/serviceworker-websocket.https.html (287610 => 287611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/workers/service/serviceworker-websocket.https.html  2022-01-05 10:01:06 UTC (rev 287610)
+++ trunk/LayoutTests/http/tests/workers/service/serviceworker-websocket.https.html     2022-01-05 10:35:47 UTC (rev 287611)
</span><span class="lines">@@ -30,6 +30,9 @@
</span><span class="cx"> }, "Setup worker");
</span><span class="cx"> 
</span><span class="cx"> promise_test(async (test) => {
</span><ins>+    if (window.testRunner)
+        testRunner.setShouldLogCanAuthenticateAgainstProtectionSpace(true);
+
</ins><span class="cx">     var promise = new Promise((resolve, reject) => {
</span><span class="cx">         navigator.serviceWorker.addEventListener("message", test.step_func((event) => {
</span><span class="cx">             if (event.data === "PASS") {
</span><span class="lines">@@ -42,6 +45,9 @@
</span><span class="cx"> 
</span><span class="cx">     activeWorker.postMessage("WEBSOCKET-1");
</span><span class="cx">     await promise;
</span><ins>+
+    if (window.testRunner)
+        testRunner.setShouldLogCanAuthenticateAgainstProtectionSpace(false);
</ins><span class="cx"> }, "Open a WebSocket in service worker");
</span><span class="cx"> </script>
</span><span class="cx"> </body>
</span></span></pre></div>
<a id="trunkLayoutTestsplatformgtkhttptestsworkersserviceserviceworkerwebsockethttpsexpectedtxtfromrev287610trunkLayoutTestsplatformios14wk2httptestsworkersserviceserviceworkerwebsockethttpsexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/platform/gtk/http/tests/workers/service/serviceworker-websocket.https-expected.txt (from rev 287610, trunk/LayoutTests/platform/ios-14-wk2/http/tests/workers/service/serviceworker-websocket.https-expected.txt) (0 => 287611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/gtk/http/tests/workers/service/serviceworker-websocket.https-expected.txt                             (rev 0)
+++ trunk/LayoutTests/platform/gtk/http/tests/workers/service/serviceworker-websocket.https-expected.txt        2022-01-05 10:35:47 UTC (rev 287611)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+
+PASS Setup worker
+PASS Open a WebSocket in service worker
+
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacbigsurwk2httptestsworkersserviceserviceworkerwebsockethttpsexpectedtxtfromrev287610trunkLayoutTestshttptestsworkersserviceserviceworkerwebsockethttpsexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/platform/mac-bigsur-wk2/http/tests/workers/service/serviceworker-websocket.https-expected.txt (from rev 287610, trunk/LayoutTests/http/tests/workers/service/serviceworker-websocket.https-expected.txt) (0 => 287611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-bigsur-wk2/http/tests/workers/service/serviceworker-websocket.https-expected.txt                          (rev 0)
+++ trunk/LayoutTests/platform/mac-bigsur-wk2/http/tests/workers/service/serviceworker-websocket.https-expected.txt     2022-01-05 10:35:47 UTC (rev 287611)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+
+PASS Setup worker
+PASS Open a WebSocket in service worker
+
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmaccatalinawk2httptestsworkersserviceserviceworkerwebsockethttpsexpectedtxtfromrev287610trunkLayoutTestshttptestsworkersserviceserviceworkerwebsockethttpsexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/platform/mac-catalina-wk2/http/tests/workers/service/serviceworker-websocket.https-expected.txt (from rev 287610, trunk/LayoutTests/http/tests/workers/service/serviceworker-websocket.https-expected.txt) (0 => 287611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-catalina-wk2/http/tests/workers/service/serviceworker-websocket.https-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/mac-catalina-wk2/http/tests/workers/service/serviceworker-websocket.https-expected.txt   2022-01-05 10:35:47 UTC (rev 287611)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+
+PASS Setup worker
+PASS Open a WebSocket in service worker
+
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (287610 => 287611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2022-01-05 10:01:06 UTC (rev 287610)
+++ trunk/Source/WebCore/ChangeLog      2022-01-05 10:35:47 UTC (rev 287611)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2022-01-05  Youenn Fablet  <youenn@apple.com>
+
+        Make sure secure websocket connections in service workers can trigger authentication challenge callbacks
+        https://bugs.webkit.org/show_bug.cgi?id=234809
+        <rdar://85888177>
+
+        Reviewed by Chris Dumez.
+
+        * dom/Document.h:
+
</ins><span class="cx"> 2022-01-05  Martin Robinson  <mrobinson@webkit.org>
</span><span class="cx"> 
</span><span class="cx">         Change offsetParent to match spec change
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumenth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.h (287610 => 287611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.h      2022-01-05 10:01:06 UTC (rev 287610)
+++ trunk/Source/WebCore/dom/Document.h 2022-01-05 10:35:47 UTC (rev 287611)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include "CSSRegisteredCustomProperty.h"
</span><span class="cx"> #include "CanvasBase.h"
</span><ins>+#include "ClientOrigin.h"
</ins><span class="cx"> #include "Color.h"
</span><span class="cx"> #include "ContainerNode.h"
</span><span class="cx"> #include "CrossOriginOpenerPolicy.h"
</span><span class="lines">@@ -49,6 +50,7 @@
</span><span class="cx"> #include "RegistrableDomain.h"
</span><span class="cx"> #include "RenderPtr.h"
</span><span class="cx"> #include "ScriptExecutionContext.h"
</span><ins>+#include "SecurityOrigin.h"
</ins><span class="cx"> #include "StringWithDirection.h"
</span><span class="cx"> #include "Supplementable.h"
</span><span class="cx"> #include "Timer.h"
</span><span class="lines">@@ -1382,6 +1384,7 @@
</span><span class="cx"> 
</span><span class="cx">     SecurityOrigin& securityOrigin() const { return *SecurityContext::securityOrigin(); }
</span><span class="cx">     SecurityOrigin& topOrigin() const final { return topDocument().securityOrigin(); }
</span><ins>+    ClientOrigin clientOrigin() const { return { topOrigin().data(), securityOrigin().data() }; }
</ins><span class="cx"> 
</span><span class="cx">     inline bool isSameOriginAsTopDocument() const;
</span><span class="cx">     bool shouldForceNoOpenerBasedOnCOOP() const;
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (287610 => 287611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2022-01-05 10:01:06 UTC (rev 287610)
+++ trunk/Source/WebKit/ChangeLog       2022-01-05 10:35:47 UTC (rev 287611)
</span><span class="lines">@@ -1,5 +1,36 @@
</span><span class="cx"> 2022-01-05  Youenn Fablet  <youenn@apple.com>
</span><span class="cx"> 
</span><ins>+        Make sure secure websocket connections in service workers can trigger authentication challenge callbacks
+        https://bugs.webkit.org/show_bug.cgi?id=234809
+        <rdar://85888177>
+
+        Reviewed by Chris Dumez.
+
+        In case we are not using fast server trust evaluation, we are going to the UIProcess to check certificates.
+        This is an issue for web socket loads triggered for service workers that have an invalid certificate.
+        Before the patch, the challenge was not provided a top origin, so the default action would be triggered by UIProcess.
+        To make sure this is working as expected, we now always pass the origin if it is the same as the top origin for web socket challenges.
+        This makes sure we get a page with the same top origin and the challenge callback is called on the page.
+
+        Covered by updated tests.
+
+        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+        * NetworkProcess/NetworkConnectionToWebProcess.h:
+        * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
+        * NetworkProcess/NetworkSession.cpp:
+        * NetworkProcess/NetworkSession.h:
+        * NetworkProcess/NetworkSocketChannel.cpp:
+        * NetworkProcess/NetworkSocketChannel.h:
+        * NetworkProcess/cocoa/NetworkSessionCocoa.h:
+        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+        * NetworkProcess/cocoa/WebSocketTaskCocoa.h:
+        * NetworkProcess/cocoa/WebSocketTaskCocoa.mm:
+        * NetworkProcess/soup/NetworkSessionSoup.cpp:
+        * NetworkProcess/soup/NetworkSessionSoup.h:
+        * WebProcess/Network/WebSocketChannel.cpp:
+
+2022-01-05  Youenn Fablet  <youenn@apple.com>
+
</ins><span class="cx">         WebPageProxy::requestUserMediaPermissionForSpeechRecognition should return early in case of no capture devices
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=234837
</span><span class="cx">         <rdar://87055505>
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessNetworkConnectionToWebProcesscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp (287610 => 287611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp     2022-01-05 10:01:06 UTC (rev 287610)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp        2022-01-05 10:35:47 UTC (rev 287611)
</span><span class="lines">@@ -429,10 +429,10 @@
</span><span class="cx">     m_networkSocketStreams.add(identifier, NetworkSocketStream::create(m_networkProcess.get(), WTFMove(url), m_sessionID, cachePartition, identifier, m_connection, WTFMove(token)));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void NetworkConnectionToWebProcess::createSocketChannel(const ResourceRequest& request, const String& protocol, WebSocketIdentifier identifier,  WebPageProxyIdentifier webPageProxyID)
</del><ins>+void NetworkConnectionToWebProcess::createSocketChannel(const ResourceRequest& request, const String& protocol, WebSocketIdentifier identifier,  WebPageProxyIdentifier webPageProxyID, const ClientOrigin& clientOrigin)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(!m_networkSocketChannels.contains(identifier));
</span><del>-    if (auto channel = NetworkSocketChannel::create(*this, m_sessionID, request, protocol, identifier, webPageProxyID))
</del><ins>+    if (auto channel = NetworkSocketChannel::create(*this, m_sessionID, request, protocol, identifier, webPageProxyID, clientOrigin))
</ins><span class="cx">         m_networkSocketChannels.add(identifier, WTFMove(channel));
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessNetworkConnectionToWebProcessh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h (287610 => 287611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h       2022-01-05 10:01:06 UTC (rev 287610)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h  2022-01-05 10:35:47 UTC (rev 287611)
</span><span class="lines">@@ -246,7 +246,7 @@
</span><span class="cx"> 
</span><span class="cx">     void createSocketStream(URL&&, String cachePartition, WebCore::WebSocketIdentifier);
</span><span class="cx"> 
</span><del>-    void createSocketChannel(const WebCore::ResourceRequest&, const String& protocol, WebCore::WebSocketIdentifier, WebPageProxyIdentifier);
</del><ins>+    void createSocketChannel(const WebCore::ResourceRequest&, const String& protocol, WebCore::WebSocketIdentifier, WebPageProxyIdentifier, const WebCore::ClientOrigin&);
</ins><span class="cx">     void updateQuotaBasedOnSpaceUsageForTesting(const WebCore::ClientOrigin&);
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(SERVICE_WORKER)
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessNetworkConnectionToWebProcessmessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in (287610 => 287611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in     2022-01-05 10:01:06 UTC (rev 287610)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in        2022-01-05 10:35:47 UTC (rev 287611)
</span><span class="lines">@@ -62,7 +62,7 @@
</span><span class="cx">     SetCaptureExtraNetworkLoadMetricsEnabled(bool enabled)
</span><span class="cx"> 
</span><span class="cx">     CreateSocketStream(URL url, String cachePartition, WebCore::WebSocketIdentifier identifier)
</span><del>-    CreateSocketChannel(WebCore::ResourceRequest request, String protocol, WebCore::WebSocketIdentifier identifier, WebKit::WebPageProxyIdentifier webPageProxyID)
</del><ins>+    CreateSocketChannel(WebCore::ResourceRequest request, String protocol, WebCore::WebSocketIdentifier identifier, WebKit::WebPageProxyIdentifier webPageProxyID, struct WebCore::ClientOrigin clientOrigin)
</ins><span class="cx"> 
</span><span class="cx">     ClearPageSpecificData(WebCore::PageIdentifier pageID);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessNetworkSessioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp (287610 => 287611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp    2022-01-05 10:01:06 UTC (rev 287610)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp       2022-01-05 10:35:47 UTC (rev 287611)
</span><span class="lines">@@ -530,7 +530,7 @@
</span><span class="cx">         cachedResourceLoader->takeLoader()->abort();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr<WebSocketTask> NetworkSession::createWebSocketTask(WebPageProxyIdentifier, NetworkSocketChannel&, const WebCore::ResourceRequest&, const String& protocol)
</del><ins>+std::unique_ptr<WebSocketTask> NetworkSession::createWebSocketTask(WebPageProxyIdentifier, NetworkSocketChannel&, const WebCore::ResourceRequest&, const String& protocol, const WebCore::ClientOrigin&)
</ins><span class="cx"> {
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessNetworkSessionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/NetworkSession.h (287610 => 287611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/NetworkSession.h      2022-01-05 10:01:06 UTC (rev 287610)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSession.h 2022-01-05 10:35:47 UTC (rev 287611)
</span><span class="lines">@@ -58,6 +58,7 @@
</span><span class="cx"> class SWServer;
</span><span class="cx"> enum class IncludeHttpOnlyCookies : bool;
</span><span class="cx"> enum class ShouldSample : bool;
</span><ins>+struct ClientOrigin;
</ins><span class="cx"> struct SecurityOriginData;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -176,7 +177,7 @@
</span><span class="cx">     PrefetchCache& prefetchCache() { return m_prefetchCache; }
</span><span class="cx">     void clearPrefetchCache() { m_prefetchCache.clear(); }
</span><span class="cx"> 
</span><del>-    virtual std::unique_ptr<WebSocketTask> createWebSocketTask(WebPageProxyIdentifier, NetworkSocketChannel&, const WebCore::ResourceRequest&, const String& protocol);
</del><ins>+    virtual std::unique_ptr<WebSocketTask> createWebSocketTask(WebPageProxyIdentifier, NetworkSocketChannel&, const WebCore::ResourceRequest&, const String& protocol, const WebCore::ClientOrigin&);
</ins><span class="cx">     virtual void removeWebSocketTask(SessionSet&, WebSocketTask&) { }
</span><span class="cx">     virtual void addWebSocketTask(WebPageProxyIdentifier, WebSocketTask&) { }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessNetworkSocketChannelcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.cpp (287610 => 287611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.cpp      2022-01-05 10:01:06 UTC (rev 287610)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.cpp 2022-01-05 10:35:47 UTC (rev 287611)
</span><span class="lines">@@ -36,9 +36,9 @@
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><del>-std::unique_ptr<NetworkSocketChannel> NetworkSocketChannel::create(NetworkConnectionToWebProcess& connection, PAL::SessionID sessionID, const ResourceRequest& request, const String& protocol, WebSocketIdentifier identifier, WebPageProxyIdentifier webPageProxyID)
</del><ins>+std::unique_ptr<NetworkSocketChannel> NetworkSocketChannel::create(NetworkConnectionToWebProcess& connection, PAL::SessionID sessionID, const ResourceRequest& request, const String& protocol, WebSocketIdentifier identifier, WebPageProxyIdentifier webPageProxyID, const WebCore::ClientOrigin& clientOrigin)
</ins><span class="cx"> {
</span><del>-    auto result = makeUnique<NetworkSocketChannel>(connection, connection.networkProcess().networkSession(sessionID), request, protocol, identifier, webPageProxyID);
</del><ins>+    auto result = makeUnique<NetworkSocketChannel>(connection, connection.networkProcess().networkSession(sessionID), request, protocol, identifier, webPageProxyID, clientOrigin);
</ins><span class="cx">     if (!result->m_socket) {
</span><span class="cx">         result->didClose(0, "Cannot create a web socket task"_s);
</span><span class="cx">         return nullptr;
</span><span class="lines">@@ -46,7 +46,7 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-NetworkSocketChannel::NetworkSocketChannel(NetworkConnectionToWebProcess& connection, NetworkSession* session, const ResourceRequest& request, const String& protocol, WebSocketIdentifier identifier, WebPageProxyIdentifier webPageProxyID)
</del><ins>+NetworkSocketChannel::NetworkSocketChannel(NetworkConnectionToWebProcess& connection, NetworkSession* session, const ResourceRequest& request, const String& protocol, WebSocketIdentifier identifier, WebPageProxyIdentifier webPageProxyID, const WebCore::ClientOrigin& clientOrigin)
</ins><span class="cx">     : m_connectionToWebProcess(connection)
</span><span class="cx">     , m_identifier(identifier)
</span><span class="cx">     , m_session(session)
</span><span class="lines">@@ -56,7 +56,7 @@
</span><span class="cx">     if (!m_session)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    m_socket = m_session->createWebSocketTask(webPageProxyID, *this, request, protocol);
</del><ins>+    m_socket = m_session->createWebSocketTask(webPageProxyID, *this, request, protocol, clientOrigin);
</ins><span class="cx">     if (m_socket) {
</span><span class="cx">         m_session->addWebSocketTask(webPageProxyID, *m_socket);
</span><span class="cx">         m_socket->resume();
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessNetworkSocketChannelh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.h (287610 => 287611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.h        2022-01-05 10:01:06 UTC (rev 287610)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.h   2022-01-05 10:35:47 UTC (rev 287611)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> #include <wtf/WeakPtr.h>
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><ins>+struct ClientOrigin;
</ins><span class="cx"> class ResourceRequest;
</span><span class="cx"> class ResourceResponse;
</span><span class="cx"> }
</span><span class="lines">@@ -55,9 +56,9 @@
</span><span class="cx"> class NetworkSocketChannel : public IPC::MessageSender, public IPC::MessageReceiver {
</span><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><del>-    static std::unique_ptr<NetworkSocketChannel> create(NetworkConnectionToWebProcess&, PAL::SessionID, const WebCore::ResourceRequest&, const String& protocol, WebCore::WebSocketIdentifier, WebPageProxyIdentifier);
</del><ins>+    static std::unique_ptr<NetworkSocketChannel> create(NetworkConnectionToWebProcess&, PAL::SessionID, const WebCore::ResourceRequest&, const String& protocol, WebCore::WebSocketIdentifier, WebPageProxyIdentifier, const WebCore::ClientOrigin&);
</ins><span class="cx"> 
</span><del>-    NetworkSocketChannel(NetworkConnectionToWebProcess&, NetworkSession*, const WebCore::ResourceRequest&, const String& protocol, WebCore::WebSocketIdentifier, WebPageProxyIdentifier);
</del><ins>+    NetworkSocketChannel(NetworkConnectionToWebProcess&, NetworkSession*, const WebCore::ResourceRequest&, const String& protocol, WebCore::WebSocketIdentifier, WebPageProxyIdentifier, const WebCore::ClientOrigin&);
</ins><span class="cx">     ~NetworkSocketChannel();
</span><span class="cx"> 
</span><span class="cx">     void didReceiveMessage(IPC::Connection&, IPC::Decoder&);
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcesscocoaNetworkSessionCocoah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h (287610 => 287611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h   2022-01-05 10:01:06 UTC (rev 287610)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h      2022-01-05 10:35:47 UTC (rev 287611)
</span><span class="lines">@@ -157,7 +157,7 @@
</span><span class="cx">     void clearAlternativeServices(WallTime) override;
</span><span class="cx"> 
</span><span class="cx"> #if HAVE(NSURLSESSION_WEBSOCKET)
</span><del>-    std::unique_ptr<WebSocketTask> createWebSocketTask(WebPageProxyIdentifier, NetworkSocketChannel&, const WebCore::ResourceRequest&, const String& protocol) final;
</del><ins>+    std::unique_ptr<WebSocketTask> createWebSocketTask(WebPageProxyIdentifier, NetworkSocketChannel&, const WebCore::ResourceRequest&, const String& protocol, const WebCore::ClientOrigin&) final;
</ins><span class="cx">     void addWebSocketTask(WebPageProxyIdentifier, WebSocketTask&) final;
</span><span class="cx">     void removeWebSocketTask(SessionSet&, WebSocketTask&) final;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcesscocoaNetworkSessionCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm (287610 => 287611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm  2022-01-05 10:01:06 UTC (rev 287610)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm     2022-01-05 10:35:47 UTC (rev 287611)
</span><span class="lines">@@ -1665,8 +1665,7 @@
</span><span class="cx"> #if HAVE(NSURLSESSION_WEBSOCKET)
</span><span class="cx">         if (auto* webSocketTask = sessionWrapper.webSocketDataTaskMap.get(taskIdentifier)) {
</span><span class="cx">             auto challengeCompletionHandler = createChallengeCompletionHandler(networkProcess(), sessionID(), challenge, webSocketTask->partition(), 0, WTFMove(completionHandler));
</span><del>-            networkProcess().authenticationManager().didReceiveAuthenticationChallenge(sessionID(), webSocketTask->pageID(), nullptr, challenge, negotiatedLegacyTLS, WTFMove(challengeCompletionHandler));
-
</del><ins>+            networkProcess().authenticationManager().didReceiveAuthenticationChallenge(sessionID(), webSocketTask->pageID(), !webSocketTask->topOrigin().isEmpty() ? &webSocketTask->topOrigin() : nullptr, challenge, negotiatedLegacyTLS, WTFMove(challengeCompletionHandler));
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx"> #endif
</span><span class="lines">@@ -1707,7 +1706,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if HAVE(NSURLSESSION_WEBSOCKET)
</span><del>-std::unique_ptr<WebSocketTask> NetworkSessionCocoa::createWebSocketTask(WebPageProxyIdentifier webPageProxyID, NetworkSocketChannel& channel, const WebCore::ResourceRequest& request, const String& protocol)
</del><ins>+std::unique_ptr<WebSocketTask> NetworkSessionCocoa::createWebSocketTask(WebPageProxyIdentifier webPageProxyID, NetworkSocketChannel& channel, const WebCore::ResourceRequest& request, const String& protocol, const WebCore::ClientOrigin& clientOrigin)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(!request.hasHTTPHeaderField(WebCore::HTTPHeaderName::SecWebSocketProtocol));
</span><span class="cx">     auto nsRequest = retainPtr(request.nsURLRequest(WebCore::HTTPBodyUpdatePolicy::DoNotUpdateHTTPBody));
</span><span class="lines">@@ -1735,7 +1734,7 @@
</span><span class="cx">     // Although the WebSocket protocol allows full 64-bit lengths, Chrome and Firefox limit the length to 2^63 - 1
</span><span class="cx">     task.get().maximumMessageSize = 0x7FFFFFFFFFFFFFFFull;
</span><span class="cx"> 
</span><del>-    return makeUnique<WebSocketTask>(channel, webPageProxyID, sessionSet, request, WTFMove(task));
</del><ins>+    return makeUnique<WebSocketTask>(channel, webPageProxyID, sessionSet, request, clientOrigin, WTFMove(task));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void NetworkSessionCocoa::addWebSocketTask(WebPageProxyIdentifier webPageProxyID, WebSocketTask& task)
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcesscocoaWebSocketTaskCocoah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/cocoa/WebSocketTaskCocoa.h (287610 => 287611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/cocoa/WebSocketTaskCocoa.h    2022-01-05 10:01:06 UTC (rev 287610)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/WebSocketTaskCocoa.h       2022-01-05 10:35:47 UTC (rev 287611)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include "DataReference.h"
</span><span class="cx"> #include "WebPageProxyIdentifier.h"
</span><ins>+#include <WebCore/SecurityOriginData.h>
</ins><span class="cx"> #include <wtf/RetainPtr.h>
</span><span class="cx"> #include <wtf/WeakPtr.h>
</span><span class="cx"> 
</span><span class="lines">@@ -36,6 +37,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> class ResourceRequest;
</span><ins>+struct ClientOrigin;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="lines">@@ -47,7 +49,7 @@
</span><span class="cx"> class WebSocketTask : public CanMakeWeakPtr<WebSocketTask> {
</span><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><del>-    WebSocketTask(NetworkSocketChannel&, WebPageProxyIdentifier, WeakPtr<SessionSet>&&, const WebCore::ResourceRequest&, RetainPtr<NSURLSessionWebSocketTask>&&);
</del><ins>+    WebSocketTask(NetworkSocketChannel&, WebPageProxyIdentifier, WeakPtr<SessionSet>&&, const WebCore::ResourceRequest&, const WebCore::ClientOrigin&, RetainPtr<NSURLSessionWebSocketTask>&&);
</ins><span class="cx">     ~WebSocketTask();
</span><span class="cx"> 
</span><span class="cx">     void sendString(const IPC::DataReference&, CompletionHandler<void()>&&);
</span><span class="lines">@@ -68,6 +70,7 @@
</span><span class="cx"> 
</span><span class="cx">     WebPageProxyIdentifier pageID() const { return m_pageID; }
</span><span class="cx">     String partition() const { return m_partition; }
</span><ins>+    const WebCore::SecurityOriginData& topOrigin() const { return m_topOrigin; }
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     void readNextMessage();
</span><span class="lines">@@ -79,6 +82,7 @@
</span><span class="cx">     WebPageProxyIdentifier m_pageID;
</span><span class="cx">     WeakPtr<SessionSet> m_sessionSet;
</span><span class="cx">     String m_partition;
</span><ins>+    WebCore::SecurityOriginData m_topOrigin;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcesscocoaWebSocketTaskCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/cocoa/WebSocketTaskCocoa.mm (287610 => 287611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/cocoa/WebSocketTaskCocoa.mm   2022-01-05 10:01:06 UTC (rev 287610)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/WebSocketTaskCocoa.mm      2022-01-05 10:35:47 UTC (rev 287611)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #import "NetworkSessionCocoa.h"
</span><span class="cx"> #import "NetworkSocketChannel.h"
</span><span class="cx"> #import <Foundation/NSURLSession.h>
</span><ins>+#import <WebCore/ClientOrigin.h>
</ins><span class="cx"> #import <WebCore/ResourceRequest.h>
</span><span class="cx"> #import <WebCore/ResourceResponse.h>
</span><span class="cx"> #import <WebCore/WebSocketChannel.h>
</span><span class="lines">@@ -40,7 +41,7 @@
</span><span class="cx"> 
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><del>-WebSocketTask::WebSocketTask(NetworkSocketChannel& channel, WebPageProxyIdentifier pageID, WeakPtr<SessionSet>&& sessionSet, const WebCore::ResourceRequest& request, RetainPtr<NSURLSessionWebSocketTask>&& task)
</del><ins>+WebSocketTask::WebSocketTask(NetworkSocketChannel& channel, WebPageProxyIdentifier pageID, WeakPtr<SessionSet>&& sessionSet, const WebCore::ResourceRequest& request, const WebCore::ClientOrigin& clientOrigin, RetainPtr<NSURLSessionWebSocketTask>&& task)
</ins><span class="cx">     : m_channel(channel)
</span><span class="cx">     , m_task(WTFMove(task))
</span><span class="cx">     , m_pageID(pageID)
</span><span class="lines">@@ -47,6 +48,11 @@
</span><span class="cx">     , m_sessionSet(WTFMove(sessionSet))
</span><span class="cx">     , m_partition(request.cachePartition())
</span><span class="cx"> {
</span><ins>+    // We use topOrigin in case of service worker websocket connections, for which pageID does not link to a real page.
+    // In that case, let's only call the callback for same origin loads.
+    if (clientOrigin.topOrigin == clientOrigin.clientOrigin)
+        m_topOrigin = clientOrigin.topOrigin;
+
</ins><span class="cx">     readNextMessage();
</span><span class="cx">     m_channel.didSendHandshakeRequest(ResourceRequest { [m_task currentRequest] });
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcesssoupNetworkSessionSoupcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.cpp (287610 => 287611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.cpp   2022-01-05 10:01:06 UTC (rev 287610)
+++ trunk/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.cpp      2022-01-05 10:35:47 UTC (rev 287611)
</span><span class="lines">@@ -119,7 +119,7 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-std::unique_ptr<WebSocketTask> NetworkSessionSoup::createWebSocketTask(WebPageProxyIdentifier, NetworkSocketChannel& channel, const ResourceRequest& request, const String& protocol)
</del><ins>+std::unique_ptr<WebSocketTask> NetworkSessionSoup::createWebSocketTask(WebPageProxyIdentifier, NetworkSocketChannel& channel, const ResourceRequest& request, const String& protocol, const ClientOrigin&)
</ins><span class="cx"> {
</span><span class="cx">     GRefPtr<SoupMessage> soupMessage = request.createSoupMessage(blobRegistry());
</span><span class="cx">     if (!soupMessage)
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcesssoupNetworkSessionSouph"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.h (287610 => 287611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.h     2022-01-05 10:01:06 UTC (rev 287610)
+++ trunk/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.h        2022-01-05 10:35:47 UTC (rev 287611)
</span><span class="lines">@@ -63,7 +63,7 @@
</span><span class="cx">     void setProxySettings(const WebCore::SoupNetworkProxySettings&);
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    std::unique_ptr<WebSocketTask> createWebSocketTask(WebPageProxyIdentifier, NetworkSocketChannel&, const WebCore::ResourceRequest&, const String& protocol) final;
</del><ins>+    std::unique_ptr<WebSocketTask> createWebSocketTask(WebPageProxyIdentifier, NetworkSocketChannel&, const WebCore::ResourceRequest&, const String& protocol, const WebCore::ClientOrigin&) final;
</ins><span class="cx">     void clearCredentials() final;
</span><span class="cx"> 
</span><span class="cx">     std::unique_ptr<WebCore::SoupNetworkSession> m_networkSession;
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessNetworkWebSocketChannelcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp (287610 => 287611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp      2022-01-05 10:01:06 UTC (rev 287610)
+++ trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp 2022-01-05 10:35:47 UTC (rev 287611)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #include "WebCoreArgumentCoders.h"
</span><span class="cx"> #include "WebProcess.h"
</span><span class="cx"> #include <WebCore/Blob.h>
</span><ins>+#include <WebCore/ClientOrigin.h>
</ins><span class="cx"> #include <WebCore/Document.h>
</span><span class="cx"> #include <WebCore/ExceptionCode.h>
</span><span class="cx"> #include <WebCore/Page.h>
</span><span class="lines">@@ -117,7 +118,7 @@
</span><span class="cx"> 
</span><span class="cx">     m_inspector.didCreateWebSocket(m_document.get(), url);
</span><span class="cx">     m_url = request->url();
</span><del>-    MessageSender::send(Messages::NetworkConnectionToWebProcess::CreateSocketChannel { *request, protocol, m_identifier, m_webPageProxyID });
</del><ins>+    MessageSender::send(Messages::NetworkConnectionToWebProcess::CreateSocketChannel { *request, protocol, m_identifier, m_webPageProxyID, m_document->clientOrigin() });
</ins><span class="cx">     return ConnectStatus::OK;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>