<!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>[279079] 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/279079">279079</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2021-06-21 13:47:29 -0700 (Mon, 21 Jun 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>[WK2] Don't process-swap on navigations within the same non-HTTP(s) protocol
https://bugs.webkit.org/show_bug.cgi?id=227220

Reviewed by Tim Horton.

Source/WebKit:

Don't process-swap on navigations within the same non-HTTP(s) protocol. Trying to extract registrable domains
from non-HTTP(s) URLs does not make much sense and leads to unexpected process swaps.

* UIProcess/API/APIProcessPoolConfiguration.cpp:
(API::ProcessPoolConfiguration::copy):
* UIProcess/API/APIProcessPoolConfiguration.h:
* UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
* UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
(-[_WKProcessPoolConfiguration setProcessSwapsOnNavigationWithinSameNonHTTPFamilyProtocol:]):
(-[_WKProcessPoolConfiguration processSwapsOnNavigationWithinSameNonHTTPFamilyProtocol]):
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::processForNavigationInternal):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::didStartProvisionalLoadForMainFrame):

Tools:

Add API test coverage.

* TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPIAPIProcessPoolConfigurationcpp">trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPIAPIProcessPoolConfigurationh">trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoa_WKProcessPoolConfigurationh">trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoa_WKProcessPoolConfigurationmm">trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebProcessPoolcpp">trunk/Source/WebKit/UIProcess/WebProcessPool.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebProcessProxycpp">trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitCocoaProcessSwapOnNavigationmm">trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitCocoaResourceLoadStatisticsmm">trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitCocoaWKWebViewEvaluateJavaScriptmm">trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewEvaluateJavaScript.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (279078 => 279079)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2021-06-21 20:44:49 UTC (rev 279078)
+++ trunk/Source/WebKit/ChangeLog       2021-06-21 20:47:29 UTC (rev 279079)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2021-06-21  Chris Dumez  <cdumez@apple.com>
+
+        [WK2] Don't process-swap on navigations within the same non-HTTP(s) protocol
+        https://bugs.webkit.org/show_bug.cgi?id=227220
+
+        Reviewed by Tim Horton.
+
+        Don't process-swap on navigations within the same non-HTTP(s) protocol. Trying to extract registrable domains
+        from non-HTTP(s) URLs does not make much sense and leads to unexpected process swaps.
+
+        * UIProcess/API/APIProcessPoolConfiguration.cpp:
+        (API::ProcessPoolConfiguration::copy):
+        * UIProcess/API/APIProcessPoolConfiguration.h:
+        * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
+        * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
+        (-[_WKProcessPoolConfiguration setProcessSwapsOnNavigationWithinSameNonHTTPFamilyProtocol:]):
+        (-[_WKProcessPoolConfiguration processSwapsOnNavigationWithinSameNonHTTPFamilyProtocol]):
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::processForNavigationInternal):
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::didStartProvisionalLoadForMainFrame):
+
</ins><span class="cx"> 2021-06-21  Megan Gardner  <megan_gardner@apple.com>
</span><span class="cx"> 
</span><span class="cx">         AppHighlights disappear on page reload
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPIAPIProcessPoolConfigurationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.cpp (279078 => 279079)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.cpp        2021-06-21 20:44:49 UTC (rev 279078)
+++ trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.cpp   2021-06-21 20:47:29 UTC (rev 279079)
</span><span class="lines">@@ -64,6 +64,7 @@
</span><span class="cx">     copy->m_processSwapsOnNavigationFromExperimentalFeatures = this->m_processSwapsOnNavigationFromExperimentalFeatures;
</span><span class="cx">     copy->m_alwaysKeepAndReuseSwappedProcesses = this->m_alwaysKeepAndReuseSwappedProcesses;
</span><span class="cx">     copy->m_processSwapsOnWindowOpenWithOpener = this->m_processSwapsOnWindowOpenWithOpener;
</span><ins>+    copy->m_processSwapsOnNavigationWithinSameNonHTTPFamilyProtocol = this->m_processSwapsOnNavigationWithinSameNonHTTPFamilyProtocol;
</ins><span class="cx">     copy->m_isAutomaticProcessWarmingEnabledByClient = this->m_isAutomaticProcessWarmingEnabledByClient;
</span><span class="cx">     copy->m_usesWebProcessCache = this->m_usesWebProcessCache;
</span><span class="cx">     copy->m_usesBackForwardCache = this->m_usesBackForwardCache;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPIAPIProcessPoolConfigurationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h (279078 => 279079)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h  2021-06-21 20:44:49 UTC (rev 279078)
+++ trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h     2021-06-21 20:47:29 UTC (rev 279079)
</span><span class="lines">@@ -128,6 +128,9 @@
</span><span class="cx">     bool alwaysKeepAndReuseSwappedProcesses() const { return m_alwaysKeepAndReuseSwappedProcesses; }
</span><span class="cx">     void setAlwaysKeepAndReuseSwappedProcesses(bool keepAndReuse) { m_alwaysKeepAndReuseSwappedProcesses = keepAndReuse; }
</span><span class="cx"> 
</span><ins>+    bool processSwapsOnNavigationWithinSameNonHTTPFamilyProtocol() const { return m_processSwapsOnNavigationWithinSameNonHTTPFamilyProtocol; }
+    void setProcessSwapsOnNavigationWithinSameNonHTTPFamilyProtocol(bool swaps) { m_processSwapsOnNavigationWithinSameNonHTTPFamilyProtocol = swaps; }
+
</ins><span class="cx">     bool processSwapsOnWindowOpenWithOpener() const { return m_processSwapsOnWindowOpenWithOpener; }
</span><span class="cx">     void setProcessSwapsOnWindowOpenWithOpener(bool swaps) { m_processSwapsOnWindowOpenWithOpener = swaps; }
</span><span class="cx"> 
</span><span class="lines">@@ -169,6 +172,7 @@
</span><span class="cx">     bool m_processSwapsOnNavigationFromExperimentalFeatures { false };
</span><span class="cx">     bool m_alwaysKeepAndReuseSwappedProcesses { false };
</span><span class="cx">     bool m_processSwapsOnWindowOpenWithOpener { false };
</span><ins>+    bool m_processSwapsOnNavigationWithinSameNonHTTPFamilyProtocol { false };
</ins><span class="cx">     std::optional<bool> m_isAutomaticProcessWarmingEnabledByClient;
</span><span class="cx">     bool m_usesWebProcessCache { false };
</span><span class="cx">     bool m_usesBackForwardCache { true };
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoa_WKProcessPoolConfigurationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h (279078 => 279079)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h    2021-06-21 20:44:49 UTC (rev 279078)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h       2021-06-21 20:47:29 UTC (rev 279079)
</span><span class="lines">@@ -67,6 +67,7 @@
</span><span class="cx"> @property (nonatomic) BOOL processSwapsOnNavigation WK_API_AVAILABLE(macos(10.14), ios(12.0));
</span><span class="cx"> @property (nonatomic) BOOL alwaysKeepAndReuseSwappedProcesses WK_API_AVAILABLE(macos(10.14), ios(12.0));
</span><span class="cx"> @property (nonatomic) BOOL processSwapsOnWindowOpenWithOpener WK_API_AVAILABLE(macos(10.14), ios(12.0));
</span><ins>+@property (nonatomic) BOOL processSwapsOnNavigationWithinSameNonHTTPFamilyProtocol WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
</ins><span class="cx"> @property (nonatomic) BOOL prewarmsProcessesAutomatically WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
</span><span class="cx"> @property (nonatomic) BOOL usesWebProcessCache WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
</span><span class="cx"> @property (nonatomic) BOOL pageCacheEnabled WK_API_AVAILABLE(macos(10.14), ios(12.0));
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoa_WKProcessPoolConfigurationmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm (279078 => 279079)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm   2021-06-21 20:44:49 UTC (rev 279078)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm      2021-06-21 20:47:29 UTC (rev 279079)
</span><span class="lines">@@ -285,6 +285,16 @@
</span><span class="cx">     return _processPoolConfiguration->processSwapsOnWindowOpenWithOpener();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)setProcessSwapsOnNavigationWithinSameNonHTTPFamilyProtocol:(BOOL)swaps
+{
+    _processPoolConfiguration->setProcessSwapsOnNavigationWithinSameNonHTTPFamilyProtocol(swaps);
+}
+
+- (BOOL)processSwapsOnNavigationWithinSameNonHTTPFamilyProtocol
+{
+    return _processPoolConfiguration->processSwapsOnNavigationWithinSameNonHTTPFamilyProtocol();
+}
+
</ins><span class="cx"> - (BOOL)pageCacheEnabled
</span><span class="cx"> {
</span><span class="cx">     return _processPoolConfiguration->usesBackForwardCache();
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebProcessPoolcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (279078 => 279079)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2021-06-21 20:44:49 UTC (rev 279078)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp    2021-06-21 20:47:29 UTC (rev 279079)
</span><span class="lines">@@ -1844,6 +1844,10 @@
</span><span class="cx">         WEBPROCESSPOOL_RELEASE_LOG(ProcessSwapping, "processForNavigationInternal: Using related page's URL as source URL for process swap decision (page=%p)", page.configuration().relatedPage());
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    // For non-HTTP(s) URLs, we only swap when navigating to a new scheme, unless processSwapsOnNavigationWithinSameNonHTTPFamilyProtocol is set.
+    if (!m_configuration->processSwapsOnNavigationWithinSameNonHTTPFamilyProtocol() && !sourceURL.protocolIsInHTTPFamily() && sourceURL.protocol() == targetURL.protocol())
+        return completionHandler(WTFMove(sourceProcess), nullptr, "Navigation within the same non-HTTP(s) protocol"_s);
+
</ins><span class="cx">     if (!sourceURL.isValid() || !targetURL.isValid() || sourceURL.isEmpty() || sourceURL.protocolIsAbout() || targetRegistrableDomain.matches(sourceURL))
</span><span class="cx">         return completionHandler(WTFMove(sourceProcess), nullptr, "Navigation is same-site"_s);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebProcessProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp (279078 => 279079)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp        2021-06-21 20:44:49 UTC (rev 279078)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp   2021-06-21 20:47:29 UTC (rev 279079)
</span><span class="lines">@@ -1626,6 +1626,13 @@
</span><span class="cx">     if (url.protocolIsAbout())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+    if (!url.protocolIsInHTTPFamily() && !processPool().configuration().processSwapsOnNavigationWithinSameNonHTTPFamilyProtocol()) {
+        // Unless the processSwapsOnNavigationWithinSameNonHTTPFamilyProtocol flag is set, we don't process swap on navigations withing the same
+        // non HTTP(s) protocol. For this reason, we ignore the registrable domain and processes are not eligible for the process cache.
+        m_registrableDomain = WebCore::RegistrableDomain { };
+        return;
+    }
+
</ins><span class="cx">     auto registrableDomain = WebCore::RegistrableDomain { url };
</span><span class="cx">     if (m_registrableDomain && *m_registrableDomain != registrableDomain) {
</span><span class="cx"> #if ENABLE(SERVICE_WORKER)
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (279078 => 279079)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2021-06-21 20:44:49 UTC (rev 279078)
+++ trunk/Tools/ChangeLog       2021-06-21 20:47:29 UTC (rev 279079)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2021-06-21  Chris Dumez  <cdumez@apple.com>
+
+        [WK2] Don't process-swap on navigations within the same non-HTTP(s) protocol
+        https://bugs.webkit.org/show_bug.cgi?id=227220
+
+        Reviewed by Tim Horton.
+
+        Add API test coverage.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
+
</ins><span class="cx"> 2021-06-21  Alex Christensen  <achristensen@webkit.org>
</span><span class="cx"> 
</span><span class="cx">         Break ref cycle between API::HTTPCookieStore and WebKit::WebsiteDataStore
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitCocoaProcessSwapOnNavigationmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm (279078 => 279079)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm   2021-06-21 20:44:49 UTC (rev 279078)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm      2021-06-21 20:47:29 UTC (rev 279079)
</span><span class="lines">@@ -506,6 +506,7 @@
</span><span class="cx">     processPoolConfiguration.get().processSwapsOnNavigation = YES;
</span><span class="cx">     processPoolConfiguration.get().usesWebProcessCache = YES;
</span><span class="cx">     processPoolConfiguration.get().prewarmsProcessesAutomatically = YES;
</span><ins>+    processPoolConfiguration.get().processSwapsOnNavigationWithinSameNonHTTPFamilyProtocol = YES;
</ins><span class="cx">     return processPoolConfiguration;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -566,6 +567,57 @@
</span><span class="cx">     runBasicTest(SchemeHandlerShouldBeAsync::Yes);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+TEST(ProcessSwap, NoProcessSwappingWithinSameNonHTTPFamilyProtocol)
+{
+    auto processPoolConfiguration = psonProcessPoolConfiguration();
+    processPoolConfiguration.get().processSwapsOnNavigationWithinSameNonHTTPFamilyProtocol = NO;
+    auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
+
+    auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    [webViewConfiguration setProcessPool:processPool.get()];
+    auto handler = adoptNS([[PSONScheme alloc] init]);
+    [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"CUSTOM"];
+
+    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
+    auto delegate = adoptNS([[PSONNavigationDelegate alloc] init]);
+    [webView setNavigationDelegate:delegate.get()];
+
+    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"custom://abc/main1.html"]];
+    [webView loadRequest:request];
+    TestWebKitAPI::Util::run(&done);
+    done = false;
+
+    auto pid1 = [webView _webProcessIdentifier];
+
+    request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"custom://def/main2.html"]];
+    [webView loadRequest:request];
+    TestWebKitAPI::Util::run(&done);
+    done = false;
+
+    EXPECT_EQ(pid1, [webView _webProcessIdentifier]);
+
+    request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"custom://ghi/main3.html"]];
+    [webView loadRequest:request];
+    TestWebKitAPI::Util::run(&done);
+    done = false;
+
+    EXPECT_EQ(pid1, [webView _webProcessIdentifier]);
+
+    // Switch to the file protocol.
+    [webView loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
+    TestWebKitAPI::Util::run(&done);
+    done = false;
+
+    auto pid2 = [webView _webProcessIdentifier];
+    EXPECT_NE(pid1, pid2);
+
+    [webView loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"simple2" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
+    TestWebKitAPI::Util::run(&done);
+    done = false;
+
+    EXPECT_EQ(pid2, [webView _webProcessIdentifier]);
+}
+
</ins><span class="cx"> TEST(ProcessSwap, LoadAfterPolicyDecision)
</span><span class="cx"> {
</span><span class="cx">     auto processPoolConfiguration = psonProcessPoolConfiguration();
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitCocoaResourceLoadStatisticsmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm (279078 => 279079)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm    2021-06-21 20:44:49 UTC (rev 279078)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm       2021-06-21 20:47:29 UTC (rev 279079)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> #import <WebKit/WKWebViewConfigurationPrivate.h>
</span><span class="cx"> #import <WebKit/WKWebsiteDataRecordPrivate.h>
</span><span class="cx"> #import <WebKit/WKWebsiteDataStorePrivate.h>
</span><ins>+#import <WebKit/_WKProcessPoolConfiguration.h>
</ins><span class="cx"> #import <WebKit/_WKWebsiteDataStoreConfiguration.h>
</span><span class="cx"> #import <wtf/RetainPtr.h>
</span><span class="cx"> 
</span><span class="lines">@@ -1338,11 +1339,16 @@
</span><span class="cx"> 
</span><span class="cx"> TEST(ResourceLoadStatistics, BackForwardPerPageData)
</span><span class="cx"> {
</span><ins>+    auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]);
+    processPoolConfiguration.get().processSwapsOnNavigationWithinSameNonHTTPFamilyProtocol = YES;
+    auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
+
</ins><span class="cx">     auto *dataStore = [WKWebsiteDataStore defaultDataStore];
</span><span class="cx">     auto delegate = adoptNS([TestNavigationDelegate new]);
</span><span class="cx"> 
</span><span class="cx">     auto schemeHandler = adoptNS([[ResourceLoadStatisticsSchemeHandler alloc] init]);
</span><span class="cx">     auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
</span><ins>+    [configuration setProcessPool:processPool.get()];
</ins><span class="cx">     [configuration setURLSchemeHandler:schemeHandler.get() forURLScheme:@"resource-load-statistics"];
</span><span class="cx"> 
</span><span class="cx">     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitCocoaWKWebViewEvaluateJavaScriptmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewEvaluateJavaScript.mm (279078 => 279079)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewEvaluateJavaScript.mm       2021-06-21 20:44:49 UTC (rev 279078)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewEvaluateJavaScript.mm  2021-06-21 20:47:29 UTC (rev 279079)
</span><span class="lines">@@ -38,10 +38,12 @@
</span><span class="cx"> #import <WebKit/WKErrorPrivate.h>
</span><span class="cx"> #import <WebKit/WKPreferencesPrivate.h>
</span><span class="cx"> #import <WebKit/WKPreferencesRef.h>
</span><ins>+#import <WebKit/WKProcessPoolPrivate.h>
</ins><span class="cx"> #import <WebKit/WKUserContentControllerPrivate.h>
</span><span class="cx"> #import <WebKit/WKWebViewConfigurationPrivate.h>
</span><span class="cx"> #import <WebKit/WKWebViewPrivate.h>
</span><span class="cx"> #import <WebKit/_WKFrameTreeNode.h>
</span><ins>+#import <WebKit/_WKProcessPoolConfiguration.h>
</ins><span class="cx"> #import <wtf/RetainPtr.h>
</span><span class="cx"> 
</span><span class="cx"> static bool isDone;
</span><span class="lines">@@ -750,6 +752,10 @@
</span><span class="cx"> // This test verifies that evaluating JavaScript in a frame from the previous main navigation results in an error
</span><span class="cx"> TEST(EvaluateJavaScript, JavaScriptInMissingFrameAfterNavigationError)
</span><span class="cx"> {
</span><ins>+    auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]);
+    processPoolConfiguration.get().processSwapsOnNavigationWithinSameNonHTTPFamilyProtocol = YES;
+    auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
+
</ins><span class="cx">     allFrames = adoptNS([[NSMutableSet<WKFrameInfo *> alloc] init]);
</span><span class="cx"> 
</span><span class="cx">     auto handler = adoptNS([[TestURLSchemeHandler alloc] init]);
</span><span class="lines">@@ -774,6 +780,7 @@
</span><span class="cx">     }];
</span><span class="cx"> 
</span><span class="cx">     auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
</span><ins>+    [configuration setProcessPool:processPool.get()];
</ins><span class="cx">     [configuration setURLSchemeHandler:handler.get() forURLScheme:@"framestest"];
</span><span class="cx">     [configuration setURLSchemeHandler:handler.get() forURLScheme:@"otherprotocol"];
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>