Title: [241752] trunk
Revision
241752
Author
[email protected]
Date
2019-02-18 18:29:02 -0800 (Mon, 18 Feb 2019)

Log Message

REGRESSION (PSON): Can't access optumbank.com from myuhc.com
https://bugs.webkit.org/show_bug.cgi?id=194797
<rdar://problem/48055151>

Reviewed by Geoffrey Garen.

Source/WebKit:

The issue was caused by us mistakenly process-swapping for a same-site server side redirect.
The reason we were getting it wrong is because the logic in
WebProcessPool::processForNavigationInternal() was expecting page.process() to be the source
process and page.pageLoadState().url() to be the source URL. Those assumptions are incorrect
when a server-side redirect occurs in a provisional process. In such case, the source process
is the ProvisionalPageProxy's process and the source URL is the provisional URL, not the
committed one.

* UIProcess/ProvisionalPageProxy.cpp:
(WebKit::ProvisionalPageProxy::didPerformServerRedirect):
(WebKit::ProvisionalPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame):
(WebKit::ProvisionalPageProxy::didReceiveMessage):
* UIProcess/ProvisionalPageProxy.h:
Make sure the provisional page forwards IPC related to server-side redirects to the page so
that the client gets informed.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::receivedNavigationPolicyDecision):
(WebKit::WebPageProxy::didPerformServerRedirect):
(WebKit::WebPageProxy::didPerformServerRedirectShared):
* UIProcess/WebPageProxy.h:
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::processForNavigation):
(WebKit::WebProcessPool::processForNavigationInternal):
* UIProcess/WebProcessPool.h:

Tools:

Add API test coverage.

* TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (241751 => 241752)


--- trunk/Source/WebKit/ChangeLog	2019-02-19 02:04:33 UTC (rev 241751)
+++ trunk/Source/WebKit/ChangeLog	2019-02-19 02:29:02 UTC (rev 241752)
@@ -1,3 +1,37 @@
+2019-02-18  Chris Dumez  <[email protected]>
+
+        REGRESSION (PSON): Can't access optumbank.com from myuhc.com
+        https://bugs.webkit.org/show_bug.cgi?id=194797
+        <rdar://problem/48055151>
+
+        Reviewed by Geoffrey Garen.
+
+        The issue was caused by us mistakenly process-swapping for a same-site server side redirect.
+        The reason we were getting it wrong is because the logic in
+        WebProcessPool::processForNavigationInternal() was expecting page.process() to be the source
+        process and page.pageLoadState().url() to be the source URL. Those assumptions are incorrect
+        when a server-side redirect occurs in a provisional process. In such case, the source process
+        is the ProvisionalPageProxy's process and the source URL is the provisional URL, not the
+        committed one.
+
+        * UIProcess/ProvisionalPageProxy.cpp:
+        (WebKit::ProvisionalPageProxy::didPerformServerRedirect):
+        (WebKit::ProvisionalPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame):
+        (WebKit::ProvisionalPageProxy::didReceiveMessage):
+        * UIProcess/ProvisionalPageProxy.h:
+        Make sure the provisional page forwards IPC related to server-side redirects to the page so
+        that the client gets informed.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::receivedNavigationPolicyDecision):
+        (WebKit::WebPageProxy::didPerformServerRedirect):
+        (WebKit::WebPageProxy::didPerformServerRedirectShared):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::processForNavigation):
+        (WebKit::WebProcessPool::processForNavigationInternal):
+        * UIProcess/WebProcessPool.h:
+
 2019-02-16  Darin Adler  <[email protected]>
 
         Continue reducing use of String::format, now focusing on hex: "%p", "%x", etc.

Modified: trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp (241751 => 241752)


--- trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp	2019-02-19 02:04:33 UTC (rev 241751)
+++ trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp	2019-02-19 02:29:02 UTC (rev 241752)
@@ -284,6 +284,16 @@
     m_page.decidePolicyForResponseShared(m_process.copyRef(), frameID, frameSecurityOrigin, identifier, navigationID, response, request, canShowMIMEType, listenerID, userData);
 }
 
+void ProvisionalPageProxy::didPerformServerRedirect(const String& sourceURLString, const String& destinationURLString, uint64_t frameID)
+{
+    m_page.didPerformServerRedirectShared(m_process.copyRef(), sourceURLString, destinationURLString, frameID);
+}
+
+void ProvisionalPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, WebCore::ResourceRequest&& request, const UserData& userData)
+{
+    m_page.didReceiveServerRedirectForProvisionalLoadForFrameShared(m_process.copyRef(), frameID, navigationID, WTFMove(request), userData);
+}
+
 void ProvisionalPageProxy::startURLSchemeTask(URLSchemeTaskParameters&& parameters)
 {
     m_page.startURLSchemeTaskShared(m_process.copyRef(), WTFMove(parameters));
@@ -374,6 +384,16 @@
         return;
     }
 
+    if (decoder.messageName() == Messages::WebPageProxy::DidReceiveServerRedirectForProvisionalLoadForFrame::name()) {
+        IPC::handleMessage<Messages::WebPageProxy::DidReceiveServerRedirectForProvisionalLoadForFrame>(decoder, this, &ProvisionalPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame);
+        return;
+    }
+
+    if (decoder.messageName() == Messages::WebPageProxy::DidPerformServerRedirect::name()) {
+        IPC::handleMessage<Messages::WebPageProxy::DidPerformServerRedirect>(decoder, this, &ProvisionalPageProxy::didPerformServerRedirect);
+        return;
+    }
+
     LOG(ProcessSwapping, "Unhandled message %s::%s from provisional process", decoder.messageReceiverName().toString().data(), decoder.messageName().toString().data());
 }
 

Modified: trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.h (241751 => 241752)


--- trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.h	2019-02-19 02:04:33 UTC (rev 241751)
+++ trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.h	2019-02-19 02:29:02 UTC (rev 241752)
@@ -64,6 +64,7 @@
     WebProcessProxy& process() { return m_process.get(); }
     ProcessSwapRequestedByClient processSwapRequestedByClient() const { return m_processSwapRequestedByClient; }
     uint64_t navigationID() const { return m_navigationID; }
+    const URL& provisionalURL() const { return m_provisionalLoadURL; }
 
     DrawingAreaProxy* drawingArea() const { return m_drawingArea.get(); }
     std::unique_ptr<DrawingAreaProxy> takeDrawingArea();
@@ -91,6 +92,8 @@
     void decidePolicyForResponse(uint64_t frameID, const WebCore::SecurityOriginData&, WebCore::PolicyCheckIdentifier, uint64_t navigationID, const WebCore::ResourceResponse&,
         const WebCore::ResourceRequest&, bool canShowMIMEType, uint64_t listenerID, const UserData&);
     void didChangeProvisionalURLForFrame(uint64_t frameID, uint64_t navigationID, URL&&);
+    void didPerformServerRedirect(const String& sourceURLString, const String& destinationURLString, uint64_t frameID);
+    void didReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, WebCore::ResourceRequest&&, const UserData&);
     void didNavigateWithNavigationData(const WebNavigationDataStore&, uint64_t frameID);
     void didPerformClientRedirect(const String& sourceURLString, const String& destinationURLString, uint64_t frameID);
     void didCreateMainFrame(uint64_t frameID);

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (241751 => 241752)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2019-02-19 02:04:33 UTC (rev 241751)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2019-02-19 02:29:02 UTC (rev 241752)
@@ -2748,7 +2748,17 @@
         return;
     }
 
-    process().processPool().processForNavigation(*this, *navigation, processSwapRequestedByClient, [this, protectedThis = makeRef(*this), policyAction, navigation = makeRef(*navigation),
+    Ref<WebProcessProxy> sourceProcess = process();
+    URL sourceURL = URL { URL(), pageLoadState().url() };
+    if (auto* provisionalPage = provisionalPageProxy()) {
+        if (provisionalPage->navigationID() == navigation->navigationID()) {
+            ASSERT(navigation->currentRequestIsRedirect());
+            sourceProcess = provisionalPage->process();
+            sourceURL = provisionalPage->provisionalURL();
+        }
+    }
+
+    process().processPool().processForNavigation(*this, *navigation, sourceProcess.copyRef(), sourceURL, processSwapRequestedByClient, [this, protectedThis = makeRef(*this), policyAction, navigation = makeRef(*navigation), sourceProcess = sourceProcess.copyRef(),
         data = "" sender = WTFMove(sender), processSwapRequestedByClient] (Ref<WebProcessProxy>&& processForNavigation, SuspendedPageProxy* destinationSuspendedPage, const String& reason) mutable {
         // If the navigation has been destroyed, then no need to proceed.
         if (isClosed() || !navigationState().hasNavigation(navigation->navigationID())) {
@@ -2756,7 +2766,8 @@
             return;
         }
 
-        if (processForNavigation.ptr() != &process()) {
+        bool shouldProcessSwap = processForNavigation.ptr() != sourceProcess.ptr();
+        if (shouldProcessSwap) {
             policyAction = PolicyAction::StopAllLoads;
             RELEASE_LOG_IF_ALLOWED(ProcessSwapping, "decidePolicyForNavigationAction, swapping process %i with process %i for navigation, reason: %{public}s", processIdentifier(), processForNavigation->processIdentifier(), reason.utf8().data());
             LOG(ProcessSwapping, "(ProcessSwapping) Switching from process %i to new process (%i) for navigation %" PRIu64 " '%s'", processIdentifier(), processForNavigation->processIdentifier(), navigation->navigationID(), navigation->loggingString());
@@ -2763,7 +2774,6 @@
         } else
             RELEASE_LOG_IF_ALLOWED(ProcessSwapping, "decidePolicyForNavigationAction: keep using process %i for navigation, reason: %{public}s", processIdentifier(), reason.utf8().data());
 
-        bool shouldProcessSwap = processForNavigation.ptr() != &process();
         receivedPolicyDecision(policyAction, navigation.ptr(), shouldProcessSwap ? WTF::nullopt : WTFMove(data), WTFMove(sender), shouldProcessSwap ? WillContinueLoadInNewProcess::Yes : WillContinueLoadInNewProcess::No);
 
         if (!shouldProcessSwap)
@@ -4798,23 +4808,28 @@
 
 void WebPageProxy::didPerformServerRedirect(const String& sourceURLString, const String& destinationURLString, uint64_t frameID)
 {
-    RELEASE_LOG_IF_ALLOWED(Loading, "didPerformServerRedirect: webPID = %i, pageID = %" PRIu64, m_process->processIdentifier(), m_pageID);
+    didPerformServerRedirectShared(m_process.copyRef(), sourceURLString, destinationURLString, frameID);
+}
 
+void WebPageProxy::didPerformServerRedirectShared(Ref<WebProcessProxy>&& process, const String& sourceURLString, const String& destinationURLString, uint64_t frameID)
+{
+    RELEASE_LOG_IF_ALLOWED(Loading, "didPerformServerRedirect: webPID = %i, pageID = %" PRIu64, process->processIdentifier(), m_pageID);
+
     PageClientProtector protector(pageClient());
 
     if (sourceURLString.isEmpty() || destinationURLString.isEmpty())
         return;
     
-    WebFrameProxy* frame = m_process->webFrame(frameID);
-    MESSAGE_CHECK(m_process, frame);
-    MESSAGE_CHECK(m_process, frame->page() == this);
+    WebFrameProxy* frame = process->webFrame(frameID);
+    MESSAGE_CHECK(process, frame);
+    MESSAGE_CHECK(process, frame->page() == this);
 
-    MESSAGE_CHECK_URL(m_process, sourceURLString);
-    MESSAGE_CHECK_URL(m_process, destinationURLString);
+    MESSAGE_CHECK_URL(process, sourceURLString);
+    MESSAGE_CHECK_URL(process, destinationURLString);
 
     if (frame->isMainFrame())
         m_historyClient->didPerformServerRedirect(*this, sourceURLString, destinationURLString);
-    process().processPool().historyClient().didPerformServerRedirect(process().processPool(), *this, sourceURLString, destinationURLString, *frame);
+    process->processPool().historyClient().didPerformServerRedirect(process->processPool(), *this, sourceURLString, destinationURLString, *frame);
 }
 
 void WebPageProxy::didUpdateHistoryTitle(const String& title, const String& url, uint64_t frameID)

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (241751 => 241752)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2019-02-19 02:04:33 UTC (rev 241751)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2019-02-19 02:29:02 UTC (rev 241752)
@@ -1442,6 +1442,7 @@
     void didStartProvisionalLoadForFrameShared(Ref<WebProcessProxy>&&, uint64_t frameID, uint64_t navigationID, URL&&, URL&& unreachableURL, const UserData&);
     void didFailProvisionalLoadForFrameShared(Ref<WebProcessProxy>&&, uint64_t frameID, const WebCore::SecurityOriginData& frameSecurityOrigin, uint64_t navigationID, const String& provisionalURL, const WebCore::ResourceError&, const UserData&);
     void didReceiveServerRedirectForProvisionalLoadForFrameShared(Ref<WebProcessProxy>&&, uint64_t frameID, uint64_t navigationID, WebCore::ResourceRequest&&, const UserData&);
+    void didPerformServerRedirectShared(Ref<WebProcessProxy>&&, const String& sourceURLString, const String& destinationURLString, uint64_t frameID);
     void didPerformClientRedirectShared(Ref<WebProcessProxy>&&, const String& sourceURLString, const String& destinationURLString, uint64_t frameID);
     void didNavigateWithNavigationDataShared(Ref<WebProcessProxy>&&, const WebNavigationDataStore&, uint64_t frameID);
     void didChangeProvisionalURLForFrameShared(Ref<WebProcessProxy>&&, uint64_t frameID, uint64_t navigationID, URL&&);

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (241751 => 241752)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2019-02-19 02:04:33 UTC (rev 241751)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2019-02-19 02:29:02 UTC (rev 241752)
@@ -2115,14 +2115,14 @@
 }
 #endif
 
-void WebProcessPool::addProcessToOriginCacheSet(WebPageProxy& page)
+void WebProcessPool::addProcessToOriginCacheSet(WebProcessProxy& process, const URL& url)
 {
-    auto registrableDomain = toRegistrableDomain({ { }, page.pageLoadState().url() });
-    auto result = m_swappedProcessesPerRegistrableDomain.add(registrableDomain, &page.process());
+    auto registrableDomain = toRegistrableDomain(url);
+    auto result = m_swappedProcessesPerRegistrableDomain.add(registrableDomain, &process);
     if (!result.isNewEntry)
-        result.iterator->value = &page.process();
+        result.iterator->value = &process;
 
-    LOG(ProcessSwapping, "(ProcessSwapping) Registrable domain %s just saved a cached process with pid %i", registrableDomain.utf8().data(), page.process().processIdentifier());
+    LOG(ProcessSwapping, "(ProcessSwapping) Registrable domain %s just saved a cached process with pid %i", registrableDomain.utf8().data(), process.processIdentifier());
     if (!result.isNewEntry)
         LOG(ProcessSwapping, "(ProcessSwapping) Note: It already had one saved");
 }
@@ -2142,25 +2142,25 @@
         m_swappedProcessesPerRegistrableDomain.remove(registrableDomain);
 }
 
-void WebProcessPool::processForNavigation(WebPageProxy& page, const API::Navigation& navigation, ProcessSwapRequestedByClient processSwapRequestedByClient, CompletionHandler<void(Ref<WebProcessProxy>&&, SuspendedPageProxy*, const String&)>&& completionHandler)
+void WebProcessPool::processForNavigation(WebPageProxy& page, const API::Navigation& navigation, Ref<WebProcessProxy>&& sourceProcess, const URL& sourceURL, ProcessSwapRequestedByClient processSwapRequestedByClient, CompletionHandler<void(Ref<WebProcessProxy>&&, SuspendedPageProxy*, const String&)>&& completionHandler)
 {
-    processForNavigationInternal(page, navigation, processSwapRequestedByClient, [this, page = makeRefPtr(page), navigation = makeRef(navigation), processSwapRequestedByClient, completionHandler = WTFMove(completionHandler)](Ref<WebProcessProxy>&& process, SuspendedPageProxy* suspendedPage, const String& reason) mutable {
+    processForNavigationInternal(page, navigation, sourceProcess.copyRef(), sourceURL, processSwapRequestedByClient, [this, page = makeRefPtr(page), navigation = makeRef(navigation), sourceProcess = sourceProcess.copyRef(), sourceURL, processSwapRequestedByClient, completionHandler = WTFMove(completionHandler)](Ref<WebProcessProxy>&& process, SuspendedPageProxy* suspendedPage, const String& reason) mutable {
         // We are process-swapping so automatic process prewarming would be beneficial if the client has not explicitly enabled / disabled it.
-        bool doingAnAutomaticProcessSwap = processSwapRequestedByClient == ProcessSwapRequestedByClient::No && process.ptr() != &page->process();
+        bool doingAnAutomaticProcessSwap = processSwapRequestedByClient == ProcessSwapRequestedByClient::No && process.ptr() != sourceProcess.ptr();
         if (doingAnAutomaticProcessSwap && !configuration().wasAutomaticProcessWarmingSetByClient() && !configuration().clientWouldBenefitFromAutomaticProcessPrewarming()) {
             RELEASE_LOG(PerformanceLogging, "Automatically turning on process prewarming because the client would benefit from it");
             configuration().setClientWouldBenefitFromAutomaticProcessPrewarming(true);
         }
 
-        if (m_configuration->alwaysKeepAndReuseSwappedProcesses() && process.ptr() != &page->process()) {
+        if (m_configuration->alwaysKeepAndReuseSwappedProcesses() && process.ptr() != sourceProcess.ptr()) {
             static std::once_flag onceFlag;
             std::call_once(onceFlag, [] {
                 WTFLogAlways("WARNING: The option to always keep swapped web processes alive is active. This is meant for debugging and testing only.");
             });
 
-            addProcessToOriginCacheSet(*page);
+            addProcessToOriginCacheSet(sourceProcess, sourceURL);
 
-            LOG(ProcessSwapping, "(ProcessSwapping) Navigating from %s to %s, keeping around old process. Now holding on to old processes for %u origins.", page->currentURL().utf8().data(), navigation->currentRequest().url().string().utf8().data(), m_swappedProcessesPerRegistrableDomain.size());
+            LOG(ProcessSwapping, "(ProcessSwapping) Navigating from %s to %s, keeping around old process. Now holding on to old processes for %u origins.", sourceURL.string().utf8().data(), navigation->currentRequest().url().string().utf8().data(), m_swappedProcessesPerRegistrableDomain.size());
         }
 
         completionHandler(WTFMove(process), suspendedPage, reason);
@@ -2167,7 +2167,7 @@
     });
 }
 
-void WebProcessPool::processForNavigationInternal(WebPageProxy& page, const API::Navigation& navigation, ProcessSwapRequestedByClient processSwapRequestedByClient, CompletionHandler<void(Ref<WebProcessProxy>&&, SuspendedPageProxy*, const String&)>&& completionHandler)
+void WebProcessPool::processForNavigationInternal(WebPageProxy& page, const API::Navigation& navigation, Ref<WebProcessProxy>&& sourceProcess, const URL& pageSourceURL, ProcessSwapRequestedByClient processSwapRequestedByClient, CompletionHandler<void(Ref<WebProcessProxy>&&, SuspendedPageProxy*, const String&)>&& completionHandler)
 {
     auto& targetURL = navigation.currentRequest().url();
     auto registrableDomain = toRegistrableDomain(targetURL);
@@ -2193,30 +2193,30 @@
     };
 
     if (usesSingleWebProcess())
-        return completionHandler(page.process(), nullptr, "Single WebProcess mode is enabled"_s);
+        return completionHandler(WTFMove(sourceProcess), nullptr, "Single WebProcess mode is enabled"_s);
 
     if (processSwapRequestedByClient == ProcessSwapRequestedByClient::Yes)
         return completionHandler(createNewProcess(), nullptr, "Process swap was requested by the client"_s);
 
     if (!m_configuration->processSwapsOnNavigation())
-        return completionHandler(page.process(), nullptr, "Feature is disabled"_s);
+        return completionHandler(WTFMove(sourceProcess), nullptr, "Feature is disabled"_s);
 
     if (m_automationSession)
-        return completionHandler(page.process(), nullptr, "An automation session is active"_s);
+        return completionHandler(WTFMove(sourceProcess), nullptr, "An automation session is active"_s);
 
-    if (!page.process().hasCommittedAnyProvisionalLoads()) {
-        tryPrewarmWithDomainInformation(page.process(), targetURL);
-        return completionHandler(page.process(), nullptr, "Process has not yet committed any provisional loads"_s);
+    if (!sourceProcess->hasCommittedAnyProvisionalLoads()) {
+        tryPrewarmWithDomainInformation(sourceProcess, targetURL);
+        return completionHandler(WTFMove(sourceProcess), nullptr, "Process has not yet committed any provisional loads"_s);
     }
 
     // FIXME: We should support process swap when a window has been opened via window.open() without 'noopener'.
     // The issue is that the opener has a handle to the WindowProxy.
     if (navigation.openedByDOMWithOpener() && !m_configuration->processSwapsOnWindowOpenWithOpener())
-        return completionHandler(page.process(), nullptr, "Browsing context been opened by DOM without 'noopener'"_s);
+        return completionHandler(WTFMove(sourceProcess), nullptr, "Browsing context been opened by DOM without 'noopener'"_s);
 
     // FIXME: We should support process swap when a window has opened other windows via window.open.
     if (navigation.hasOpenedFrames())
-        return completionHandler(page.process(), nullptr, "Browsing context has opened other windows"_s);
+        return completionHandler(WTFMove(sourceProcess), nullptr, "Browsing context has opened other windows"_s);
 
     if (auto* targetItem = navigation.targetItem()) {
         if (auto* suspendedPage = targetItem->suspendedPage()) {
@@ -2245,13 +2245,13 @@
     }
 
     if (navigation.treatAsSameOriginNavigation())
-        return completionHandler(page.process(), nullptr, "The treatAsSameOriginNavigation flag is set"_s);
+        return completionHandler(WTFMove(sourceProcess), nullptr, "The treatAsSameOriginNavigation flag is set"_s);
 
     URL sourceURL;
     if (page.isPageOpenedByDOMShowingInitialEmptyDocument() && !navigation.requesterOrigin().isEmpty())
         sourceURL = URL { URL(), navigation.requesterOrigin().toString() };
     else
-        sourceURL = URL { { }, page.pageLoadState().url() };
+        sourceURL = pageSourceURL;
 
     if (sourceURL.isEmpty() && page.configuration().relatedPage()) {
         sourceURL = URL { { }, page.configuration().relatedPage()->pageLoadState().url() };
@@ -2259,7 +2259,7 @@
     }
 
     if (!sourceURL.isValid() || !targetURL.isValid() || sourceURL.isEmpty() || sourceURL.protocolIsAbout() || registrableDomainsAreEqual(sourceURL, targetURL))
-        return completionHandler(page.process(), nullptr, "Navigation is same-site"_s);
+        return completionHandler(WTFMove(sourceProcess), nullptr, "Navigation is same-site"_s);
 
     String reason = "Navigation is cross-site"_s;
     

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.h (241751 => 241752)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.h	2019-02-19 02:04:33 UTC (rev 241751)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.h	2019-02-19 02:29:02 UTC (rev 241752)
@@ -457,7 +457,7 @@
     BackgroundWebProcessToken backgroundWebProcessToken() const { return BackgroundWebProcessToken(m_backgroundWebProcessCounter.count()); }
 #endif
 
-    void processForNavigation(WebPageProxy&, const API::Navigation&, ProcessSwapRequestedByClient, CompletionHandler<void(Ref<WebProcessProxy>&&, SuspendedPageProxy*, const String&)>&&);
+    void processForNavigation(WebPageProxy&, const API::Navigation&, Ref<WebProcessProxy>&& sourceProcess, const URL& sourceURL, ProcessSwapRequestedByClient, CompletionHandler<void(Ref<WebProcessProxy>&&, SuspendedPageProxy*, const String&)>&&);
 
     // SuspendedPageProxy management.
     void addSuspendedPage(std::unique_ptr<SuspendedPageProxy>&&);
@@ -499,7 +499,7 @@
     void platformInitializeWebProcess(WebProcessCreationParameters&);
     void platformInvalidateContext();
 
-    void processForNavigationInternal(WebPageProxy&, const API::Navigation&, ProcessSwapRequestedByClient, CompletionHandler<void(Ref<WebProcessProxy>&&, SuspendedPageProxy*, const String&)>&&);
+    void processForNavigationInternal(WebPageProxy&, const API::Navigation&, Ref<WebProcessProxy>&& sourceProcess, const URL& sourceURL, ProcessSwapRequestedByClient, CompletionHandler<void(Ref<WebProcessProxy>&&, SuspendedPageProxy*, const String&)>&&);
 
     RefPtr<WebProcessProxy> tryTakePrewarmedProcess(WebsiteDataStore&);
 
@@ -562,7 +562,7 @@
     void resolvePathsForSandboxExtensions();
     void platformResolvePathsForSandboxExtensions();
 
-    void addProcessToOriginCacheSet(WebPageProxy&);
+    void addProcessToOriginCacheSet(WebProcessProxy&, const URL&);
     void removeProcessFromOriginCacheSet(WebProcessProxy&);
 
     void tryPrewarmWithDomainInformation(WebProcessProxy&, const URL&);

Modified: trunk/Tools/ChangeLog (241751 => 241752)


--- trunk/Tools/ChangeLog	2019-02-19 02:04:33 UTC (rev 241751)
+++ trunk/Tools/ChangeLog	2019-02-19 02:29:02 UTC (rev 241752)
@@ -1,3 +1,15 @@
+2019-02-18  Chris Dumez  <[email protected]>
+
+        REGRESSION (PSON): Can't access optumbank.com from myuhc.com
+        https://bugs.webkit.org/show_bug.cgi?id=194797
+        <rdar://problem/48055151>
+
+        Reviewed by Geoffrey Garen.
+
+        Add API test coverage.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
+
 2019-02-18  Wenson Hsieh  <[email protected]>
 
         [iOS] Support pasting item-provider-backed data on the pasteboard as attachment elements

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm (241751 => 241752)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm	2019-02-19 02:04:33 UTC (rev 241751)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm	2019-02-19 02:29:02 UTC (rev 241752)
@@ -1406,11 +1406,15 @@
     serverRedirected = false;
 
     seenPIDs.add([webView _webProcessIdentifier]);
+    if (auto provisionalPID = [webView _provisionalWebProcessIdentifier])
+        seenPIDs.add(provisionalPID);
 
     TestWebKitAPI::Util::run(&done);
     done = false;
 
     seenPIDs.add([webView _webProcessIdentifier]);
+    if (auto provisionalPID = [webView _provisionalWebProcessIdentifier])
+        seenPIDs.add(provisionalPID);
 
     EXPECT_FALSE(serverRedirected);
     EXPECT_EQ(3, numberOfDecidePolicyCalls);
@@ -1455,11 +1459,15 @@
     serverRedirected = false;
 
     seenPIDs.add([webView _webProcessIdentifier]);
+    if (auto provisionalPID = [webView _provisionalWebProcessIdentifier])
+        seenPIDs.add(provisionalPID);
 
     TestWebKitAPI::Util::run(&done);
     done = false;
 
     seenPIDs.add([webView _webProcessIdentifier]);
+    if (auto provisionalPID = [webView _provisionalWebProcessIdentifier])
+        seenPIDs.add(provisionalPID);
 
     EXPECT_FALSE(serverRedirected);
     EXPECT_EQ(3, numberOfDecidePolicyCalls);
@@ -1475,6 +1483,87 @@
     EXPECT_WK_STREQ(@"pson://www.webkit.org/main1.html", [[webView URL] absoluteString]);
 }
 
+enum class ShouldCacheProcessFirst { No, Yes };
+static void runSameOriginServerRedirectTest(ShouldCacheProcessFirst shouldCacheProcessFirst)
+{
+    auto processPoolConfiguration = psonProcessPoolConfiguration();
+    processPoolConfiguration.get().processSwapsOnNavigation = 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:crossSiteClientSideRedirectBytes];
+    [handler addRedirectFromURLString:@"pson://www.apple.com/main.html" toURLString:@"pson://www.apple.com/main2.html"];
+    [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()];
+
+    NSURLRequest *request;
+
+    if (shouldCacheProcessFirst == ShouldCacheProcessFirst::Yes) {
+        request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.apple.com/main3.html"]];
+        [webView loadRequest:request];
+
+        TestWebKitAPI::Util::run(&done);
+        done = false;
+    }
+
+    delegate->didStartProvisionalNavigationHandler = ^{
+        seenPIDs.add([webView _webProcessIdentifier]);
+        if (auto provisionalPID = [webView _provisionalWebProcessIdentifier])
+            seenPIDs.add(provisionalPID);
+    };
+
+    willPerformClientRedirect = false;
+    didPerformClientRedirect = false;
+    serverRedirected = false;
+    request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main.html"]];
+    [webView loadRequest:request];
+
+    TestWebKitAPI::Util::run(&willPerformClientRedirect);
+
+    seenPIDs.add([webView _webProcessIdentifier]);
+    if (auto provisionalPID = [webView _provisionalWebProcessIdentifier])
+        seenPIDs.add(provisionalPID);
+
+    TestWebKitAPI::Util::run(&didPerformClientRedirect);
+    didPerformClientRedirect = false;
+    willPerformClientRedirect = false;
+
+    seenPIDs.add([webView _webProcessIdentifier]);
+    if (auto provisionalPID = [webView _provisionalWebProcessIdentifier])
+        seenPIDs.add(provisionalPID);
+
+    TestWebKitAPI::Util::run(&serverRedirected);
+    serverRedirected = false;
+
+    seenPIDs.add([webView _webProcessIdentifier]);
+    if (auto provisionalPID = [webView _provisionalWebProcessIdentifier])
+        seenPIDs.add(provisionalPID);
+
+    TestWebKitAPI::Util::run(&done);
+    done = false;
+
+    seenPIDs.add([webView _webProcessIdentifier]);
+    if (auto provisionalPID = [webView _provisionalWebProcessIdentifier])
+        seenPIDs.add(provisionalPID);
+
+    EXPECT_EQ(2u, seenPIDs.size());
+}
+
+TEST(ProcessSwap, SameOriginServerRedirect)
+{
+    runSameOriginServerRedirectTest(ShouldCacheProcessFirst::No);
+}
+
+TEST(ProcessSwap, SameOriginServerRedirectFromCachedProcess)
+{
+    runSameOriginServerRedirectTest(ShouldCacheProcessFirst::Yes);
+}
+
 TEST(ProcessSwap, TerminateProcessRightAfterSwap)
 {
     auto processPoolConfiguration = psonProcessPoolConfiguration();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to