<!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>[260369] branches/safari-609-branch</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/260369">260369</a></dd>
<dt>Author</dt> <dd>repstein@apple.com</dd>
<dt>Date</dt> <dd>2020-04-20 09:23:25 -0700 (Mon, 20 Apr 2020)</dd>
</dl>

<h3>Log Message</h3>
<pre>Apply patch. rdar://problem/61950472</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari609branchSourceWebKitChangeLog">branches/safari-609-branch/Source/WebKit/ChangeLog</a></li>
<li><a href="#branchessafari609branchSourceWebKitSharedWebPageCreationParametersh">branches/safari-609-branch/Source/WebKit/Shared/WebPageCreationParameters.h</a></li>
<li><a href="#branchessafari609branchSourceWebKitUIProcessAPIAPINavigationcpp">branches/safari-609-branch/Source/WebKit/UIProcess/API/APINavigation.cpp</a></li>
<li><a href="#branchessafari609branchSourceWebKitUIProcessAPIAPINavigationh">branches/safari-609-branch/Source/WebKit/UIProcess/API/APINavigation.h</a></li>
<li><a href="#branchessafari609branchSourceWebKitUIProcessProvisionalPageProxycpp">branches/safari-609-branch/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp</a></li>
<li><a href="#branchessafari609branchSourceWebKitUIProcessProvisionalPageProxyh">branches/safari-609-branch/Source/WebKit/UIProcess/ProvisionalPageProxy.h</a></li>
<li><a href="#branchessafari609branchSourceWebKitUIProcessWebNavigationStatecpp">branches/safari-609-branch/Source/WebKit/UIProcess/WebNavigationState.cpp</a></li>
<li><a href="#branchessafari609branchSourceWebKitUIProcessWebNavigationStateh">branches/safari-609-branch/Source/WebKit/UIProcess/WebNavigationState.h</a></li>
<li><a href="#branchessafari609branchSourceWebKitUIProcessWebPageProxycpp">branches/safari-609-branch/Source/WebKit/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#branchessafari609branchSourceWebKitUIProcessWebPageProxyh">branches/safari-609-branch/Source/WebKit/UIProcess/WebPageProxy.h</a></li>
<li><a href="#branchessafari609branchSourceWebKitUIProcessWebPageProxymessagesin">branches/safari-609-branch/Source/WebKit/UIProcess/WebPageProxy.messages.in</a></li>
<li><a href="#branchessafari609branchSourceWebKitWebProcessWebCoreSupportWebFrameLoaderClientcpp">branches/safari-609-branch/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp</a></li>
<li><a href="#branchessafari609branchSourceWebKitWebProcessWebPageWebBackForwardListProxycpp">branches/safari-609-branch/Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.cpp</a></li>
<li><a href="#branchessafari609branchSourceWebKitWebProcessWebPageWebFramecpp">branches/safari-609-branch/Source/WebKit/WebProcess/WebPage/WebFrame.cpp</a></li>
<li><a href="#branchessafari609branchSourceWebKitWebProcessWebPageWebFrameh">branches/safari-609-branch/Source/WebKit/WebProcess/WebPage/WebFrame.h</a></li>
<li><a href="#branchessafari609branchSourceWebKitWebProcessWebPageWebPagecpp">branches/safari-609-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#branchessafari609branchSourceWebKitWebProcessWebPageWebPageh">branches/safari-609-branch/Source/WebKit/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#branchessafari609branchSourceWebKitWebProcessWebPageWebPagemessagesin">branches/safari-609-branch/Source/WebKit/WebProcess/WebPage/WebPage.messages.in</a></li>
<li><a href="#branchessafari609branchToolsChangeLog">branches/safari-609-branch/Tools/ChangeLog</a></li>
<li><a href="#branchessafari609branchToolsTestWebKitAPITestsWebKitCocoaProcessSwapOnNavigationmm">branches/safari-609-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari609branchSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-609-branch/Source/WebKit/ChangeLog (260368 => 260369)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-609-branch/Source/WebKit/ChangeLog       2020-04-20 16:16:19 UTC (rev 260368)
+++ branches/safari-609-branch/Source/WebKit/ChangeLog  2020-04-20 16:23:25 UTC (rev 260369)
</span><span class="lines">@@ -1,3 +1,58 @@
</span><ins>+2020-04-20  Alan Coon  <alancoon@apple.com>
+
+        Apply patch. rdar://problem/61950472
+
+    2020-04-20  Brady Eidson  <beidson@apple.com>
+
+            Pass sandbox extensions for back/forward list navigations after the policy is decided at process-swap time.
+            <rdar://problem/59535167> and https://bugs.webkit.org/show_bug.cgi?id=210623
+
+            Reviewed by Geoff Garen.
+
+            Covered by almost all existing tests, and a new API test.
+
+            Instead of granting a sandbox extension when updating the back/forward cursor for a pending
+            back/forward list traversal, do so after the client decides the policy.
+            (Which is also along with a process swap in interesting cases)
+
+            * Shared/PolicyDecision.h:
+            (WebKit::PolicyDecision::encode const):
+            (WebKit::PolicyDecision::decode):
+
+            * Shared/WebPageCreationParameters.h:
+
+            * UIProcess/API/APINavigation.cpp:
+            (API::Navigation::Navigation):
+            * UIProcess/API/APINavigation.h:
+            (API::Navigation::create):
+            (API::Navigation::reloadItem const):
+
+            * UIProcess/ProvisionalPageProxy.cpp:
+            (WebKit::ProvisionalPageProxy::backForwardGoToItem):
+            * UIProcess/ProvisionalPageProxy.h:
+
+            * UIProcess/WebNavigationState.cpp:
+            (WebKit::WebNavigationState::createReloadNavigation):
+            * UIProcess/WebNavigationState.h:
+
+            * UIProcess/WebPageProxy.cpp:
+            (WebKit::WebPageProxy::launchProcessForReload):
+            (WebKit::WebPageProxy::reload):
+            (WebKit::WebPageProxy::receivedNavigationPolicyDecision):
+            (WebKit::WebPageProxy::receivedPolicyDecision):
+            * UIProcess/WebPageProxy.h:
+            (WebKit::WebPageProxy::receivedPolicyDecision):
+            * UIProcess/WebPageProxy.messages.in:
+
+            * WebProcess/WebPage/WebBackForwardListProxy.cpp:
+            (WebKit::WebBackForwardListProxy::goToItem):
+
+            * WebProcess/WebPage/WebFrame.cpp:
+            (WebKit::WebFrame::didReceivePolicyDecision):
+
+            * WebProcess/WebPage/WebPage.cpp:
+            (WebKit::WebPage::SandboxExtensionTracker::didStartProvisionalLoad):
+
</ins><span class="cx"> 2020-04-17  Alan Coon  <alancoon@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Cherry-pick r260278. rdar://problem/61950220
</span></span></pre></div>
<a id="branchessafari609branchSourceWebKitSharedWebPageCreationParametersh"></a>
<div class="modfile"><h4>Modified: branches/safari-609-branch/Source/WebKit/Shared/WebPageCreationParameters.h (260368 => 260369)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-609-branch/Source/WebKit/Shared/WebPageCreationParameters.h      2020-04-20 16:16:19 UTC (rev 260368)
+++ branches/safari-609-branch/Source/WebKit/Shared/WebPageCreationParameters.h 2020-04-20 16:23:25 UTC (rev 260369)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include "DrawingAreaInfo.h"
</span><span class="cx"> #include "LayerTreeContext.h"
</span><ins>+#include "SandboxExtension.h"
</ins><span class="cx"> #include "SessionState.h"
</span><span class="cx"> #include "WebCompiledContentRuleListData.h"
</span><span class="cx"> #include "WebCoreArgumentCoders.h"
</span></span></pre></div>
<a id="branchessafari609branchSourceWebKitUIProcessAPIAPINavigationcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-609-branch/Source/WebKit/UIProcess/API/APINavigation.cpp (260368 => 260369)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-609-branch/Source/WebKit/UIProcess/API/APINavigation.cpp 2020-04-20 16:16:19 UTC (rev 260368)
+++ branches/safari-609-branch/Source/WebKit/UIProcess/API/APINavigation.cpp    2020-04-20 16:23:25 UTC (rev 260369)
</span><span class="lines">@@ -40,6 +40,12 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Navigation::Navigation(WebNavigationState& state, WebBackForwardListItem* currentAndTargetItem)
+    : m_navigationID(state.generateNavigationID())
+    , m_reloadItem(currentAndTargetItem)
+{
+}
+
</ins><span class="cx"> Navigation::Navigation(WebNavigationState& state, WebCore::ResourceRequest&& request, WebBackForwardListItem* fromItem)
</span><span class="cx">     : m_navigationID(state.generateNavigationID())
</span><span class="cx">     , m_originalRequest(WTFMove(request))
</span></span></pre></div>
<a id="branchessafari609branchSourceWebKitUIProcessAPIAPINavigationh"></a>
<div class="modfile"><h4>Modified: branches/safari-609-branch/Source/WebKit/UIProcess/API/APINavigation.h (260368 => 260369)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-609-branch/Source/WebKit/UIProcess/API/APINavigation.h   2020-04-20 16:16:19 UTC (rev 260368)
+++ branches/safari-609-branch/Source/WebKit/UIProcess/API/APINavigation.h      2020-04-20 16:23:25 UTC (rev 260369)
</span><span class="lines">@@ -70,9 +70,9 @@
</span><span class="cx"> class Navigation : public ObjectImpl<Object::Type::Navigation> {
</span><span class="cx">     WTF_MAKE_NONCOPYABLE(Navigation);
</span><span class="cx"> public:
</span><del>-    static Ref<Navigation> create(WebKit::WebNavigationState& state)
</del><ins>+    static Ref<Navigation> create(WebKit::WebNavigationState& state, WebKit::WebBackForwardListItem* currentAndTargetItem)
</ins><span class="cx">     {
</span><del>-        return adoptRef(*new Navigation(state));
</del><ins>+        return adoptRef(*new Navigation(state, currentAndTargetItem));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     static Ref<Navigation> create(WebKit::WebNavigationState& state, WebKit::WebBackForwardListItem& targetItem, WebKit::WebBackForwardListItem* fromItem, WebCore::FrameLoadType backForwardFrameLoadType)
</span><span class="lines">@@ -104,6 +104,7 @@
</span><span class="cx">     WebKit::WebBackForwardListItem* targetItem() const { return m_targetItem.get(); }
</span><span class="cx">     WebKit::WebBackForwardListItem* fromItem() const { return m_fromItem.get(); }
</span><span class="cx">     Optional<WebCore::FrameLoadType> backForwardFrameLoadType() const { return m_backForwardFrameLoadType; }
</span><ins>+    WebKit::WebBackForwardListItem* reloadItem() const { return m_reloadItem.get(); }
</ins><span class="cx"> 
</span><span class="cx">     void appendRedirectionURL(const WTF::URL&);
</span><span class="cx">     Vector<WTF::URL> takeRedirectChain() { return WTFMove(m_redirectChain); }
</span><span class="lines">@@ -158,6 +159,7 @@
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     explicit Navigation(WebKit::WebNavigationState&);
</span><ins>+    Navigation(WebKit::WebNavigationState&, WebKit::WebBackForwardListItem*);
</ins><span class="cx">     Navigation(WebKit::WebNavigationState&, WebCore::ResourceRequest&&, WebKit::WebBackForwardListItem* fromItem);
</span><span class="cx">     Navigation(WebKit::WebNavigationState&, WebKit::WebBackForwardListItem& targetItem, WebKit::WebBackForwardListItem* fromItem, WebCore::FrameLoadType);
</span><span class="cx">     Navigation(WebKit::WebNavigationState&, std::unique_ptr<SubstituteData>&&);
</span><span class="lines">@@ -170,6 +172,7 @@
</span><span class="cx"> 
</span><span class="cx">     RefPtr<WebKit::WebBackForwardListItem> m_targetItem;
</span><span class="cx">     RefPtr<WebKit::WebBackForwardListItem> m_fromItem;
</span><ins>+    RefPtr<WebKit::WebBackForwardListItem> m_reloadItem;
</ins><span class="cx">     Optional<WebCore::FrameLoadType> m_backForwardFrameLoadType;
</span><span class="cx">     std::unique_ptr<SubstituteData> m_substituteData;
</span><span class="cx">     WebKit::NavigationActionData m_lastNavigationAction;
</span></span></pre></div>
<a id="branchessafari609branchSourceWebKitUIProcessProvisionalPageProxycpp"></a>
<div class="modfile"><h4>Modified: branches/safari-609-branch/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp (260368 => 260369)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-609-branch/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp      2020-04-20 16:16:19 UTC (rev 260368)
+++ branches/safari-609-branch/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp 2020-04-20 16:23:25 UTC (rev 260369)
</span><span class="lines">@@ -334,7 +334,7 @@
</span><span class="cx">     m_page.startURLSchemeTaskShared(m_process.copyRef(), m_webPageID, WTFMove(parameters));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ProvisionalPageProxy::backForwardGoToItem(const WebCore::BackForwardItemIdentifier& identifier, CompletionHandler<void(SandboxExtension::Handle&&)>&& completionHandler)
</del><ins>+void ProvisionalPageProxy::backForwardGoToItem(const WebCore::BackForwardItemIdentifier& identifier, CompletionHandler<void()>&& completionHandler)
</ins><span class="cx"> {
</span><span class="cx">     m_page.backForwardGoToItemShared(m_process.copyRef(), identifier, WTFMove(completionHandler));
</span><span class="cx"> }
</span><span class="lines">@@ -345,7 +345,7 @@
</span><span class="cx">     const UserData& userData, Messages::WebPageProxy::DecidePolicyForNavigationActionSync::DelayedReply&& reply)
</span><span class="cx"> {
</span><span class="cx">     if (!isMainFrame || (m_mainFrame && m_mainFrame->frameID() != frameID) || navigationID != m_navigationID) {
</span><del>-        reply(identifier, WebCore::PolicyAction::Ignore, navigationID, DownloadID(), WTF::nullopt);
</del><ins>+        reply(identifier, WebCore::PolicyAction::Ignore, navigationID, DownloadID(), WTF::nullopt, WTF::nullopt);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari609branchSourceWebKitUIProcessProvisionalPageProxyh"></a>
<div class="modfile"><h4>Modified: branches/safari-609-branch/Source/WebKit/UIProcess/ProvisionalPageProxy.h (260368 => 260369)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-609-branch/Source/WebKit/UIProcess/ProvisionalPageProxy.h        2020-04-20 16:16:19 UTC (rev 260368)
+++ branches/safari-609-branch/Source/WebKit/UIProcess/ProvisionalPageProxy.h   2020-04-20 16:23:25 UTC (rev 260369)
</span><span class="lines">@@ -125,7 +125,7 @@
</span><span class="cx">     void didCommitLoadForFrame(WebCore::FrameIdentifier, uint64_t navigationID, const String& mimeType, bool frameHasCustomContentProvider, uint32_t frameLoadType, const WebCore::CertificateInfo&, bool usedLegacyTLS, bool containsPluginDocument, Optional<WebCore::HasInsecureContent> forcedHasInsecureContent, const UserData&);
</span><span class="cx">     void didFailProvisionalLoadForFrame(WebCore::FrameIdentifier, WebCore::SecurityOriginData&& frameSecurityOrigin, uint64_t navigationID, const String& provisionalURL, const WebCore::ResourceError&, WebCore::WillContinueLoading, const UserData&);
</span><span class="cx">     void startURLSchemeTask(URLSchemeTaskParameters&&);
</span><del>-    void backForwardGoToItem(const WebCore::BackForwardItemIdentifier&, CompletionHandler<void(SandboxExtension::Handle&&)>&&);
</del><ins>+    void backForwardGoToItem(const WebCore::BackForwardItemIdentifier&, CompletionHandler<void()>&&);
</ins><span class="cx">     void decidePolicyForNavigationActionSync(WebCore::FrameIdentifier, bool isMainFrame, WebCore::SecurityOriginData&&, WebCore::PolicyCheckIdentifier, uint64_t navigationID, NavigationActionData&&,
</span><span class="cx">         FrameInfoData&&, Optional<WebPageProxyIdentifier> originatingPageID, const WebCore::ResourceRequest& originalRequest, WebCore::ResourceRequest&&, IPC::FormDataReference&& requestBody,
</span><span class="cx">         WebCore::ResourceResponse&& redirectResponse, const UserData&, Messages::WebPageProxy::DecidePolicyForNavigationActionSyncDelayedReply&&);
</span></span></pre></div>
<a id="branchessafari609branchSourceWebKitUIProcessWebNavigationStatecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-609-branch/Source/WebKit/UIProcess/WebNavigationState.cpp (260368 => 260369)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-609-branch/Source/WebKit/UIProcess/WebNavigationState.cpp        2020-04-20 16:16:19 UTC (rev 260368)
+++ branches/safari-609-branch/Source/WebKit/UIProcess/WebNavigationState.cpp   2020-04-20 16:23:25 UTC (rev 260369)
</span><span class="lines">@@ -59,9 +59,9 @@
</span><span class="cx">     return navigation;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Ref<API::Navigation> WebNavigationState::createReloadNavigation()
</del><ins>+Ref<API::Navigation> WebNavigationState::createReloadNavigation(WebBackForwardListItem* currentAndTargetItem)
</ins><span class="cx"> {
</span><del>-    auto navigation = API::Navigation::create(*this);
</del><ins>+    auto navigation = API::Navigation::create(*this, currentAndTargetItem);
</ins><span class="cx"> 
</span><span class="cx">     m_navigations.set(navigation->navigationID(), navigation.ptr());
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari609branchSourceWebKitUIProcessWebNavigationStateh"></a>
<div class="modfile"><h4>Modified: branches/safari-609-branch/Source/WebKit/UIProcess/WebNavigationState.h (260368 => 260369)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-609-branch/Source/WebKit/UIProcess/WebNavigationState.h  2020-04-20 16:16:19 UTC (rev 260368)
+++ branches/safari-609-branch/Source/WebKit/UIProcess/WebNavigationState.h     2020-04-20 16:23:25 UTC (rev 260369)
</span><span class="lines">@@ -52,7 +52,7 @@
</span><span class="cx"> 
</span><span class="cx">     Ref<API::Navigation> createBackForwardNavigation(WebBackForwardListItem& targetItem, WebBackForwardListItem* currentItem, WebCore::FrameLoadType);
</span><span class="cx">     Ref<API::Navigation> createLoadRequestNavigation(WebCore::ResourceRequest&&, WebBackForwardListItem* currentItem);
</span><del>-    Ref<API::Navigation> createReloadNavigation();
</del><ins>+    Ref<API::Navigation> createReloadNavigation(WebBackForwardListItem* currentAndTargetItem);
</ins><span class="cx">     Ref<API::Navigation> createLoadDataNavigation(std::unique_ptr<API::SubstituteData>&&);
</span><span class="cx"> 
</span><span class="cx">     bool hasNavigation(uint64_t navigationID) const { return m_navigations.contains(navigationID); }
</span></span></pre></div>
<a id="branchessafari609branchSourceWebKitUIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: branches/safari-609-branch/Source/WebKit/UIProcess/WebPageProxy.cpp (260368 => 260369)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-609-branch/Source/WebKit/UIProcess/WebPageProxy.cpp      2020-04-20 16:16:19 UTC (rev 260368)
+++ branches/safari-609-branch/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-04-20 16:23:25 UTC (rev 260369)
</span><span class="lines">@@ -953,7 +953,7 @@
</span><span class="cx">         return nullptr;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    auto navigation = m_navigationState->createReloadNavigation();
</del><ins>+    auto navigation = m_navigationState->createReloadNavigation(m_backForwardList->currentItem());
</ins><span class="cx"> 
</span><span class="cx">     String url = currentURL();
</span><span class="cx">     if (!url.isEmpty()) {
</span><span class="lines">@@ -1516,7 +1516,7 @@
</span><span class="cx">     if (!hasRunningProcess())
</span><span class="cx">         return launchProcessForReload();
</span><span class="cx">     
</span><del>-    auto navigation = m_navigationState->createReloadNavigation();
</del><ins>+    auto navigation = m_navigationState->createReloadNavigation(m_backForwardList->currentItem());
</ins><span class="cx"> 
</span><span class="cx">     if (!url.isEmpty()) {
</span><span class="cx">         auto transaction = m_pageLoadState.transaction();
</span><span class="lines">@@ -3013,7 +3013,7 @@
</span><span class="cx"> 
</span><span class="cx"> class WebPageProxy::PolicyDecisionSender : public RefCounted<PolicyDecisionSender> {
</span><span class="cx"> public:
</span><del>-    using SendFunction = CompletionHandler<void(PolicyCheckIdentifier, PolicyAction, uint64_t newNavigationID, DownloadID, Optional<WebsitePoliciesData>)>;
</del><ins>+    using SendFunction = CompletionHandler<void(PolicyCheckIdentifier, PolicyAction, uint64_t newNavigationID, DownloadID, Optional<WebsitePoliciesData>, Optional<SandboxExtension::Handle>)>;
</ins><span class="cx"> 
</span><span class="cx">     static Ref<PolicyDecisionSender> create(PolicyCheckIdentifier identifier, SendFunction&& sendFunction)
</span><span class="cx">     {
</span><span class="lines">@@ -3102,6 +3102,7 @@
</span><span class="cx">         } else
</span><span class="cx">             RELEASE_LOG_IF_ALLOWED(ProcessSwapping, "decidePolicyForNavigationAction: keep using process %i for navigation, reason: %{public}s", processIdentifier(), reason.utf8().data());
</span><span class="cx"> 
</span><ins>+        Optional<SandboxExtension::Handle> optionalHandle;
</ins><span class="cx">         if (shouldProcessSwap) {
</span><span class="cx">             // Make sure the process to be used for the navigation does not get shutDown now due to destroying SuspendedPageProxy or ProvisionalPageProxy objects.
</span><span class="cx">             auto preventNavigationProcessShutdown = processForNavigation->makeScopePreventingShutdown();
</span><span class="lines">@@ -3113,16 +3114,26 @@
</span><span class="cx">                 suspendedPage = nullptr;
</span><span class="cx"> 
</span><span class="cx">             continueNavigationInNewProcess(navigation, WTFMove(suspendedPage), WTFMove(processForNavigation), processSwapRequestedByClient, WTFMove(data));
</span><ins>+        } else {
+            auto item = navigation->reloadItem() ? navigation->reloadItem() : navigation->targetItem();
+            if (policyAction == PolicyAction::Use && item) {
+                auto fullURL = URL { URL(), item->url() };
+                if (fullURL.protocolIs("file"_s)) {
+                    SandboxExtension::Handle sandboxExtensionHandle;
+                    maybeInitializeSandboxExtensionHandle(processForNavigation.get(), fullURL, item->resourceDirectoryURL(), sandboxExtensionHandle);
+                    optionalHandle = WTFMove(sandboxExtensionHandle);
+                }
+            }
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        receivedPolicyDecision(policyAction, navigation.ptr(), shouldProcessSwap ? WTF::nullopt : WTFMove(data), WTFMove(sender), shouldProcessSwap ? WillContinueLoadInNewProcess::Yes : WillContinueLoadInNewProcess::No);
</del><ins>+        receivedPolicyDecision(policyAction, navigation.ptr(), shouldProcessSwap ? WTF::nullopt : WTFMove(data), WTFMove(sender), WTFMove(optionalHandle), shouldProcessSwap ? WillContinueLoadInNewProcess::Yes : WillContinueLoadInNewProcess::No);
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPageProxy::receivedPolicyDecision(PolicyAction action, API::Navigation* navigation, Optional<WebsitePoliciesData>&& websitePolicies, Ref<PolicyDecisionSender>&& sender, WillContinueLoadInNewProcess willContinueLoadInNewProcess)
</del><ins>+void WebPageProxy::receivedPolicyDecision(PolicyAction action, API::Navigation* navigation, Optional<WebsitePoliciesData>&& websitePolicies, Ref<PolicyDecisionSender>&& sender, Optional<SandboxExtension::Handle> sandboxExtensionHandle, WillContinueLoadInNewProcess willContinueLoadInNewProcess)
</ins><span class="cx"> {
</span><span class="cx">     if (!hasRunningProcess()) {
</span><del>-        sender->send(PolicyAction::Ignore, 0, DownloadID(), WTF::nullopt);
</del><ins>+        sender->send(PolicyAction::Ignore, 0, DownloadID(), WTF::nullopt, WTF::nullopt);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -3145,7 +3156,7 @@
</span><span class="cx">         m_decidePolicyForResponseRequest = { };
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    sender->send(action, navigation ? navigation->navigationID() : 0, downloadID, WTFMove(websitePolicies));
</del><ins>+    sender->send(action, navigation ? navigation->navigationID() : 0, downloadID, WTFMove(websitePolicies), WTFMove(sandboxExtensionHandle));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPageProxy::commitProvisionalPage(FrameIdentifier frameID, uint64_t navigationID, const String& mimeType, bool frameHasCustomContentProvider, uint32_t frameLoadType, const WebCore::CertificateInfo& certificateInfo, bool usedLegacyTLS, bool containsPluginDocument, Optional<WebCore::HasInsecureContent> forcedHasInsecureContent, const UserData& userData)
</span><span class="lines">@@ -4921,7 +4932,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (!checkURLReceivedFromCurrentOrPreviousWebProcess(process, request.url())) {
</span><span class="cx">         RELEASE_LOG_ERROR_IF_ALLOWED(Process, "Ignoring request to load this main resource because it is outside the sandbox");
</span><del>-        sender->send(PolicyAction::Ignore, 0, DownloadID(), WTF::nullopt);
</del><ins>+        sender->send(PolicyAction::Ignore, 0, DownloadID(), WTF::nullopt, WTF::nullopt);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -5148,7 +5159,7 @@
</span><span class="cx">         originatingPageID, originalRequest, WTFMove(request), WTFMove(requestBody), WTFMove(redirectResponse), userData, sender.copyRef());
</span><span class="cx"> 
</span><span class="cx">     // If the client did not respond synchronously, proceed with the load.
</span><del>-    sender->send(PolicyAction::Use, navigationID, DownloadID(), WTF::nullopt);
</del><ins>+    sender->send(PolicyAction::Use, navigationID, DownloadID(), WTF::nullopt, WTF::nullopt);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPageProxy::decidePolicyForNewWindowAction(FrameIdentifier frameID, SecurityOriginData&& frameSecurityOrigin, PolicyCheckIdentifier identifier,
</span><span class="lines">@@ -6033,30 +6044,28 @@
</span><span class="cx">     m_backForwardList->addItem(WTFMove(item));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPageProxy::backForwardGoToItem(const BackForwardItemIdentifier& itemID, CompletionHandler<void(SandboxExtension::Handle&&)>&& completionHandler)
</del><ins>+void WebPageProxy::backForwardGoToItem(const BackForwardItemIdentifier& itemID, CompletionHandler<void()>&& completionHandler)
</ins><span class="cx"> {
</span><span class="cx">     // On process swap, we tell the previous process to ignore the load, which causes it so restore its current back forward item to its previous
</span><span class="cx">     // value. Since the load is really going on in a new provisional process, we want to ignore such requests from the committed process.
</span><span class="cx">     // Any real new load in the committed process would have cleared m_provisionalPage.
</span><span class="cx">     if (m_provisionalPage)
</span><del>-        return completionHandler({ });
</del><ins>+        return completionHandler();
</ins><span class="cx"> 
</span><span class="cx">     SandboxExtension::Handle sandboxExtensionHandle;
</span><span class="cx">     backForwardGoToItemShared(m_process.copyRef(), itemID, WTFMove(completionHandler));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPageProxy::backForwardGoToItemShared(Ref<WebProcessProxy>&& process, const BackForwardItemIdentifier& itemID, CompletionHandler<void(SandboxExtension::Handle&&)>&& completionHandler)
</del><ins>+void WebPageProxy::backForwardGoToItemShared(Ref<WebProcessProxy>&& process, const BackForwardItemIdentifier& itemID, CompletionHandler<void()>&& completionHandler)
</ins><span class="cx"> {
</span><del>-    MESSAGE_CHECK_COMPLETION(m_process, !WebKit::isInspectorPage(*this), completionHandler({ }));
</del><ins>+    MESSAGE_CHECK_COMPLETION(m_process, !WebKit::isInspectorPage(*this), completionHandler());
</ins><span class="cx"> 
</span><span class="cx">     auto* item = m_backForwardList->itemForID(itemID);
</span><span class="cx">     if (!item)
</span><del>-        return completionHandler({ });
</del><ins>+        return completionHandler();
</ins><span class="cx"> 
</span><del>-    SandboxExtension::Handle sandboxExtensionHandle;
-    maybeInitializeSandboxExtensionHandle(process, URL(URL(), item->url()), item->resourceDirectoryURL(),  sandboxExtensionHandle);
</del><span class="cx">     m_backForwardList->goToItem(*item);
</span><del>-    completionHandler(WTFMove(sandboxExtensionHandle));
</del><ins>+    completionHandler();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPageProxy::backForwardItemAtIndex(int32_t index, CompletionHandler<void(Optional<BackForwardItemIdentifier>&&)>&& completionHandler)
</span></span></pre></div>
<a id="branchessafari609branchSourceWebKitUIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: branches/safari-609-branch/Source/WebKit/UIProcess/WebPageProxy.h (260368 => 260369)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-609-branch/Source/WebKit/UIProcess/WebPageProxy.h        2020-04-20 16:16:19 UTC (rev 260368)
+++ branches/safari-609-branch/Source/WebKit/UIProcess/WebPageProxy.h   2020-04-20 16:23:25 UTC (rev 260369)
</span><span class="lines">@@ -1092,7 +1092,7 @@
</span><span class="cx"> 
</span><span class="cx">     class PolicyDecisionSender;
</span><span class="cx">     enum class WillContinueLoadInNewProcess : bool { No, Yes };
</span><del>-    void receivedPolicyDecision(WebCore::PolicyAction, API::Navigation*, Optional<WebsitePoliciesData>&&, Ref<PolicyDecisionSender>&&, WillContinueLoadInNewProcess = WillContinueLoadInNewProcess::No);
</del><ins>+    void receivedPolicyDecision(WebCore::PolicyAction, API::Navigation*, Optional<WebsitePoliciesData>&&, Ref<PolicyDecisionSender>&&, Optional<SandboxExtension::Handle> = { }, WillContinueLoadInNewProcess = WillContinueLoadInNewProcess::No);
</ins><span class="cx">     void receivedNavigationPolicyDecision(WebCore::PolicyAction, API::Navigation*, ProcessSwapRequestedByClient, WebFrameProxy&, API::WebsitePolicies*, Ref<PolicyDecisionSender>&&);
</span><span class="cx"> 
</span><span class="cx">     void backForwardRemovedItem(const WebCore::BackForwardItemIdentifier&);
</span><span class="lines">@@ -1579,10 +1579,11 @@
</span><span class="cx">     void startURLSchemeTaskShared(Ref<WebProcessProxy>&&, WebCore::PageIdentifier, URLSchemeTaskParameters&&);
</span><span class="cx">     void loadDataWithNavigationShared(Ref<WebProcessProxy>&&, WebCore::PageIdentifier, API::Navigation&, const IPC::DataReference&, const String& MIMEType, const String& encoding, const String& baseURL, API::Object* userData, WebCore::ShouldTreatAsContinuingLoad, Optional<WebsitePoliciesData>&& = WTF::nullopt, WebCore::ShouldOpenExternalURLsPolicy = WebCore::ShouldOpenExternalURLsPolicy::ShouldNotAllow);
</span><span class="cx">     void loadRequestWithNavigationShared(Ref<WebProcessProxy>&&, WebCore::PageIdentifier, API::Navigation&, WebCore::ResourceRequest&&, WebCore::ShouldOpenExternalURLsPolicy, API::Object* userData, WebCore::ShouldTreatAsContinuingLoad, Optional<WebsitePoliciesData>&& = WTF::nullopt);
</span><del>-    void backForwardGoToItemShared(Ref<WebProcessProxy>&&, const WebCore::BackForwardItemIdentifier&, CompletionHandler<void(SandboxExtension::Handle&&)>&&);
</del><ins>+    void backForwardGoToItemShared(Ref<WebProcessProxy>&&, const WebCore::BackForwardItemIdentifier&, CompletionHandler<void()>&&);
</ins><span class="cx">     void decidePolicyForNavigationActionSyncShared(Ref<WebProcessProxy>&&, WebCore::FrameIdentifier, bool isMainFrame, WebCore::SecurityOriginData&&, WebCore::PolicyCheckIdentifier, uint64_t navigationID, NavigationActionData&&,
</span><span class="cx">         FrameInfoData&&, Optional<WebPageProxyIdentifier> originatingPageID, const WebCore::ResourceRequest& originalRequest, WebCore::ResourceRequest&&, IPC::FormDataReference&& requestBody,
</span><span class="cx">         WebCore::ResourceResponse&& redirectResponse, const UserData&, Messages::WebPageProxy::DecidePolicyForNavigationActionSyncDelayedReply&&);
</span><ins>+
</ins><span class="cx"> #if USE(QUICK_LOOK)
</span><span class="cx">     void requestPasswordForQuickLookDocumentInMainFrameShared(const String& fileName, CompletionHandler<void(const String&)>&&);
</span><span class="cx"> #endif
</span><span class="lines">@@ -1870,7 +1871,7 @@
</span><span class="cx"> 
</span><span class="cx">     // Back/Forward list management
</span><span class="cx">     void backForwardAddItem(BackForwardListItemState&&);
</span><del>-    void backForwardGoToItem(const WebCore::BackForwardItemIdentifier&, CompletionHandler<void(SandboxExtension::Handle&&)>&&);
</del><ins>+    void backForwardGoToItem(const WebCore::BackForwardItemIdentifier&, CompletionHandler<void()>&&);
</ins><span class="cx">     void backForwardItemAtIndex(int32_t index, CompletionHandler<void(Optional<WebCore::BackForwardItemIdentifier>&&)>&&);
</span><span class="cx">     void backForwardBackListCount(CompletionHandler<void(uint32_t)>&&);
</span><span class="cx">     void backForwardForwardListCount(CompletionHandler<void(uint32_t)>&&);
</span></span></pre></div>
<a id="branchessafari609branchSourceWebKitUIProcessWebPageProxymessagesin"></a>
<div class="modfile"><h4>Modified: branches/safari-609-branch/Source/WebKit/UIProcess/WebPageProxy.messages.in (260368 => 260369)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-609-branch/Source/WebKit/UIProcess/WebPageProxy.messages.in      2020-04-20 16:16:19 UTC (rev 260368)
+++ branches/safari-609-branch/Source/WebKit/UIProcess/WebPageProxy.messages.in 2020-04-20 16:23:25 UTC (rev 260369)
</span><span class="lines">@@ -102,7 +102,7 @@
</span><span class="cx">     # Policy messages
</span><span class="cx">     DecidePolicyForResponse(WebCore::FrameIdentifier frameID, struct WebCore::SecurityOriginData frameSecurityOrigin, WebCore::PolicyCheckIdentifier policyCheckIdentifier, uint64_t navigationID, WebCore::ResourceResponse response, WebCore::ResourceRequest request, bool canShowMIMEType, String downloadAttribute, uint64_t listenerID, WebKit::UserData userData)
</span><span class="cx">     DecidePolicyForNavigationActionAsync(WebCore::FrameIdentifier frameID, struct WebCore::SecurityOriginData frameSecurityOrigin, WebCore::PolicyCheckIdentifier policyCheckIdentifier, uint64_t navigationID, struct WebKit::NavigationActionData navigationActionData, struct WebKit::FrameInfoData originatingFrameInfoData, Optional<WebKit::WebPageProxyIdentifier> originatingPageID, WebCore::ResourceRequest originalRequest, WebCore::ResourceRequest request, IPC::FormDataReference requestBody, WebCore::ResourceResponse redirectResponse, WebKit::UserData userData, uint64_t listenerID)
</span><del>-    DecidePolicyForNavigationActionSync(WebCore::FrameIdentifier frameID, bool isMainFrame, struct WebCore::SecurityOriginData frameSecurityOrigin, WebCore::PolicyCheckIdentifier policyCheckIdentifier, uint64_t navigationID, struct WebKit::NavigationActionData navigationActionData, struct WebKit::FrameInfoData originatingFrameInfoData, Optional<WebKit::WebPageProxyIdentifier> originatingPageID, WebCore::ResourceRequest originalRequest, WebCore::ResourceRequest request, IPC::FormDataReference requestBody, WebCore::ResourceResponse redirectResponse, WebKit::UserData userData) -> (WebCore::PolicyCheckIdentifier policyCheckIdentifier, enum:uint8_t WebCore::PolicyAction policyAction, uint64_t newNavigationID, WebKit::DownloadID downloadID, Optional<WebKit::WebsitePoliciesData> websitePolicies) Synchronous
</del><ins>+    DecidePolicyForNavigationActionSync(WebCore::FrameIdentifier frameID, bool isMainFrame, struct WebCore::SecurityOriginData frameSecurityOrigin, WebCore::PolicyCheckIdentifier policyCheckIdentifier, uint64_t navigationID, struct WebKit::NavigationActionData navigationActionData, struct WebKit::FrameInfoData originatingFrameInfoData, Optional<WebKit::WebPageProxyIdentifier> originatingPageID, WebCore::ResourceRequest originalRequest, WebCore::ResourceRequest request, IPC::FormDataReference requestBody, WebCore::ResourceResponse redirectResponse, WebKit::UserData userData) -> (WebCore::PolicyCheckIdentifier policyCheckIdentifier, enum:uint8_t WebCore::PolicyAction policyAction, uint64_t newNavigationID, WebKit::DownloadID downloadID, Optional<WebKit::WebsitePoliciesData> websitePolicies, Optional<WebKit::SandboxExtension::Handle> sandboxExtensionHandle) Synchronous
</ins><span class="cx">     DecidePolicyForNewWindowAction(WebCore::FrameIdentifier frameID, struct WebCore::SecurityOriginData frameSecurityOrigin, WebCore::PolicyCheckIdentifier policyCheckIdentifier, struct WebKit::NavigationActionData navigationActionData, WebCore::ResourceRequest request, String frameName, uint64_t listenerID, WebKit::UserData userData)
</span><span class="cx">     UnableToImplementPolicy(WebCore::FrameIdentifier frameID, WebCore::ResourceError error, WebKit::UserData userData)
</span><span class="cx"> 
</span><span class="lines">@@ -224,7 +224,7 @@
</span><span class="cx"> 
</span><span class="cx">     # BackForward messages
</span><span class="cx">     BackForwardAddItem(struct WebKit::BackForwardListItemState itemState)
</span><del>-    BackForwardGoToItem(struct WebCore::BackForwardItemIdentifier itemID) -> (WebKit::SandboxExtension::Handle sandboxExtensionHandle) Synchronous
</del><ins>+    BackForwardGoToItem(struct WebCore::BackForwardItemIdentifier itemID) -> () Synchronous
</ins><span class="cx">     BackForwardItemAtIndex(int32_t itemIndex) -> (Optional<WebCore::BackForwardItemIdentifier> itemID) Synchronous
</span><span class="cx">     BackForwardBackListCount() -> (uint32_t count) Synchronous
</span><span class="cx">     BackForwardForwardListCount() -> (uint32_t count) Synchronous
</span></span></pre></div>
<a id="branchessafari609branchSourceWebKitWebProcessWebCoreSupportWebFrameLoaderClientcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-609-branch/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (260368 => 260369)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-609-branch/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp      2020-04-20 16:16:19 UTC (rev 260368)
+++ branches/safari-609-branch/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp 2020-04-20 16:23:25 UTC (rev 260369)
</span><span class="lines">@@ -835,7 +835,7 @@
</span><span class="cx">     uint64_t listenerID = m_frame->setUpPolicyListener(identifier, WTFMove(function), WebFrame::ForNavigationAction::No);
</span><span class="cx">     if (!webPage->send(Messages::WebPageProxy::DecidePolicyForResponse(m_frame->frameID(), SecurityOriginData::fromFrame(coreFrame), identifier, navigationID, response, request,
</span><span class="cx">         canShowResponse, downloadAttribute, listenerID, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))))
</span><del>-        m_frame->didReceivePolicyDecision(listenerID, identifier, PolicyAction::Ignore, 0, { }, { });
</del><ins>+        m_frame->didReceivePolicyDecision(listenerID, identifier, PolicyAction::Ignore, 0, { }, { }, { });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(const NavigationAction& navigationAction, const ResourceRequest& request,
</span><span class="lines">@@ -985,16 +985,17 @@
</span><span class="cx">         PolicyAction policyAction;
</span><span class="cx">         DownloadID downloadID;
</span><span class="cx">         Optional<WebsitePoliciesData> websitePolicies;
</span><ins>+        Optional<SandboxExtension::Handle> sandboxExtensionHandle;
</ins><span class="cx"> 
</span><span class="cx">         if (!webPage->sendSync(Messages::WebPageProxy::DecidePolicyForNavigationActionSync(m_frame->frameID(), m_frame->isMainFrame(), SecurityOriginData::fromFrame(coreFrame),
</span><span class="cx">             requestIdentifier, documentLoader->navigationID(), navigationActionData, originatingFrameInfoData, originatingPageID, navigationAction.resourceRequest(), request,
</span><span class="cx">             IPC::FormDataReference { request.httpBody() }, redirectResponse, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())),
</span><del>-            Messages::WebPageProxy::DecidePolicyForNavigationActionSync::Reply(responseIdentifier, policyAction, newNavigationID, downloadID, websitePolicies))) {
-            m_frame->didReceivePolicyDecision(listenerID, requestIdentifier, PolicyAction::Ignore, 0, { }, { });
</del><ins>+            Messages::WebPageProxy::DecidePolicyForNavigationActionSync::Reply(responseIdentifier, policyAction, newNavigationID, downloadID, websitePolicies, sandboxExtensionHandle))) {
+            m_frame->didReceivePolicyDecision(listenerID, requestIdentifier, PolicyAction::Ignore, 0, { }, { }, { });
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        m_frame->didReceivePolicyDecision(listenerID, responseIdentifier, policyAction, 0, downloadID, { });
</del><ins>+        m_frame->didReceivePolicyDecision(listenerID, responseIdentifier, policyAction, 0, downloadID, { }, { });
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -1002,7 +1003,7 @@
</span><span class="cx">     if (!webPage->send(Messages::WebPageProxy::DecidePolicyForNavigationActionAsync(m_frame->frameID(), SecurityOriginData::fromFrame(coreFrame),
</span><span class="cx">         requestIdentifier, documentLoader->navigationID(), navigationActionData, originatingFrameInfoData, originatingPageID, navigationAction.resourceRequest(), request,
</span><span class="cx">         IPC::FormDataReference { request.httpBody() }, redirectResponse, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()), listenerID)))
</span><del>-        m_frame->didReceivePolicyDecision(listenerID, requestIdentifier, PolicyAction::Ignore, 0, { }, { });
</del><ins>+        m_frame->didReceivePolicyDecision(listenerID, requestIdentifier, PolicyAction::Ignore, 0, { }, { }, { });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebFrameLoaderClient::cancelPolicyCheck()
</span></span></pre></div>
<a id="branchessafari609branchSourceWebKitWebProcessWebPageWebBackForwardListProxycpp"></a>
<div class="modfile"><h4>Modified: branches/safari-609-branch/Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.cpp (260368 => 260369)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-609-branch/Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.cpp  2020-04-20 16:16:19 UTC (rev 260368)
+++ branches/safari-609-branch/Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.cpp     2020-04-20 16:23:25 UTC (rev 260369)
</span><span class="lines">@@ -105,9 +105,7 @@
</span><span class="cx">     if (!m_page)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    SandboxExtension::Handle sandboxExtensionHandle;
-    m_page->sendSync(Messages::WebPageProxy::BackForwardGoToItem(item.identifier()), Messages::WebPageProxy::BackForwardGoToItem::Reply(sandboxExtensionHandle));
-    m_page->sandboxExtensionTracker().beginLoad(m_page->mainWebFrame(), WTFMove(sandboxExtensionHandle));
</del><ins>+    m_page->sendSync(Messages::WebPageProxy::BackForwardGoToItem(item.identifier()), Messages::WebPageProxy::BackForwardGoToItem::Reply());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> RefPtr<HistoryItem> WebBackForwardListProxy::itemAtIndex(int itemIndex)
</span></span></pre></div>
<a id="branchessafari609branchSourceWebKitWebProcessWebPageWebFramecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-609-branch/Source/WebKit/WebProcess/WebPage/WebFrame.cpp (260368 => 260369)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-609-branch/Source/WebKit/WebProcess/WebPage/WebFrame.cpp 2020-04-20 16:16:19 UTC (rev 260368)
+++ branches/safari-609-branch/Source/WebKit/WebProcess/WebPage/WebFrame.cpp    2020-04-20 16:23:25 UTC (rev 260369)
</span><span class="lines">@@ -252,7 +252,7 @@
</span><span class="cx">         completionHandler();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebFrame::didReceivePolicyDecision(uint64_t listenerID, WebCore::PolicyCheckIdentifier identifier, PolicyAction action, uint64_t navigationID, DownloadID downloadID, Optional<WebsitePoliciesData>&& websitePolicies)
</del><ins>+void WebFrame::didReceivePolicyDecision(uint64_t listenerID, WebCore::PolicyCheckIdentifier identifier, PolicyAction action, uint64_t navigationID, DownloadID downloadID, Optional<WebsitePoliciesData>&& websitePolicies, Optional<SandboxExtension::Handle>&& sandboxExtensionHandle)
</ins><span class="cx"> {
</span><span class="cx">     if (!m_coreFrame || !m_policyListenerID || listenerID != m_policyListenerID || !m_policyFunction)
</span><span class="cx">         return;
</span><span class="lines">@@ -274,6 +274,11 @@
</span><span class="cx">             documentLoader->setNavigationID(navigationID);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    if (action == PolicyAction::Use && sandboxExtensionHandle) {
+        if (auto* page = this->page())
+            page->sandboxExtensionTracker().beginLoad(page->mainWebFrame(), WTFMove(*sandboxExtensionHandle));
+    }
+
</ins><span class="cx">     function(action, identifier);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari609branchSourceWebKitWebProcessWebPageWebFrameh"></a>
<div class="modfile"><h4>Modified: branches/safari-609-branch/Source/WebKit/WebProcess/WebPage/WebFrame.h (260368 => 260369)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-609-branch/Source/WebKit/WebProcess/WebPage/WebFrame.h   2020-04-20 16:16:19 UTC (rev 260368)
+++ branches/safari-609-branch/Source/WebKit/WebProcess/WebPage/WebFrame.h      2020-04-20 16:23:25 UTC (rev 260369)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include "APIObject.h"
</span><span class="cx"> #include "DownloadID.h"
</span><ins>+#include "SandboxExtension.h"
</ins><span class="cx"> #include "ShareableBitmap.h"
</span><span class="cx"> #include "TransactionID.h"
</span><span class="cx"> #include "WKBase.h"
</span><span class="lines">@@ -82,7 +83,7 @@
</span><span class="cx">     enum class ForNavigationAction { No, Yes };
</span><span class="cx">     uint64_t setUpPolicyListener(WebCore::PolicyCheckIdentifier, WebCore::FramePolicyFunction&&, ForNavigationAction);
</span><span class="cx">     void invalidatePolicyListener();
</span><del>-    void didReceivePolicyDecision(uint64_t listenerID, WebCore::PolicyCheckIdentifier, WebCore::PolicyAction, uint64_t navigationID, DownloadID, Optional<WebsitePoliciesData>&&);
</del><ins>+    void didReceivePolicyDecision(uint64_t listenerID, WebCore::PolicyCheckIdentifier, WebCore::PolicyAction, uint64_t navigationID, DownloadID, Optional<WebsitePoliciesData>&&, Optional<SandboxExtension::Handle>&&);
</ins><span class="cx"> 
</span><span class="cx">     uint64_t setUpWillSubmitFormListener(CompletionHandler<void()>&&);
</span><span class="cx">     void continueWillSubmitForm(uint64_t);
</span></span></pre></div>
<a id="branchessafari609branchSourceWebKitWebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-609-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp (260368 => 260369)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-609-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp  2020-04-20 16:16:19 UTC (rev 260368)
+++ branches/safari-609-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp     2020-04-20 16:23:25 UTC (rev 260369)
</span><span class="lines">@@ -3238,12 +3238,12 @@
</span><span class="cx">         pluginView->setLayerHostingMode(m_layerHostingMode);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPage::didReceivePolicyDecision(FrameIdentifier frameID, uint64_t listenerID, PolicyCheckIdentifier identifier, PolicyAction policyAction, uint64_t navigationID, const DownloadID& downloadID, Optional<WebsitePoliciesData>&& websitePolicies)
</del><ins>+void WebPage::didReceivePolicyDecision(FrameIdentifier frameID, uint64_t listenerID, PolicyCheckIdentifier identifier, PolicyAction policyAction, uint64_t navigationID, const DownloadID& downloadID, Optional<WebsitePoliciesData>&& websitePolicies, Optional<SandboxExtension::Handle>&& sandboxExtensionHandle)
</ins><span class="cx"> {
</span><span class="cx">     WebFrame* frame = WebProcess::singleton().webFrame(frameID);
</span><span class="cx">     if (!frame)
</span><span class="cx">         return;
</span><del>-    frame->didReceivePolicyDecision(listenerID, identifier, policyAction, navigationID, downloadID, WTFMove(websitePolicies));
</del><ins>+    frame->didReceivePolicyDecision(listenerID, identifier, policyAction, navigationID, downloadID, WTFMove(websitePolicies), WTFMove(sandboxExtensionHandle));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPage::continueWillSubmitForm(FrameIdentifier frameID, uint64_t listenerID)
</span><span class="lines">@@ -4587,8 +4587,6 @@
</span><span class="cx">     if (!m_provisionalSandboxExtension)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    ASSERT(!m_provisionalSandboxExtension || frame->coreFrame()->loader().provisionalDocumentLoader()->url().isLocalFile());
-
</del><span class="cx">     m_provisionalSandboxExtension->consume();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari609branchSourceWebKitWebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: branches/safari-609-branch/Source/WebKit/WebProcess/WebPage/WebPage.h (260368 => 260369)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-609-branch/Source/WebKit/WebProcess/WebPage/WebPage.h    2020-04-20 16:16:19 UTC (rev 260368)
+++ branches/safari-609-branch/Source/WebKit/WebProcess/WebPage/WebPage.h       2020-04-20 16:23:25 UTC (rev 260369)
</span><span class="lines">@@ -1453,7 +1453,7 @@
</span><span class="cx">     bool parentProcessHasServiceWorkerEntitlement() const { return true; }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    void didReceivePolicyDecision(WebCore::FrameIdentifier, uint64_t listenerID, WebCore::PolicyCheckIdentifier, WebCore::PolicyAction, uint64_t navigationID, const DownloadID&, Optional<WebsitePoliciesData>&&);
</del><ins>+    void didReceivePolicyDecision(WebCore::FrameIdentifier, uint64_t listenerID, WebCore::PolicyCheckIdentifier, WebCore::PolicyAction, uint64_t navigationID, const DownloadID&, Optional<WebsitePoliciesData>&&, Optional<SandboxExtension::Handle>&&);
</ins><span class="cx">     void continueWillSubmitForm(WebCore::FrameIdentifier, uint64_t listenerID);
</span><span class="cx">     void setUserAgent(const String&);
</span><span class="cx">     void setCustomTextEncodingName(const String&);
</span></span></pre></div>
<a id="branchessafari609branchSourceWebKitWebProcessWebPageWebPagemessagesin"></a>
<div class="modfile"><h4>Modified: branches/safari-609-branch/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (260368 => 260369)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-609-branch/Source/WebKit/WebProcess/WebPage/WebPage.messages.in  2020-04-20 16:16:19 UTC (rev 260368)
+++ branches/safari-609-branch/Source/WebKit/WebProcess/WebPage/WebPage.messages.in     2020-04-20 16:23:25 UTC (rev 260369)
</span><span class="lines">@@ -183,7 +183,7 @@
</span><span class="cx">     DidRemoveBackForwardItem(struct WebCore::BackForwardItemIdentifier backForwardItemID)
</span><span class="cx"> 
</span><span class="cx">     UpdateWebsitePolicies(struct WebKit::WebsitePoliciesData websitePolicies)
</span><del>-    DidReceivePolicyDecision(WebCore::FrameIdentifier frameID, uint64_t listenerID, WebCore::PolicyCheckIdentifier policyCheckIdentifier, enum:uint8_t WebCore::PolicyAction policyAction, uint64_t navigationID, WebKit::DownloadID downloadID, Optional<WebKit::WebsitePoliciesData> websitePolicies)
</del><ins>+    DidReceivePolicyDecision(WebCore::FrameIdentifier frameID, uint64_t listenerID, WebCore::PolicyCheckIdentifier policyCheckIdentifier, enum:uint8_t WebCore::PolicyAction policyAction, uint64_t navigationID, WebKit::DownloadID downloadID, Optional<WebKit::WebsitePoliciesData> websitePolicies, Optional<WebKit::SandboxExtension::Handle> sandboxExtensionHandle)
</ins><span class="cx">     ContinueWillSubmitForm(WebCore::FrameIdentifier frameID, uint64_t listenerID)
</span><span class="cx"> 
</span><span class="cx">     ClearSelection()
</span></span></pre></div>
<a id="branchessafari609branchToolsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-609-branch/Tools/ChangeLog (260368 => 260369)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-609-branch/Tools/ChangeLog       2020-04-20 16:16:19 UTC (rev 260368)
+++ branches/safari-609-branch/Tools/ChangeLog  2020-04-20 16:23:25 UTC (rev 260369)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2020-04-20  Alan Coon  <alancoon@apple.com>
+
+        Apply patch. rdar://problem/61950472
+
+    2020-04-20  Brady Eidson  <beidson@apple.com>
+
+            Pass sandbox extensions for back/forward list navigations after the policy is decided at process-swap time.
+            <rdar://problem/59535167> and https://bugs.webkit.org/show_bug.cgi?id=210623
+
+            Reviewed by Geoff Garen.
+
+            * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
+
</ins><span class="cx"> 2020-04-17  Alan Coon  <alancoon@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Cherry-pick r260278. rdar://problem/61950220
</span></span></pre></div>
<a id="branchessafari609branchToolsTestWebKitAPITestsWebKitCocoaProcessSwapOnNavigationmm"></a>
<div class="modfile"><h4>Modified: branches/safari-609-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm (260368 => 260369)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-609-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm      2020-04-20 16:16:19 UTC (rev 260368)
+++ branches/safari-609-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm 2020-04-20 16:23:25 UTC (rev 260369)
</span><span class="lines">@@ -6548,3 +6548,88 @@
</span><span class="cx"> 
</span><span class="cx">     EXPECT_WK_STREQ(webView.get()._resourceDirectoryURL.path, file.URLByDeletingLastPathComponent.path);
</span><span class="cx"> }
</span><ins>+
+#if PLATFORM(MAC)
+
+static const char* pageThatOpensBytes = R"PSONRESOURCE(
+<script>
+window.onload = function() {
+    window.open("pson://www.webkit.org/window.html", "_blank");
+}
+</script>
+)PSONRESOURCE";
+
+static const char* openedPage = "Hello World";
+
+TEST(ProcessSwap, SameSiteWindowWithOpenerNavigateToFile)
+{
+    auto processPoolConfiguration = psonProcessPoolConfiguration();
+    processPoolConfiguration.get().processSwapsOnWindowOpenWithOpener = 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]);
+    [handler addMappingFromURLString:@"pson://www.webkit.org/main.html" toData:pageThatOpensBytes];
+    [handler addMappingFromURLString:@"pson://www.webkit.org/window.html" toData:openedPage];
+    [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"PSON"];
+
+    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
+    auto navigationDelegate = adoptNS([[PSONNavigationDelegate alloc] init]);
+    [webView setNavigationDelegate:navigationDelegate.get()];
+    auto uiDelegate = adoptNS([[PSONUIDelegate alloc] initWithNavigationDelegate:navigationDelegate.get()]);
+    [webView setUIDelegate:uiDelegate.get()];
+
+    numberOfDecidePolicyCalls = 0;
+    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main.html"]];
+    [webView loadRequest:request];
+
+    TestWebKitAPI::Util::run(&done);
+    done = false;
+
+    TestWebKitAPI::Util::run(&didCreateWebView);
+    didCreateWebView = false;
+
+    TestWebKitAPI::Util::run(&done);
+    done = false;
+
+    EXPECT_EQ(2, numberOfDecidePolicyCalls);
+
+    auto pid1 = [webView _webProcessIdentifier];
+    EXPECT_TRUE(!!pid1);
+    auto pid2 = [createdWebView _webProcessIdentifier];
+    EXPECT_TRUE(!!pid2);
+
+    EXPECT_EQ(pid1, pid2);
+
+    NSURL *url = [[NSBundle mainBundle] URLForResource:@"blinking-div" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
+    EXPECT_TRUE([url.scheme isEqualToString:@"file"]);
+
+    [createdWebView loadRequest:[NSURLRequest requestWithURL:url]];
+
+    TestWebKitAPI::Util::run(&done);
+    done = false;
+
+    EXPECT_EQ(3, numberOfDecidePolicyCalls);
+    auto pid3 = [createdWebView _webProcessIdentifier];
+    EXPECT_TRUE(!!pid3);
+    EXPECT_NE(pid2, pid3);
+
+    [createdWebView goBack];
+    TestWebKitAPI::Util::run(&done);
+    done = false;
+
+    EXPECT_EQ(4, numberOfDecidePolicyCalls);
+    auto pid4 = [createdWebView _webProcessIdentifier];
+    EXPECT_NE(pid3, pid4);
+
+    [createdWebView goForward];
+    TestWebKitAPI::Util::run(&done);
+    done = false;
+
+    EXPECT_EQ(5, numberOfDecidePolicyCalls);
+    auto pid5 = [createdWebView _webProcessIdentifier];
+    EXPECT_NE(pid4, pid5);
+}
+
+#endif // PLATFORM(MAC)
</ins></span></pre>
</div>
</div>

</body>
</html>