<!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>[238368] 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/238368">238368</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2018-11-18 23:14:51 -0800 (Sun, 18 Nov 2018)</dd>
</dl>

<h3>Log Message</h3>
<pre>[PSON] Received an invalid message "WebPageProxy.DidPerformClientRedirect" from the web process
https://bugs.webkit.org/show_bug.cgi?id=191828

Reviewed by Antti Koivisto.

Source/WebKit:

WebPageProxy::didPerformClientRedirect() had a MESSAGE_CHECK_URL() for both the source
and the destination URL. The macro calls WebProcessProxy::checkURLReceivedFromWebProcess()
to make sure that both URLs were actually loaded by this WebContent process.

However, now that we're enabled process-swap on cross-site navigation, these checks are no
longer fully valid. If the client-side redirect is cross-site, then the source and destination
URLs get loaded by 2 different WebContent processes. Since didPerformClientRedirect() gets
called after the redirect and gets set by the new WebContent process, only the destination URL
is guaranteed to have been loaded by this process. The source URL may have been loaded in
another process so this patch drops the message check for the source URL.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didPerformClientRedirect):

Tools:

Add API test coverage.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
* TestWebKitAPI/Tests/WebKitCocoa/client-side-redirect.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxycpp">trunk/Source/WebKit/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitCocoaProcessSwapOnNavigationmm">trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitCocoaclientsideredirecthtml">trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/client-side-redirect.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (238367 => 238368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2018-11-19 06:51:54 UTC (rev 238367)
+++ trunk/Source/WebKit/ChangeLog       2018-11-19 07:14:51 UTC (rev 238368)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2018-11-18  Chris Dumez  <cdumez@apple.com>
+
+        [PSON] Received an invalid message "WebPageProxy.DidPerformClientRedirect" from the web process
+        https://bugs.webkit.org/show_bug.cgi?id=191828
+
+        Reviewed by Antti Koivisto.
+
+        WebPageProxy::didPerformClientRedirect() had a MESSAGE_CHECK_URL() for both the source
+        and the destination URL. The macro calls WebProcessProxy::checkURLReceivedFromWebProcess()
+        to make sure that both URLs were actually loaded by this WebContent process.
+
+        However, now that we're enabled process-swap on cross-site navigation, these checks are no
+        longer fully valid. If the client-side redirect is cross-site, then the source and destination
+        URLs get loaded by 2 different WebContent processes. Since didPerformClientRedirect() gets
+        called after the redirect and gets set by the new WebContent process, only the destination URL
+        is guaranteed to have been loaded by this process. The source URL may have been loaded in
+        another process so this patch drops the message check for the source URL.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::didPerformClientRedirect):
+
</ins><span class="cx"> 2018-11-18  Yusuke Suzuki  <yusukesuzuki@slowstart.org>
</span><span class="cx"> 
</span><span class="cx">         Use Box<BinarySemaphore> instead of dispatch_semaphore_t
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (238367 => 238368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp   2018-11-19 06:51:54 UTC (rev 238367)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp      2018-11-19 07:14:51 UTC (rev 238368)
</span><span class="lines">@@ -4442,8 +4442,6 @@
</span><span class="cx">     WebFrameProxy* frame = m_process->webFrame(frameID);
</span><span class="cx">     MESSAGE_CHECK(frame);
</span><span class="cx">     MESSAGE_CHECK(frame->page() == this);
</span><del>-
-    MESSAGE_CHECK_URL(sourceURLString);
</del><span class="cx">     MESSAGE_CHECK_URL(destinationURLString);
</span><span class="cx"> 
</span><span class="cx">     if (frame->isMainFrame()) {
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (238367 => 238368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2018-11-19 06:51:54 UTC (rev 238367)
+++ trunk/Tools/ChangeLog       2018-11-19 07:14:51 UTC (rev 238368)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2018-11-18  Chris Dumez  <cdumez@apple.com>
+
+        [PSON] Received an invalid message "WebPageProxy.DidPerformClientRedirect" from the web process
+        https://bugs.webkit.org/show_bug.cgi?id=191828
+
+        Reviewed by Antti Koivisto.
+
+        Add API test coverage.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
+        * TestWebKitAPI/Tests/WebKitCocoa/client-side-redirect.html: Added.
+
</ins><span class="cx"> 2018-11-17  Wenson Hsieh  <wenson_hsieh@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [iOS] Remove all usages of UIItemProvider, UIItemProviderReading, and related classes
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (238367 => 238368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2018-11-19 06:51:54 UTC (rev 238367)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj   2018-11-19 07:14:51 UTC (rev 238368)
</span><span class="lines">@@ -587,6 +587,7 @@
</span><span class="cx">          8361F1781E610B4E00759B25 /* link-with-download-attribute-with-slashes.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 8361F1771E610B2100759B25 /* link-with-download-attribute-with-slashes.html */; };
</span><span class="cx">          83779C381F82FECE007CDA8A /* VisitedLinkStore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83779C371F82FEB0007CDA8A /* VisitedLinkStore.mm */; };
</span><span class="cx">          837A35F11D9A1E7D00663C57 /* DownloadRequestBlobURL.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 837A35F01D9A1E6400663C57 /* DownloadRequestBlobURL.html */; };
</span><ins>+               839AA35F21A26B0300980DD6 /* client-side-redirect.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 839AA35E21A26ACD00980DD6 /* client-side-redirect.html */; };
</ins><span class="cx">           83B6DE6F1EE75221001E792F /* RestoreSessionState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83B6DE6E1EE7520F001E792F /* RestoreSessionState.cpp */; };
</span><span class="cx">          83BAEE8D1EF4625500DDE894 /* PluginLoadClientPolicies.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83BAEE8C1EF4625500DDE894 /* PluginLoadClientPolicies.mm */; };
</span><span class="cx">          83BC5AC020E6C0DF00F5879F /* StartLoadInDidFailProvisionalLoad.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83BC5ABF20E6C0D300F5879F /* StartLoadInDidFailProvisionalLoad.mm */; };
</span><span class="lines">@@ -998,6 +999,7 @@
</span><span class="cx">                          2EFF06C51D8867760004BB30 /* change-video-source-on-click.html in Copy Resources */,
</span><span class="cx">                          2EFF06C71D886A580004BB30 /* change-video-source-on-end.html in Copy Resources */,
</span><span class="cx">                          9BD4239C1E04C01C00200395 /* chinese-character-with-image.html in Copy Resources */,
</span><ins>+                               839AA35F21A26B0300980DD6 /* client-side-redirect.html in Copy Resources */,
</ins><span class="cx">                           1A50AA201A2A51FC00F4C345 /* close-from-within-create-page.html in Copy Resources */,
</span><span class="cx">                          9B270FEE1DDC2C0B002D53F3 /* closed-shadow-tree-test.html in Copy Resources */,
</span><span class="cx">                          E5036F78211BC25400BFDBE2 /* color-drop.html in Copy Resources */,
</span><span class="lines">@@ -1736,6 +1738,7 @@
</span><span class="cx">          8361F1771E610B2100759B25 /* link-with-download-attribute-with-slashes.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "link-with-download-attribute-with-slashes.html"; sourceTree = "<group>"; };
</span><span class="cx">          83779C371F82FEB0007CDA8A /* VisitedLinkStore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = VisitedLinkStore.mm; sourceTree = "<group>"; };
</span><span class="cx">          837A35F01D9A1E6400663C57 /* DownloadRequestBlobURL.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DownloadRequestBlobURL.html; sourceTree = "<group>"; };
</span><ins>+               839AA35E21A26ACD00980DD6 /* client-side-redirect.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "client-side-redirect.html"; sourceTree = "<group>"; };
</ins><span class="cx">           83B6DE6E1EE7520F001E792F /* RestoreSessionState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RestoreSessionState.cpp; sourceTree = "<group>"; };
</span><span class="cx">          83B88A331C80056D00BB2418 /* HTMLParserIdioms.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLParserIdioms.cpp; sourceTree = "<group>"; };
</span><span class="cx">          83BAEE8C1EF4625500DDE894 /* PluginLoadClientPolicies.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PluginLoadClientPolicies.mm; sourceTree = "<group>"; };
</span><span class="lines">@@ -2720,6 +2723,7 @@
</span><span class="cx">                          2DE71AFF1D49C2F000904094 /* blinking-div.html */,
</span><span class="cx">                          2EFF06C41D8867700004BB30 /* change-video-source-on-click.html */,
</span><span class="cx">                          2EFF06C61D886A560004BB30 /* change-video-source-on-end.html */,
</span><ins>+                               839AA35E21A26ACD00980DD6 /* client-side-redirect.html */,
</ins><span class="cx">                           E5036F77211BC22800BFDBE2 /* color-drop.html */,
</span><span class="cx">                          F4B825D61EF4DBD4006E417F /* compressed-files.zip */,
</span><span class="cx">                          F469FB231F01803500401539 /* contenteditable-and-target.html */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitCocoaProcessSwapOnNavigationmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm (238367 => 238368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm   2018-11-19 06:51:54 UTC (rev 238367)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm      2018-11-19 07:14:51 UTC (rev 238368)
</span><span class="lines">@@ -1457,6 +1457,44 @@
</span><span class="cx">     runClientSideRedirectTest(ShouldEnablePSON::Yes);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+TEST(ProcessSwap, CrossSiteClientSideRedirectFromFileURL)
+{
+    auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]);
+    processPoolConfiguration.get().processSwapsOnNavigation = YES;
+    processPoolConfiguration.get().prewarmsProcessesAutomatically = YES;
+    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:@"pson"];
+
+    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
+    auto delegate = adoptNS([[PSONNavigationDelegate alloc] init]);
+    [webView setNavigationDelegate:delegate.get()];
+
+    willPerformClientRedirect = false;
+    didPerformClientRedirect = false;
+
+    NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"client-side-redirect" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+    [webView loadRequest:request];
+
+    TestWebKitAPI::Util::run(&done);
+    done = false;
+
+    auto pid1 = [webView _webProcessIdentifier];
+
+    TestWebKitAPI::Util::run(&done);
+    done = false;
+
+    auto pid2 = [webView _webProcessIdentifier];
+    EXPECT_NE(pid1, pid2);
+
+    EXPECT_EQ(2U, [processPool _webProcessCountIgnoringPrewarmed]);
+    EXPECT_TRUE(willPerformClientRedirect);
+    EXPECT_TRUE(didPerformClientRedirect);
+}
+
</ins><span class="cx"> static void runNavigationWithLockedHistoryTest(ShouldEnablePSON shouldEnablePSON)
</span><span class="cx"> {
</span><span class="cx">     auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]);
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitCocoaclientsideredirecthtml"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/client-side-redirect.html (0 => 238368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/client-side-redirect.html                            (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/client-side-redirect.html       2018-11-19 07:14:51 UTC (rev 238368)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<body>
+<script>
+onload = () => {
+  location = "pson://www.apple.com/main.html";
+};
+</script>
+</body>
+</html>
</ins></span></pre>
</div>
</div>

</body>
</html>