<!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>[283274] 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/283274">283274</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2021-09-29 16:08:05 -0700 (Wed, 29 Sep 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Use isolated NSURLSessions for each first party registrable domain
https://bugs.webkit.org/show_bug.cgi?id=230750
<rdar://83159358>

Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

Rebaseline WPT test that is now passing more checks.

* web-platform-tests/fetch/connection-pool/network-partition-key-expected.txt:

Source/WebCore:

Fix bug where service worker soft-update requests would have their "first-party-for-cookies"
field set to "https:" instead of a full origin (e.g. "https://localhost:8080"). This was
causing some service worker test failures now that we use different NSURLSession based on
the "first-party-for-cookies" field.

* workers/service/server/SWServer.cpp:
(WebCore::originURL):

Source/WebKit:

Previously would use up to 10 isolated NSURLSessions only for domains marked as prevalent
by ITP *and* that the user interacts with as first party website. We now use different
isolated NSURLSession for each top-level registrable domain, not matter their ITP status.
This significantly improves privacy.

To avoid having too many NSURLSession, we clear the ones that haven't been used in the
last 10 minutes, every time we add a new one.

* NetworkProcess/cocoa/NetworkSessionCocoa.h:
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(WebKit::NetworkSessionCocoa::sessionWrapperForTask):
(WebKit::SessionSet::isolatedSession):

LayoutTests:

This test is now passing more checks on WebKit2 but still completely fails on WebKit1 so I am
adding a WK1-specific baseline.

* platform/mac-wk1/imported/w3c/web-platform-tests/fetch/connection-pool/network-partition-key-expected.txt: Copied from LayoutTests/imported/w3c/web-platform-tests/fetch/connection-pool/network-partition-key-expected.txt.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchconnectionpoolnetworkpartitionkeyexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/connection-pool/network-partition-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformgtkTestExpectations">trunk/LayoutTests/platform/gtk/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformwpeTestExpectations">trunk/LayoutTests/platform/wpe/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreworkersserviceserverSWServercpp">trunk/Source/WebCore/workers/service/server/SWServer.cpp</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</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>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestshttptestsresourceLoadStatisticsswitchsessiononnavigationtoprevalentwithoutinteractionexpectedtxt">trunk/LayoutTests/http/tests/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-without-interaction-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestsresourceLoadStatisticsswitchsessiononnavigationtoprevalentwithoutinteractionpy">trunk/LayoutTests/http/tests/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-without-interaction.py</a></li>
<li>trunk/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/fetch/connection-pool/</li>
<li><a href="#trunkLayoutTestsplatformmacwk1importedw3cwebplatformtestsfetchconnectionpoolnetworkpartitionkeyexpectedtxt">trunk/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/fetch/connection-pool/network-partition-key-expected.txt</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkLayoutTestshttptestsresourceLoadStatisticsdonotswitchsessiononnavigationtoprevalentwithoutinteractionexpectedtxt">trunk/LayoutTests/http/tests/resourceLoadStatistics/do-not-switch-session-on-navigation-to-prevalent-without-interaction-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestsresourceLoadStatisticsdonotswitchsessiononnavigationtoprevalentwithoutinteractionpy">trunk/LayoutTests/http/tests/resourceLoadStatistics/do-not-switch-session-on-navigation-to-prevalent-without-interaction.py</a></li>
<li><a href="#trunkLayoutTestshttptestsresourceLoadStatisticsswitchsessiononnavigationtoprevalentwithinteractionexpectedtxt">trunk/LayoutTests/http/tests/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-with-interaction-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestsresourceLoadStatisticsswitchsessiononnavigationtoprevalentwithinteractionpy">trunk/LayoutTests/http/tests/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-with-interaction.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (283273 => 283274)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2021-09-29 23:04:52 UTC (rev 283273)
+++ trunk/LayoutTests/ChangeLog 2021-09-29 23:08:05 UTC (rev 283274)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2021-09-29  Chris Dumez  <cdumez@apple.com>
+
+        Use isolated NSURLSessions for each first party registrable domain
+        https://bugs.webkit.org/show_bug.cgi?id=230750
+        <rdar://83159358>
+
+        Reviewed by Alex Christensen.
+
+        This test is now passing more checks on WebKit2 but still completely fails on WebKit1 so I am
+        adding a WK1-specific baseline.
+
+        * platform/mac-wk1/imported/w3c/web-platform-tests/fetch/connection-pool/network-partition-key-expected.txt: Copied from LayoutTests/imported/w3c/web-platform-tests/fetch/connection-pool/network-partition-key-expected.txt.
+
</ins><span class="cx"> 2021-09-29  Aditya Keerthi  <akeerthi@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [css-ui] getComputedStyle() must return the specified value for '-webkit-appearance'
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsresourceLoadStatisticsdonotswitchsessiononnavigationtoprevalentwithoutinteractionexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/http/tests/resourceLoadStatistics/do-not-switch-session-on-navigation-to-prevalent-without-interaction-expected.txt (283273 => 283274)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/resourceLoadStatistics/do-not-switch-session-on-navigation-to-prevalent-without-interaction-expected.txt    2021-09-29 23:04:52 UTC (rev 283273)
+++ trunk/LayoutTests/http/tests/resourceLoadStatistics/do-not-switch-session-on-navigation-to-prevalent-without-interaction-expected.txt       2021-09-29 23:08:05 UTC (rev 283274)
</span><span class="lines">@@ -1,12 +0,0 @@
</span><del>-Tests that the session is not switched upon top frame navigation to a prevalent resource without user interaction.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-PASS Should have and has the session cookie.
-PASS Should have and has the persistent cookie.
-PASS Origin has no isolated session.
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
</del></span></pre></div>
<a id="trunkLayoutTestshttptestsresourceLoadStatisticsdonotswitchsessiononnavigationtoprevalentwithoutinteractionpy"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/http/tests/resourceLoadStatistics/do-not-switch-session-on-navigation-to-prevalent-without-interaction.py (283273 => 283274)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/resourceLoadStatistics/do-not-switch-session-on-navigation-to-prevalent-without-interaction.py      2021-09-29 23:04:52 UTC (rev 283273)
+++ trunk/LayoutTests/http/tests/resourceLoadStatistics/do-not-switch-session-on-navigation-to-prevalent-without-interaction.py 2021-09-29 23:08:05 UTC (rev 283274)
</span><span class="lines">@@ -1,117 +0,0 @@
</span><del>-#!/usr/bin/env python3
-
-import sys
-
-sys.stdout.write(
-    'Cache-Control: no-store\r\n'
-    'Content-Type: text/html\r\n\r\n'
-)
-
-print('''<!DOCTYPE html>
-<html lang="en">
-<head>
-    <meta charset="UTF-8">
-    <script src="/js-test-resources/js-test.js"></script>
-    <script src="resources/util.js"></script>
-</head>
-<body onload="runTest()">
-<script>
-    description("Tests that the session is not switched upon top frame navigation to a prevalent resource without user interaction.");
-    jsTestIsAsync = true;
-
-    const prevalentOrigin = "http://127.0.0.1:8000";
-    const nonPrevalentOrigin = "http://localhost:8000";
-    const sessionCookieName = "sessionCookie";
-    const persistentCookieName = "persistentCookie";
-    const twoMinutesInSeconds = 120;
-
-    function setSessionCookie() {
-        document.cookie = sessionCookieName + "=1; path=/";
-    }
-
-    function setPersistentCookie() {
-        document.cookie = persistentCookieName + "=1; path=/; Max-Age=" + twoMinutesInSeconds + ";";
-    }
-
-    function checkCookies(shouldHaveSessionCookie, shouldHavePersistentCookie) {
-        let hasSessionCookie = (document.cookie + "").includes(sessionCookieName),
-            hasPersistentCookie = (document.cookie + "").includes(persistentCookieName);
-
-        if (shouldHaveSessionCookie && hasSessionCookie)
-            testPassed("Should have and has the session cookie.");
-        else if (shouldHaveSessionCookie && !hasSessionCookie) {
-            testFailed("Should have but doesn\'t have the session cookie.");
-            setEnableFeature(false, finishJSTest);
-        } else if (!shouldHaveSessionCookie && hasSessionCookie) {
-            testFailed("Shouldn\'t have but has the session cookie.");
-            setEnableFeature(false, finishJSTest);
-        } else
-            testPassed("Shouldn\'t have and doesn\'t have the session cookie.");
-
-
-        if (shouldHavePersistentCookie && hasPersistentCookie)
-            testPassed("Should have and has the persistent cookie.");
-        else if (shouldHavePersistentCookie && !hasPersistentCookie) {
-            testFailed("Should have but doesn\'t have the persistent cookie.");
-            setEnableFeature(false, finishJSTest);
-        } else if (!shouldHavePersistentCookie && hasPersistentCookie) {
-            testFailed("Shouldn\'t have but has the persistent cookie.");
-            setEnableFeature(false, finishJSTest);
-        } else
-            testPassed("Shouldn\'t have and doesn\'t have the persistent cookie.");
-    }
-
-    function runTest() {
-        switch (document.location.hash) {
-            case "":
-                if (document.location.origin !== prevalentOrigin)
-                    testFailed("Test is not starting out on " + prevalentOrigin + ".");
-
-                setEnableFeature(true, function () {
-                    if (testRunner.isStatisticsPrevalentResource(prevalentOrigin))
-                        testFailed(prevalentOrigin + " was classified as prevalent resource before the test starts.");
-                    document.location.hash = "step1";
-                    runTest();
-                });
-            case "#step1":
-                setSessionCookie();
-                setPersistentCookie();
-                checkCookies(true, true);
-                if (testRunner.hasStatisticsIsolatedSession(prevalentOrigin)) {
-                    testFailed("Origin has isolated session.");
-                    setEnableFeature(false, finishJSTest);
-                } else
-                    testPassed("Origin has no isolated session.");
-                document.location.href = nonPrevalentOrigin + "/resourceLoadStatistics/do-not-switch-session-on-navigation-to-prevalent-without-interaction.py#step2";
-                break;
-            case "#step2":
-                document.location.hash = "step3";
-                if (document.location.origin !== nonPrevalentOrigin)
-                    testFailed("Step 2 is not on " + nonPrevalentOrigin + ".");
-                testRunner.setStatisticsPrevalentResource(prevalentOrigin, true, function() {
-                    if (!testRunner.isStatisticsPrevalentResource(prevalentOrigin)) {
-                        testFailed(prevalentOrigin + " did not get set as prevalent resource.");
-                        setEnableFeature(false, finishJSTest);
-                    }
-                    testRunner.statisticsUpdateCookieBlocking(runTest);
-                });
-                break;
-            case "#step3":
-                document.location.href = prevalentOrigin + "/resourceLoadStatistics/do-not-switch-session-on-navigation-to-prevalent-without-interaction.py#step4";
-                break;
-            case "#step4":
-                checkCookies(true, true);
-                if (testRunner.hasStatisticsIsolatedSession(prevalentOrigin))
-                    testFailed("Origin has isolated session.");
-                else
-                    testPassed("Origin has no isolated session.");
-                setEnableFeature(false, finishJSTest);
-                break;
-            default:
-                testFailed("Unknown hash.");
-                setEnableFeature(false, finishJSTest);
-        }
-    }
-</script>
-</body>
-</html>''')
</del><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsresourceLoadStatisticsswitchsessiononnavigationtoprevalentwithinteractionexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/http/tests/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-with-interaction-expected.txt (283273 => 283274)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-with-interaction-expected.txt      2021-09-29 23:04:52 UTC (rev 283273)
+++ trunk/LayoutTests/http/tests/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-with-interaction-expected.txt 2021-09-29 23:08:05 UTC (rev 283274)
</span><span class="lines">@@ -1,12 +0,0 @@
</span><del>-Tests that the session is switched upon top frame navigation to a prevalent resource with user interaction.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-PASS Should have and has the session cookie.
-PASS Should have and has the persistent cookie.
-PASS Origin has isolated session.
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
</del></span></pre></div>
<a id="trunkLayoutTestshttptestsresourceLoadStatisticsswitchsessiononnavigationtoprevalentwithinteractionpy"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/http/tests/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-with-interaction.py (283273 => 283274)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-with-interaction.py        2021-09-29 23:04:52 UTC (rev 283273)
+++ trunk/LayoutTests/http/tests/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-with-interaction.py   2021-09-29 23:08:05 UTC (rev 283274)
</span><span class="lines">@@ -1,119 +0,0 @@
</span><del>-#!/usr/bin/env python3
-
-import sys
-
-sys.stdout.write(
-    'Cache-Control: no-store\r\n'
-    'Content-Type: text/html\r\n\r\n'
-)
-
-print('''<!DOCTYPE html>
-<html lang="en">
-<head>
-    <meta charset="UTF-8">
-    <script src="/js-test-resources/js-test.js"></script>
-    <script src="resources/util.js"></script>
-</head>
-<body onload="runTest()">
-<script>
-    description("Tests that the session is switched upon top frame navigation to a prevalent resource with user interaction.");
-    jsTestIsAsync = true;
-
-    const prevalentOrigin = "http://127.0.0.1:8000";
-    const nonPrevalentOrigin = "http://localhost:8000";
-    const sessionCookieName = "sessionCookie";
-    const persistentCookieName = "persistentCookie";
-    const twoMinutesInSeconds = 120;
-
-    function setSessionCookie() {
-        document.cookie = sessionCookieName + "=1; path=/";
-    }
-
-    function setPersistentCookie() {
-        document.cookie = persistentCookieName + "=1; path=/; Max-Age=" + twoMinutesInSeconds + ";";
-    }
-
-    function checkCookies(shouldHaveSessionCookie, shouldHavePersistentCookie) {
-        let hasSessionCookie = (document.cookie + "").includes(sessionCookieName),
-            hasPersistentCookie = (document.cookie + "").includes(persistentCookieName);
-
-        if (shouldHaveSessionCookie && hasSessionCookie)
-            testPassed("Should have and has the session cookie.");
-        else if (shouldHaveSessionCookie && !hasSessionCookie) {
-            testFailed("Should have but doesn\'t have the session cookie.");
-            setEnableFeature(false, finishJSTest);
-        } else if (!shouldHaveSessionCookie && hasSessionCookie) {
-            testFailed("Shouldn\'t have but has the session cookie.");
-            setEnableFeature(false, finishJSTest);
-        } else
-            testPassed("Shouldn\'t have and doesn\'t have the session cookie.");
-
-
-        if (shouldHavePersistentCookie && hasPersistentCookie)
-            testPassed("Should have and has the persistent cookie.");
-        else if (shouldHavePersistentCookie && !hasPersistentCookie) {
-            testFailed("Should have but doesn\'t have the persistent cookie.");
-            setEnableFeature(false, finishJSTest);
-        } else if (!shouldHavePersistentCookie && hasPersistentCookie) {
-            testFailed("Shouldn\'t have but has the persistent cookie.");
-            setEnableFeature(false, finishJSTest);
-        } else
-            testPassed("Shouldn\'t have and doesn\'t have the persistent cookie.");
-    }
-
-    function runTest() {
-        switch (document.location.hash) {
-            case "":
-                if (document.location.origin !== prevalentOrigin)
-                    testFailed("Test is not starting out on " + prevalentOrigin + ".");
-                setEnableFeature(true, function () {
-                    if (testRunner.isStatisticsPrevalentResource(prevalentOrigin))
-                        testFailed(prevalentOrigin + " was classified as prevalent resource before the test starts.");
-                    document.location.hash = "step1";
-                    runTest();
-                });
-                break;
-            case "#step1":
-                testRunner.setStatisticsHasHadUserInteraction(prevalentOrigin, true, function() {
-                    setSessionCookie();
-                    setPersistentCookie();
-                    checkCookies(true, true);
-                    if (testRunner.hasStatisticsIsolatedSession(prevalentOrigin)) {
-                        testFailed("Origin has isolated session.");
-                        setEnableFeature(false, finishJSTest);
-                    } else
-                        testPassed("Origin has no isolated session.");
-                    document.location.href = nonPrevalentOrigin + "/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-with-interaction.py#step2";
-                });
-                break;
-            case "#step2":
-                document.location.hash = "step3";
-                if (document.location.origin !== nonPrevalentOrigin)
-                    testFailed("Step 2 is not on " + nonPrevalentOrigin + ".");
-                testRunner.setStatisticsPrevalentResource(prevalentOrigin, true, function() {
-                    if (!testRunner.isStatisticsPrevalentResource(prevalentOrigin)) {
-                        testFailed(prevalentOrigin + " did not get set as prevalent resource.");
-                        setEnableFeature(false, finishJSTest);
-                    }
-                    testRunner.statisticsUpdateCookieBlocking(runTest);
-                });
-                break;
-            case "#step3":
-                document.location.href = prevalentOrigin + "/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-with-interaction.py#step4";
-                break;
-            case "#step4":
-                checkCookies(true, true);
-                if (testRunner.hasStatisticsIsolatedSession(prevalentOrigin))
-                    testPassed("Origin has isolated session.");
-                else
-                    testFailed("Origin has no isolated session.");
-                setEnableFeature(false, finishJSTest);
-                break;
-            default:
-                testFailed("Unknown hash.");
-                setEnableFeature(false, finishJSTest);
-        }
-    }
-</script>
-</body>
-</html>''')
</del><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsresourceLoadStatisticsswitchsessiononnavigationtoprevalentwithoutinteractionexpectedtxtfromrev283273trunkLayoutTestshttptestsresourceLoadStatisticsswitchsessiononnavigationtoprevalentwithinteractionexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/http/tests/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-without-interaction-expected.txt (from rev 283273, trunk/LayoutTests/http/tests/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-with-interaction-expected.txt) (0 => 283274)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-without-interaction-expected.txt                           (rev 0)
+++ trunk/LayoutTests/http/tests/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-without-interaction-expected.txt      2021-09-29 23:08:05 UTC (rev 283274)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+Tests that the session is switched upon top frame navigation to a prevalent resource without user interaction.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Should have and has the session cookie.
+PASS Should have and has the persistent cookie.
+PASS Origin has isolated session.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsresourceLoadStatisticsswitchsessiononnavigationtoprevalentwithoutinteractionpyfromrev283273trunkLayoutTestshttptestsresourceLoadStatisticsdonotswitchsessiononnavigationtoprevalentwithoutinteractionpy"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/http/tests/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-without-interaction.py (from rev 283273, trunk/LayoutTests/http/tests/resourceLoadStatistics/do-not-switch-session-on-navigation-to-prevalent-without-interaction.py) (0 => 283274)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-without-interaction.py                             (rev 0)
+++ trunk/LayoutTests/http/tests/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-without-interaction.py        2021-09-29 23:08:05 UTC (rev 283274)
</span><span class="lines">@@ -0,0 +1,119 @@
</span><ins>+#!/usr/bin/env python3
+
+import sys
+
+sys.stdout.write(
+    'Cache-Control: no-store\r\n'
+    'Content-Type: text/html\r\n\r\n'
+)
+
+print('''<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <script src="/js-test-resources/js-test.js"></script>
+    <script src="resources/util.js"></script>
+</head>
+<body onload="runTest()">
+<script>
+    description("Tests that the session is switched upon top frame navigation to a prevalent resource without user interaction.");
+    jsTestIsAsync = true;
+
+    const prevalentOrigin = "http://127.0.0.1:8000";
+    const nonPrevalentOrigin = "http://localhost:8000";
+    const sessionCookieName = "sessionCookie";
+    const persistentCookieName = "persistentCookie";
+    const twoMinutesInSeconds = 120;
+
+    function setSessionCookie() {
+        document.cookie = sessionCookieName + "=1; path=/";
+    }
+
+    function setPersistentCookie() {
+        document.cookie = persistentCookieName + "=1; path=/; Max-Age=" + twoMinutesInSeconds + ";";
+    }
+
+    function checkCookies(shouldHaveSessionCookie, shouldHavePersistentCookie) {
+        let hasSessionCookie = (document.cookie + "").includes(sessionCookieName),
+            hasPersistentCookie = (document.cookie + "").includes(persistentCookieName);
+
+        if (shouldHaveSessionCookie && hasSessionCookie)
+            testPassed("Should have and has the session cookie.");
+        else if (shouldHaveSessionCookie && !hasSessionCookie) {
+            testFailed("Should have but doesn\'t have the session cookie.");
+            setEnableFeature(false, finishJSTest);
+        } else if (!shouldHaveSessionCookie && hasSessionCookie) {
+            testFailed("Shouldn\'t have but has the session cookie.");
+            setEnableFeature(false, finishJSTest);
+        } else
+            testPassed("Shouldn\'t have and doesn\'t have the session cookie.");
+
+
+        if (shouldHavePersistentCookie && hasPersistentCookie)
+            testPassed("Should have and has the persistent cookie.");
+        else if (shouldHavePersistentCookie && !hasPersistentCookie) {
+            testFailed("Should have but doesn\'t have the persistent cookie.");
+            setEnableFeature(false, finishJSTest);
+        } else if (!shouldHavePersistentCookie && hasPersistentCookie) {
+            testFailed("Shouldn\'t have but has the persistent cookie.");
+            setEnableFeature(false, finishJSTest);
+        } else
+            testPassed("Shouldn\'t have and doesn\'t have the persistent cookie.");
+    }
+
+    function runTest() {
+        switch (document.location.hash) {
+            case "":
+                if (document.location.origin !== prevalentOrigin)
+                    testFailed("Test is not starting out on " + prevalentOrigin + ".");
+
+                setEnableFeature(true, function () {
+                    if (testRunner.isStatisticsPrevalentResource(prevalentOrigin))
+                        testFailed(prevalentOrigin + " was classified as prevalent resource before the test starts.");
+                    document.location.hash = "step1";
+                    runTest();
+                });
+                break;
+            case "#step1":
+                setSessionCookie();
+                setPersistentCookie();
+                checkCookies(true, true);
+                if (testRunner.hasStatisticsIsolatedSession(prevalentOrigin))
+                    testPassed("Origin has isolated session.");
+                else {
+                    testFailed("Origin has no isolated session.");
+                    setEnableFeature(false, finishJSTest);
+                }
+                document.location.href = nonPrevalentOrigin + "/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-without-interaction.py#step2";
+                break;
+            case "#step2":
+                document.location.hash = "step3";
+                if (document.location.origin !== nonPrevalentOrigin)
+                    testFailed("Step 2 is not on " + nonPrevalentOrigin + ".");
+                testRunner.setStatisticsPrevalentResource(prevalentOrigin, true, function() {
+                    if (!testRunner.isStatisticsPrevalentResource(prevalentOrigin)) {
+                        testFailed(prevalentOrigin + " did not get set as prevalent resource.");
+                        setEnableFeature(false, finishJSTest);
+                    }
+                    testRunner.statisticsUpdateCookieBlocking(runTest);
+                });
+                break;
+            case "#step3":
+                document.location.href = prevalentOrigin + "/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-without-interaction.py#step4";
+                break;
+            case "#step4":
+                checkCookies(true, true);
+                if (testRunner.hasStatisticsIsolatedSession(prevalentOrigin))
+                    testPassed("Origin has isolated session.");
+                else
+                    testFailed("Origin has no isolated session.");
+                setEnableFeature(false, finishJSTest);
+                break;
+            default:
+                testFailed("Unknown hash.");
+                setEnableFeature(false, finishJSTest);
+        }
+    }
+</script>
+</body>
+</html>''')
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (283273 => 283274)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-09-29 23:04:52 UTC (rev 283273)
+++ trunk/LayoutTests/imported/w3c/ChangeLog    2021-09-29 23:08:05 UTC (rev 283274)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2021-09-29  Chris Dumez  <cdumez@apple.com>
+
+        Use isolated NSURLSessions for each first party registrable domain
+        https://bugs.webkit.org/show_bug.cgi?id=230750
+        <rdar://83159358>
+
+        Reviewed by Alex Christensen.
+
+        Rebaseline WPT test that is now passing more checks.
+
+        * web-platform-tests/fetch/connection-pool/network-partition-key-expected.txt:
+
</ins><span class="cx"> 2021-09-29  Aditya Keerthi  <akeerthi@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [css-ui] getComputedStyle() must return the specified value for '-webkit-appearance'
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchconnectionpoolnetworkpartitionkeyexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/connection-pool/network-partition-key-expected.txt (283273 => 283274)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/connection-pool/network-partition-key-expected.txt       2021-09-29 23:04:52 UTC (rev 283273)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/connection-pool/network-partition-key-expected.txt  2021-09-29 23:08:05 UTC (rev 283274)
</span><span class="lines">@@ -1,12 +1,12 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-FAIL With credentials promise_test: Unhandled rejection with value: "assert_equals: Socket unexpectedly reused expected \"ok\" but got \"Multiple partition IDs used on a socket\""
-FAIL Without credentials promise_test: Unhandled rejection with value: "assert_equals: Socket unexpectedly reused expected \"ok\" but got \"Multiple partition IDs used on a socket\""
-FAIL Cross-site resources with credentials promise_test: Unhandled rejection with value: "assert_equals: Socket unexpectedly reused expected \"ok\" but got \"Multiple partition IDs used on a socket\""
-FAIL Cross-site resources without credentials promise_test: Unhandled rejection with value: "assert_equals: Socket unexpectedly reused expected \"ok\" but got \"Multiple partition IDs used on a socket\""
-FAIL Iframes promise_test: Unhandled rejection with value: "assert_equals: Socket unexpectedly reused expected \"ok\" but got \"Multiple partition IDs used on a socket\""
-FAIL Workers promise_test: Unhandled rejection with value: "assert_equals: Socket unexpectedly reused expected \"ok\" but got \"Multiple partition IDs used on a socket\""
-FAIL Workers with cross-site resources promise_test: Unhandled rejection with value: "assert_equals: Socket unexpectedly reused expected \"ok\" but got \"Multiple partition IDs used on a socket\""
</del><ins>+PASS With credentials
+PASS Without credentials
+PASS Cross-site resources with credentials
+PASS Cross-site resources without credentials
+PASS Iframes
+PASS Workers
+PASS Workers with cross-site resources
</ins><span class="cx"> FAIL CSP sandbox promise_test: Unhandled rejection with value: "assert_equals: Socket unexpectedly reused expected \"ok\" but got \"Multiple partition IDs used on a socket\""
</span><span class="cx"> FAIL about:blank from opaque origin iframe promise_test: Unhandled rejection with value: "assert_equals: Socket unexpectedly reused expected \"ok\" but got \"Multiple partition IDs used on a socket\""
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsplatformgtkTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/gtk/TestExpectations (283273 => 283274)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/gtk/TestExpectations  2021-09-29 23:04:52 UTC (rev 283273)
+++ trunk/LayoutTests/platform/gtk/TestExpectations     2021-09-29 23:08:05 UTC (rev 283274)
</span><span class="lines">@@ -896,8 +896,6 @@
</span><span class="cx"> 
</span><span class="cx"> webkit.org/b/209727 fast/forms/placeholder-content-line-height.html [ ImageOnlyFailure ]
</span><span class="cx"> 
</span><del>-webkit.org/b/210487 http/tests/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-with-interaction.py [ Failure ]
-
</del><span class="cx"> webkit.org/b/210796 http/tests/resourceLoadStatistics/standalone-web-application-exempt-from-website-data-deletion.html [ Failure ]
</span><span class="cx"> 
</span><span class="cx"> webkit.org/b/210849 compositing/overflow/rtl-scrollbar-layer-positioning.html [ Failure ]
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk1importedw3cwebplatformtestsfetchconnectionpoolnetworkpartitionkeyexpectedtxtfromrev283273trunkLayoutTestsimportedw3cwebplatformtestsfetchconnectionpoolnetworkpartitionkeyexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/fetch/connection-pool/network-partition-key-expected.txt (from rev 283273, trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/connection-pool/network-partition-key-expected.txt) (0 => 283274)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/fetch/connection-pool/network-partition-key-expected.txt                              (rev 0)
+++ trunk/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/fetch/connection-pool/network-partition-key-expected.txt 2021-09-29 23:08:05 UTC (rev 283274)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+
+
+FAIL With credentials promise_test: Unhandled rejection with value: "assert_equals: Socket unexpectedly reused expected \"ok\" but got \"Multiple partition IDs used on a socket\""
+FAIL Without credentials promise_test: Unhandled rejection with value: "assert_equals: Socket unexpectedly reused expected \"ok\" but got \"Multiple partition IDs used on a socket\""
+FAIL Cross-site resources with credentials promise_test: Unhandled rejection with value: "assert_equals: Socket unexpectedly reused expected \"ok\" but got \"Multiple partition IDs used on a socket\""
+FAIL Cross-site resources without credentials promise_test: Unhandled rejection with value: "assert_equals: Socket unexpectedly reused expected \"ok\" but got \"Multiple partition IDs used on a socket\""
+FAIL Iframes promise_test: Unhandled rejection with value: "assert_equals: Socket unexpectedly reused expected \"ok\" but got \"Multiple partition IDs used on a socket\""
+FAIL Workers promise_test: Unhandled rejection with value: "assert_equals: Socket unexpectedly reused expected \"ok\" but got \"Multiple partition IDs used on a socket\""
+FAIL Workers with cross-site resources promise_test: Unhandled rejection with value: "assert_equals: Socket unexpectedly reused expected \"ok\" but got \"Multiple partition IDs used on a socket\""
+FAIL CSP sandbox promise_test: Unhandled rejection with value: "assert_equals: Socket unexpectedly reused expected \"ok\" but got \"Multiple partition IDs used on a socket\""
+FAIL about:blank from opaque origin iframe promise_test: Unhandled rejection with value: "assert_equals: Socket unexpectedly reused expected \"ok\" but got \"Multiple partition IDs used on a socket\""
+
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformwpeTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/wpe/TestExpectations (283273 => 283274)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/wpe/TestExpectations  2021-09-29 23:04:52 UTC (rev 283273)
+++ trunk/LayoutTests/platform/wpe/TestExpectations     2021-09-29 23:08:05 UTC (rev 283274)
</span><span class="lines">@@ -598,8 +598,6 @@
</span><span class="cx"> webkit.org/b/210262 fast/selectors/text-field-selection-stroke-color.html [ ImageOnlyFailure ]
</span><span class="cx"> webkit.org/b/210262 fast/selectors/text-field-selection-text-shadow.html [ ImageOnlyFailure ]
</span><span class="cx"> 
</span><del>-webkit.org/b/210487 http/tests/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-with-interaction.py [ Failure ]
-
</del><span class="cx"> webkit.org/b/211563 fast/text-indicator/text-indicator-estimated-color-with-implicit-newline.html [ Failure ]
</span><span class="cx"> 
</span><span class="cx"> # Only enabled on Mac/iOS so far.
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (283273 => 283274)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-09-29 23:04:52 UTC (rev 283273)
+++ trunk/Source/WebCore/ChangeLog      2021-09-29 23:08:05 UTC (rev 283274)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2021-09-29  Chris Dumez  <cdumez@apple.com>
+
+        Use isolated NSURLSessions for each first party registrable domain
+        https://bugs.webkit.org/show_bug.cgi?id=230750
+        <rdar://83159358>
+
+        Reviewed by Alex Christensen.
+
+        Fix bug where service worker soft-update requests would have their "first-party-for-cookies"
+        field set to "https:" instead of a full origin (e.g. "https://localhost:8080"). This was
+        causing some service worker test failures now that we use different NSURLSession based on
+        the "first-party-for-cookies" field.
+
+        * workers/service/server/SWServer.cpp:
+        (WebCore::originURL):
+
</ins><span class="cx"> 2021-09-29  Devin Rousso  <drousso@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Allow `DrawGlyphsRecorder` to be used with any `GraphicsContext` instead of just `DisplayList::Recorder`
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersserviceserverSWServercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/service/server/SWServer.cpp (283273 => 283274)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/server/SWServer.cpp 2021-09-29 23:04:52 UTC (rev 283273)
+++ trunk/Source/WebCore/workers/service/server/SWServer.cpp    2021-09-29 23:08:05 UTC (rev 283274)
</span><span class="lines">@@ -440,11 +440,7 @@
</span><span class="cx"> 
</span><span class="cx"> URL static inline originURL(const SecurityOrigin& origin)
</span><span class="cx"> {
</span><del>-    URL url;
-    url.setProtocol(origin.protocol());
-    url.setHost(origin.host());
-    url.setPort(origin.port());
-    return url;
</del><ins>+    return URL(URL(), origin.data().toString());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void SWServer::startScriptFetch(const ServiceWorkerJobData& jobData, SWServerRegistration& registration)
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (283273 => 283274)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2021-09-29 23:04:52 UTC (rev 283273)
+++ trunk/Source/WebKit/ChangeLog       2021-09-29 23:08:05 UTC (rev 283274)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2021-09-29  Chris Dumez  <cdumez@apple.com>
+
+        Use isolated NSURLSessions for each first party registrable domain
+        https://bugs.webkit.org/show_bug.cgi?id=230750
+        <rdar://83159358>
+
+        Reviewed by Alex Christensen.
+
+        Previously would use up to 10 isolated NSURLSessions only for domains marked as prevalent
+        by ITP *and* that the user interacts with as first party website. We now use different
+        isolated NSURLSession for each top-level registrable domain, not matter their ITP status.
+        This significantly improves privacy.
+
+        To avoid having too many NSURLSession, we clear the ones that haven't been used in the
+        last 10 minutes, every time we add a new one.
+
+        * NetworkProcess/cocoa/NetworkSessionCocoa.h:
+        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+        (WebKit::NetworkSessionCocoa::sessionWrapperForTask):
+        (WebKit::SessionSet::isolatedSession):
+
</ins><span class="cx"> 2021-09-29  Sihui Liu  <sihui_liu@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Replace FileSystemHandleImpl with FileSystemStorageConnection
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcesscocoaNetworkSessionCocoah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h (283273 => 283274)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h   2021-09-29 23:04:52 UTC (rev 283273)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h      2021-09-29 23:08:05 UTC (rev 283274)
</span><span class="lines">@@ -69,7 +69,7 @@
</span><span class="cx"> public:
</span><span class="cx">     SessionWrapper sessionWithCredentialStorage;
</span><span class="cx">     SessionWrapper sessionWithoutCredentialStorage;
</span><del>-    WallTime lastUsed;
</del><ins>+    MonotonicTime lastUsed;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> struct SessionSet : public RefCounted<SessionSet>, public CanMakeWeakPtr<SessionSet> {
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcesscocoaNetworkSessionCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm (283273 => 283274)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm  2021-09-29 23:04:52 UTC (rev 283273)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm     2021-09-29 23:08:05 UTC (rev 283274)
</span><span class="lines">@@ -97,8 +97,6 @@
</span><span class="cx"> CFStringRef const WebKit2HTTPProxyDefaultsKey = static_cast<CFStringRef>(@"WebKit2HTTPProxy");
</span><span class="cx"> CFStringRef const WebKit2HTTPSProxyDefaultsKey = static_cast<CFStringRef>(@"WebKit2HTTPSProxy");
</span><span class="cx"> 
</span><del>-constexpr unsigned maxNumberOfIsolatedSessions { 10 };
-
</del><span class="cx"> static NSURLSessionResponseDisposition toNSURLSessionResponseDisposition(WebCore::PolicyAction disposition)
</span><span class="cx"> {
</span><span class="cx">     switch (disposition) {
</span><span class="lines">@@ -1440,14 +1438,6 @@
</span><span class="cx">     auto shouldBeConsideredAppBound = isNavigatingToAppBoundDomain ? *isNavigatingToAppBoundDomain : NavigatingToAppBoundDomain::Yes;
</span><span class="cx">     if (isParentProcessAFullWebBrowser(networkProcess()))
</span><span class="cx">         shouldBeConsideredAppBound = NavigatingToAppBoundDomain::No;
</span><del>-#if ENABLE(INTELLIGENT_TRACKING_PREVENTION)
-    if (auto* storageSession = networkStorageSession()) {
-        auto firstParty = WebCore::RegistrableDomain(request.firstPartyForCookies());
-        if (storageSession->shouldBlockThirdPartyCookiesButKeepFirstPartyCookiesFor(firstParty))
-            return sessionSetForPage(webPageProxyID).isolatedSession(storedCredentialsPolicy, firstParty, shouldBeConsideredAppBound, *this);
-    } else
-        ASSERT_NOT_REACHED();
-#endif
</del><span class="cx"> 
</span><span class="cx"> #if ENABLE(APP_BOUND_DOMAINS)
</span><span class="cx">     if (shouldBeConsideredAppBound == NavigatingToAppBoundDomain::Yes)
</span><span class="lines">@@ -1454,14 +1444,11 @@
</span><span class="cx">         return appBoundSession(webPageProxyID, storedCredentialsPolicy);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    switch (storedCredentialsPolicy) {
-    case WebCore::StoredCredentialsPolicy::Use:
-        return sessionSetForPage(webPageProxyID).sessionWithCredentialStorage;
-    case WebCore::StoredCredentialsPolicy::DoNotUse:
-        return sessionSetForPage(webPageProxyID).sessionWithoutCredentialStorage;
-    case WebCore::StoredCredentialsPolicy::EphemeralStateless:
-        return initializeEphemeralStatelessSessionIfNeeded(webPageProxyID, NavigatingToAppBoundDomain::No);
-    }
</del><ins>+    auto firstParty = WebCore::RegistrableDomain(request.firstPartyForCookies());
+    if (firstParty.isEmpty())
+        firstParty = WebCore::RegistrableDomain(request.url());
+
+    return sessionSetForPage(webPageProxyID).isolatedSession(storedCredentialsPolicy, firstParty, shouldBeConsideredAppBound, *this);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(APP_BOUND_DOMAINS)
</span><span class="lines">@@ -1518,44 +1505,36 @@
</span><span class="cx"> 
</span><span class="cx"> SessionWrapper& SessionSet::isolatedSession(WebCore::StoredCredentialsPolicy storedCredentialsPolicy, const WebCore::RegistrableDomain firstPartyDomain, NavigatingToAppBoundDomain isNavigatingToAppBoundDomain, NetworkSessionCocoa& session)
</span><span class="cx"> {
</span><del>-    auto& entry = isolatedSessions.ensure(firstPartyDomain, [this, &session, isNavigatingToAppBoundDomain] {
</del><ins>+    auto addResult = isolatedSessions.ensure(firstPartyDomain, [this, &session, isNavigatingToAppBoundDomain] {
</ins><span class="cx">         auto newEntry = makeUnique<IsolatedSession>();
</span><span class="cx">         newEntry->sessionWithCredentialStorage.initialize(sessionWithCredentialStorage.session.get().configuration, session, WebCore::StoredCredentialsPolicy::Use, isNavigatingToAppBoundDomain);
</span><span class="cx">         newEntry->sessionWithoutCredentialStorage.initialize(sessionWithoutCredentialStorage.session.get().configuration, session, WebCore::StoredCredentialsPolicy::DoNotUse, isNavigatingToAppBoundDomain);
</span><span class="cx">         return newEntry;
</span><del>-    }).iterator->value;
</del><ins>+    });
</ins><span class="cx"> 
</span><del>-    entry->lastUsed = WallTime::now();
</del><ins>+    auto now = MonotonicTime::now();
+    auto& isolatedSession = addResult.iterator->value;
+    isolatedSession->lastUsed = now;
</ins><span class="cx"> 
</span><span class="cx">     auto& sessionWrapper = [&] (auto storedCredentialsPolicy) -> SessionWrapper& {
</span><span class="cx">         switch (storedCredentialsPolicy) {
</span><span class="cx">         case WebCore::StoredCredentialsPolicy::Use:
</span><span class="cx">             LOG(NetworkSession, "Using isolated NSURLSession with credential storage.");
</span><del>-            return entry->sessionWithCredentialStorage;
</del><ins>+            return isolatedSession->sessionWithCredentialStorage;
</ins><span class="cx">         case WebCore::StoredCredentialsPolicy::DoNotUse:
</span><span class="cx">             LOG(NetworkSession, "Using isolated NSURLSession without credential storage.");
</span><del>-            return entry->sessionWithoutCredentialStorage;
</del><ins>+            return isolatedSession->sessionWithoutCredentialStorage;
</ins><span class="cx">         case WebCore::StoredCredentialsPolicy::EphemeralStateless:
</span><span class="cx">             return initializeEphemeralStatelessSessionIfNeeded(isNavigatingToAppBoundDomain, session);
</span><span class="cx">         }
</span><span class="cx">     } (storedCredentialsPolicy);
</span><span class="cx"> 
</span><del>-    if (isolatedSessions.size() > maxNumberOfIsolatedSessions) {
-        WebCore::RegistrableDomain keyToRemove;
-        auto oldestTimestamp = WallTime::now();
-        for (auto& key : isolatedSessions.keys()) {
-            auto timestamp = isolatedSessions.get(key)->lastUsed;
-            if (timestamp < oldestTimestamp) {
-                oldestTimestamp = timestamp;
-                keyToRemove = key;
-            }
-        }
-        LOG(NetworkSession, "About to remove isolated NSURLSession.");
-        isolatedSessions.remove(keyToRemove);
</del><ins>+    if (addResult.isNewEntry) {
+        isolatedSessions.removeIf([&](auto& entry) {
+            return (now - entry.value->lastUsed) > 10_min;
+        });
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    RELEASE_ASSERT(isolatedSessions.size() <= maxNumberOfIsolatedSessions);
-
</del><span class="cx">     return sessionWrapper;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>