Title: [281904] branches/safari-612-branch
Revision
281904
Author
[email protected]
Date
2021-09-01 18:05:35 -0700 (Wed, 01 Sep 2021)

Log Message

Cherry-pick r281817. rdar://problem/82652467

    Loads after session restore marked app initiated in Safari
    https://bugs.webkit.org/show_bug.cgi?id=229721
    <rdar://problem/82084236>

    Reviewed by Brent Fulgham.

    Source/WebCore:

    * loader/FrameLoader.cpp:
    (WebCore::FrameLoader::loadDifferentDocumentItem):
    Set the proper app initiated value when creating a new request.

    Source/WebKit:

    Offer a way to set the app initiated value when restoring a session.

    * Shared/SessionState.h:
    * UIProcess/API/Cocoa/WKWebView.mm:
    (-[WKWebView _restoreSessionState:andNavigate:]):
    * UIProcess/API/Cocoa/_WKSessionState.h:
    * UIProcess/API/Cocoa/_WKSessionState.mm:
    (-[_WKSessionState _sessionStateWithAppInitiatedValue]):
    * UIProcess/API/Cocoa/_WKSessionStateInternal.h:
    * UIProcess/ProvisionalPageProxy.cpp:
    (WebKit::ProvisionalPageProxy::goToBackForwardItem):
    * UIProcess/WebPageProxy.cpp:
    (WebKit::WebPageProxy::launchProcessForReload):
    (WebKit::WebPageProxy::goToBackForwardItem):
    (WebKit::WebPageProxy::restoreFromSessionState):
    * UIProcess/WebPageProxy.h:
    * WebProcess/WebPage/WebPage.cpp:
    (WebKit::WebPage::goToBackForwardItem):
    * WebProcess/WebPage/WebPage.h:
    * WebProcess/WebPage/WebPage.messages.in:

    Tools:

    API test coverage.

    * TestWebKitAPI/Tests/WebKitCocoa/AppPrivacyReport.mm:

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281817 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-612-branch/Source/WebCore/ChangeLog (281903 => 281904)


--- branches/safari-612-branch/Source/WebCore/ChangeLog	2021-09-02 01:05:29 UTC (rev 281903)
+++ branches/safari-612-branch/Source/WebCore/ChangeLog	2021-09-02 01:05:35 UTC (rev 281904)
@@ -1,5 +1,64 @@
 2021-09-01  Russell Epstein  <[email protected]>
 
+        Cherry-pick r281817. rdar://problem/82652467
+
+    Loads after session restore marked app initiated in Safari
+    https://bugs.webkit.org/show_bug.cgi?id=229721
+    <rdar://problem/82084236>
+    
+    Reviewed by Brent Fulgham.
+    
+    Source/WebCore:
+    
+    * loader/FrameLoader.cpp:
+    (WebCore::FrameLoader::loadDifferentDocumentItem):
+    Set the proper app initiated value when creating a new request.
+    
+    Source/WebKit:
+    
+    Offer a way to set the app initiated value when restoring a session.
+    
+    * Shared/SessionState.h:
+    * UIProcess/API/Cocoa/WKWebView.mm:
+    (-[WKWebView _restoreSessionState:andNavigate:]):
+    * UIProcess/API/Cocoa/_WKSessionState.h:
+    * UIProcess/API/Cocoa/_WKSessionState.mm:
+    (-[_WKSessionState _sessionStateWithAppInitiatedValue]):
+    * UIProcess/API/Cocoa/_WKSessionStateInternal.h:
+    * UIProcess/ProvisionalPageProxy.cpp:
+    (WebKit::ProvisionalPageProxy::goToBackForwardItem):
+    * UIProcess/WebPageProxy.cpp:
+    (WebKit::WebPageProxy::launchProcessForReload):
+    (WebKit::WebPageProxy::goToBackForwardItem):
+    (WebKit::WebPageProxy::restoreFromSessionState):
+    * UIProcess/WebPageProxy.h:
+    * WebProcess/WebPage/WebPage.cpp:
+    (WebKit::WebPage::goToBackForwardItem):
+    * WebProcess/WebPage/WebPage.h:
+    * WebProcess/WebPage/WebPage.messages.in:
+    
+    Tools:
+    
+    API test coverage.
+    
+    * TestWebKitAPI/Tests/WebKitCocoa/AppPrivacyReport.mm:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281817 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-08-31  Kate Cheney  <[email protected]>
+
+            Loads after session restore marked app initiated in Safari
+            https://bugs.webkit.org/show_bug.cgi?id=229721
+            <rdar://problem/82084236>
+
+            Reviewed by Brent Fulgham.
+
+            * loader/FrameLoader.cpp:
+            (WebCore::FrameLoader::loadDifferentDocumentItem):
+            Set the proper app initiated value when creating a new request.
+
+2021-09-01  Russell Epstein  <[email protected]>
+
         Cherry-pick r281884. rdar://problem/82651913
 
     PerformanceNavigationTiming should be instantiated before scripts run then updated when response finishes

Modified: branches/safari-612-branch/Source/WebCore/loader/FrameLoader.cpp (281903 => 281904)


--- branches/safari-612-branch/Source/WebCore/loader/FrameLoader.cpp	2021-09-02 01:05:29 UTC (rev 281903)
+++ branches/safari-612-branch/Source/WebCore/loader/FrameLoader.cpp	2021-09-02 01:05:35 UTC (rev 281904)
@@ -3800,6 +3800,9 @@
     bool isFormSubmission = false;
     Event* event = nullptr;
 
+    if (auto* documentLoader = m_frame.mainFrame().loader().documentLoader())
+        request.setIsAppInitiated(documentLoader->lastNavigationWasAppInitiated());
+
     // If this was a repost that failed the page cache, we might try to repost the form.
     NavigationAction action;
     if (formData) {

Modified: branches/safari-612-branch/Source/WebKit/ChangeLog (281903 => 281904)


--- branches/safari-612-branch/Source/WebKit/ChangeLog	2021-09-02 01:05:29 UTC (rev 281903)
+++ branches/safari-612-branch/Source/WebKit/ChangeLog	2021-09-02 01:05:35 UTC (rev 281904)
@@ -1,5 +1,81 @@
 2021-09-01  Russell Epstein  <[email protected]>
 
+        Cherry-pick r281817. rdar://problem/82652467
+
+    Loads after session restore marked app initiated in Safari
+    https://bugs.webkit.org/show_bug.cgi?id=229721
+    <rdar://problem/82084236>
+    
+    Reviewed by Brent Fulgham.
+    
+    Source/WebCore:
+    
+    * loader/FrameLoader.cpp:
+    (WebCore::FrameLoader::loadDifferentDocumentItem):
+    Set the proper app initiated value when creating a new request.
+    
+    Source/WebKit:
+    
+    Offer a way to set the app initiated value when restoring a session.
+    
+    * Shared/SessionState.h:
+    * UIProcess/API/Cocoa/WKWebView.mm:
+    (-[WKWebView _restoreSessionState:andNavigate:]):
+    * UIProcess/API/Cocoa/_WKSessionState.h:
+    * UIProcess/API/Cocoa/_WKSessionState.mm:
+    (-[_WKSessionState _sessionStateWithAppInitiatedValue]):
+    * UIProcess/API/Cocoa/_WKSessionStateInternal.h:
+    * UIProcess/ProvisionalPageProxy.cpp:
+    (WebKit::ProvisionalPageProxy::goToBackForwardItem):
+    * UIProcess/WebPageProxy.cpp:
+    (WebKit::WebPageProxy::launchProcessForReload):
+    (WebKit::WebPageProxy::goToBackForwardItem):
+    (WebKit::WebPageProxy::restoreFromSessionState):
+    * UIProcess/WebPageProxy.h:
+    * WebProcess/WebPage/WebPage.cpp:
+    (WebKit::WebPage::goToBackForwardItem):
+    * WebProcess/WebPage/WebPage.h:
+    * WebProcess/WebPage/WebPage.messages.in:
+    
+    Tools:
+    
+    API test coverage.
+    
+    * TestWebKitAPI/Tests/WebKitCocoa/AppPrivacyReport.mm:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281817 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-08-31  Kate Cheney  <[email protected]>
+
+            Loads after session restore marked app initiated in Safari
+            https://bugs.webkit.org/show_bug.cgi?id=229721
+            <rdar://problem/82084236>
+
+            Reviewed by Brent Fulgham.
+
+            Offer a way to set the app initiated value when restoring a session.
+
+            * Shared/SessionState.h:
+            * UIProcess/API/Cocoa/WKWebView.mm:
+            (-[WKWebView _restoreSessionState:andNavigate:]):
+            * UIProcess/API/Cocoa/_WKSessionState.h:
+            * UIProcess/API/Cocoa/_WKSessionState.mm:
+            (-[_WKSessionState _sessionStateWithAppInitiatedValue]):
+            * UIProcess/API/Cocoa/_WKSessionStateInternal.h:
+            * UIProcess/ProvisionalPageProxy.cpp:
+            (WebKit::ProvisionalPageProxy::goToBackForwardItem):
+            * UIProcess/WebPageProxy.cpp:
+            (WebKit::WebPageProxy::launchProcessForReload):
+            (WebKit::WebPageProxy::goToBackForwardItem):
+            (WebKit::WebPageProxy::restoreFromSessionState):
+            * UIProcess/WebPageProxy.h:
+            * WebProcess/WebPage/WebPage.cpp:
+            (WebKit::WebPage::goToBackForwardItem):
+            * WebProcess/WebPage/WebPage.h:
+            * WebProcess/WebPage/WebPage.messages.in:
+
+2021-09-01  Russell Epstein  <[email protected]>
+
         Cherry-pick r281780. rdar://problem/82650791
 
     Update availability macros for APIs available in iOS 14.5 and macOS 11.3

Modified: branches/safari-612-branch/Source/WebKit/Shared/SessionState.h (281903 => 281904)


--- branches/safari-612-branch/Source/WebKit/Shared/SessionState.h	2021-09-02 01:05:29 UTC (rev 281903)
+++ branches/safari-612-branch/Source/WebKit/Shared/SessionState.h	2021-09-02 01:05:35 UTC (rev 281904)
@@ -158,6 +158,7 @@
     BackForwardListState backForwardListState;
     uint64_t renderTreeSize;
     URL provisionalURL;
+    bool isAppInitiated { true };
 };
 
 } // namespace WebKit

Modified: branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (281903 => 281904)


--- branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2021-09-02 01:05:29 UTC (rev 281903)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2021-09-02 01:05:35 UTC (rev 281904)
@@ -2641,7 +2641,7 @@
 - (WKNavigation *)_restoreSessionState:(_WKSessionState *)sessionState andNavigate:(BOOL)navigate
 {
     THROW_IF_SUSPENDED;
-    return wrapper(_page->restoreFromSessionState(sessionState ? sessionState->_sessionState : WebKit::SessionState { }, navigate));
+    return wrapper(_page->restoreFromSessionState(sessionState ? sessionState._sessionStateWithAppInitiatedValue : WebKit::SessionState { }, navigate));
 }
 
 - (void)_close

Modified: branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/_WKSessionState.h (281903 => 281904)


--- branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/_WKSessionState.h	2021-09-02 01:05:29 UTC (rev 281903)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/_WKSessionState.h	2021-09-02 01:05:35 UTC (rev 281904)
@@ -33,5 +33,6 @@
 - (instancetype)initWithData:(NSData *)data;
 
 @property (nonatomic, readonly, copy) NSData *data;
+@property (nonatomic) BOOL isAppInitiated;
 
 @end

Modified: branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/_WKSessionState.mm (281903 => 281904)


--- branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/_WKSessionState.mm	2021-09-02 01:05:29 UTC (rev 281903)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/_WKSessionState.mm	2021-09-02 01:05:35 UTC (rev 281904)
@@ -58,4 +58,10 @@
     return WebKit::encodeSessionState(_sessionState).autorelease();
 }
 
+- (WebKit::SessionState)_sessionStateWithAppInitiatedValue
+{
+    _sessionState.isAppInitiated = _isAppInitiated;
+    return _sessionState;
+}
+
 @end

Modified: branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/_WKSessionStateInternal.h (281903 => 281904)


--- branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/_WKSessionStateInternal.h	2021-09-02 01:05:29 UTC (rev 281903)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/_WKSessionStateInternal.h	2021-09-02 01:05:35 UTC (rev 281904)
@@ -32,6 +32,7 @@
     WebKit::SessionState _sessionState;
 }
 
+- (WebKit::SessionState)_sessionStateWithAppInitiatedValue;
 - (instancetype)_initWithSessionState:(WebKit::SessionState)sessionState;
 
 @end

Modified: branches/safari-612-branch/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp (281903 => 281904)


--- branches/safari-612-branch/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp	2021-09-02 01:05:29 UTC (rev 281903)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp	2021-09-02 01:05:35 UTC (rev 281904)
@@ -199,7 +199,7 @@
         websitePoliciesData = websitePolicies->data();
     
     send(Messages::WebPage::UpdateBackForwardListForReattach(WTFMove(itemStates)));
-    send(Messages::WebPage::GoToBackForwardItem(navigation.navigationID(), item.itemID(), *navigation.backForwardFrameLoadType(), WebCore::ShouldTreatAsContinuingLoad::Yes, WTFMove(websitePoliciesData)));
+    send(Messages::WebPage::GoToBackForwardItem(navigation.navigationID(), item.itemID(), *navigation.backForwardFrameLoadType(), WebCore::ShouldTreatAsContinuingLoad::Yes, WTFMove(websitePoliciesData), m_page.lastNavigationWasAppInitiated()));
     m_process->startResponsivenessTimer();
 }
 

Modified: branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.cpp (281903 => 281904)


--- branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-09-02 01:05:29 UTC (rev 281903)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-09-02 01:05:35 UTC (rev 281904)
@@ -1084,7 +1084,7 @@
     }
 
     // We allow stale content when reloading a WebProcess that's been killed or crashed.
-    send(Messages::WebPage::GoToBackForwardItem(navigation->navigationID(), m_backForwardList->currentItem()->itemID(), FrameLoadType::IndexedBackForward, ShouldTreatAsContinuingLoad::No, std::nullopt));
+    send(Messages::WebPage::GoToBackForwardItem(navigation->navigationID(), m_backForwardList->currentItem()->itemID(), FrameLoadType::IndexedBackForward, ShouldTreatAsContinuingLoad::No, std::nullopt, m_lastNavigationWasAppInitiated));
     m_process->startResponsivenessTimer();
 
     return navigation;
@@ -1814,7 +1814,7 @@
     auto transaction = m_pageLoadState.transaction();
     m_pageLoadState.setPendingAPIRequest(transaction, { navigation ? navigation->navigationID() : 0, item.url() });
 
-    send(Messages::WebPage::GoToBackForwardItem(navigation ? navigation->navigationID() : 0, item.itemID(), frameLoadType, ShouldTreatAsContinuingLoad::No, std::nullopt));
+    send(Messages::WebPage::GoToBackForwardItem(navigation ? navigation->navigationID() : 0, item.itemID(), frameLoadType, ShouldTreatAsContinuingLoad::No, std::nullopt, m_lastNavigationWasAppInitiated));
     m_process->startResponsivenessTimer();
 
     return navigation;
@@ -3818,6 +3818,7 @@
 {
     WEBPAGEPROXY_RELEASE_LOG(Loading, "restoreFromSessionState:");
 
+    m_lastNavigationWasAppInitiated = sessionState.isAppInitiated;
     m_sessionRestorationRenderTreeSize = 0;
     m_hitRenderTreeSizeThreshold = false;
 

Modified: branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.h (281903 => 281904)


--- branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.h	2021-09-02 01:05:29 UTC (rev 281903)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.h	2021-09-02 01:05:35 UTC (rev 281904)
@@ -1946,6 +1946,8 @@
     void createMediaSessionCoordinator(Ref<MediaSessionCoordinatorProxyPrivate>&&, CompletionHandler<void(bool)>&&);
 #endif
 
+    bool lastNavigationWasAppInitiated() const { return m_lastNavigationWasAppInitiated; }
+
 #if PLATFORM(COCOA)
     void setLastNavigationWasAppInitiated(WebCore::ResourceRequest&);
     void lastNavigationWasAppInitiated(CompletionHandler<void(bool)>&&);

Modified: branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp (281903 => 281904)


--- branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2021-09-02 01:05:29 UTC (rev 281903)
+++ branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2021-09-02 01:05:35 UTC (rev 281904)
@@ -1857,10 +1857,12 @@
     }
 }
 
-void WebPage::goToBackForwardItem(uint64_t navigationID, const BackForwardItemIdentifier& backForwardItemID, FrameLoadType backForwardType, ShouldTreatAsContinuingLoad shouldTreatAsContinuingLoad, std::optional<WebsitePoliciesData>&& websitePolicies)
+void WebPage::goToBackForwardItem(uint64_t navigationID, const BackForwardItemIdentifier& backForwardItemID, FrameLoadType backForwardType, ShouldTreatAsContinuingLoad shouldTreatAsContinuingLoad, std::optional<WebsitePoliciesData>&& websitePolicies, bool lastNavigationWasAppInitiated)
 {
     SendStopResponsivenessTimer stopper;
 
+    m_lastNavigationWasAppInitiated = lastNavigationWasAppInitiated;
+
     ASSERT(isBackForwardLoadType(backForwardType));
 
     HistoryItem* item = WebBackForwardListProxy::itemForID(backForwardItemID);

Modified: branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/WebPage.h (281903 => 281904)


--- branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/WebPage.h	2021-09-02 01:05:29 UTC (rev 281903)
+++ branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/WebPage.h	2021-09-02 01:05:35 UTC (rev 281904)
@@ -1585,7 +1585,7 @@
     void navigateToPDFLinkWithSimulatedClick(const String& url, WebCore::IntPoint documentPoint, WebCore::IntPoint screenPoint);
     void getPDFFirstPageSize(WebCore::FrameIdentifier, CompletionHandler<void(WebCore::FloatSize)>&&);
     void reload(uint64_t navigationID, uint32_t reloadOptions, SandboxExtension::Handle&&);
-    void goToBackForwardItem(uint64_t navigationID, const WebCore::BackForwardItemIdentifier&, WebCore::FrameLoadType, WebCore::ShouldTreatAsContinuingLoad, std::optional<WebsitePoliciesData>&&);
+    void goToBackForwardItem(uint64_t navigationID, const WebCore::BackForwardItemIdentifier&, WebCore::FrameLoadType, WebCore::ShouldTreatAsContinuingLoad, std::optional<WebsitePoliciesData>&&, bool lastNavigationWasAppInitiated);
     void tryRestoreScrollPosition();
     void setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent&, CompletionHandler<void()>&&);
     void updateIsInWindow(bool isInitialState = false);

Modified: branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (281903 => 281904)


--- branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2021-09-02 01:05:29 UTC (rev 281903)
+++ branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2021-09-02 01:05:35 UTC (rev 281904)
@@ -167,7 +167,7 @@
     ScrollBy(uint32_t scrollDirection, uint32_t scrollGranularity)
     CenterSelectionInVisibleArea()
 
-    GoToBackForwardItem(uint64_t navigationID, struct WebCore::BackForwardItemIdentifier backForwardItemID, enum:uint8_t WebCore::FrameLoadType backForwardType, enum:bool WebCore::ShouldTreatAsContinuingLoad shouldTreatAsContinuingLoad, std::optional<WebKit::WebsitePoliciesData> websitePolicies)
+    GoToBackForwardItem(uint64_t navigationID, struct WebCore::BackForwardItemIdentifier backForwardItemID, enum:uint8_t WebCore::FrameLoadType backForwardType, enum:bool WebCore::ShouldTreatAsContinuingLoad shouldTreatAsContinuingLoad, std::optional<WebKit::WebsitePoliciesData> websitePolicies, bool lastNavigationWasAppInitiated)
     TryRestoreScrollPosition()
 
     LoadURLInFrame(URL url, String referrer, WebCore::FrameIdentifier frameID)

Modified: branches/safari-612-branch/Tools/ChangeLog (281903 => 281904)


--- branches/safari-612-branch/Tools/ChangeLog	2021-09-02 01:05:29 UTC (rev 281903)
+++ branches/safari-612-branch/Tools/ChangeLog	2021-09-02 01:05:35 UTC (rev 281904)
@@ -1,5 +1,64 @@
 2021-09-01  Russell Epstein  <[email protected]>
 
+        Cherry-pick r281817. rdar://problem/82652467
+
+    Loads after session restore marked app initiated in Safari
+    https://bugs.webkit.org/show_bug.cgi?id=229721
+    <rdar://problem/82084236>
+    
+    Reviewed by Brent Fulgham.
+    
+    Source/WebCore:
+    
+    * loader/FrameLoader.cpp:
+    (WebCore::FrameLoader::loadDifferentDocumentItem):
+    Set the proper app initiated value when creating a new request.
+    
+    Source/WebKit:
+    
+    Offer a way to set the app initiated value when restoring a session.
+    
+    * Shared/SessionState.h:
+    * UIProcess/API/Cocoa/WKWebView.mm:
+    (-[WKWebView _restoreSessionState:andNavigate:]):
+    * UIProcess/API/Cocoa/_WKSessionState.h:
+    * UIProcess/API/Cocoa/_WKSessionState.mm:
+    (-[_WKSessionState _sessionStateWithAppInitiatedValue]):
+    * UIProcess/API/Cocoa/_WKSessionStateInternal.h:
+    * UIProcess/ProvisionalPageProxy.cpp:
+    (WebKit::ProvisionalPageProxy::goToBackForwardItem):
+    * UIProcess/WebPageProxy.cpp:
+    (WebKit::WebPageProxy::launchProcessForReload):
+    (WebKit::WebPageProxy::goToBackForwardItem):
+    (WebKit::WebPageProxy::restoreFromSessionState):
+    * UIProcess/WebPageProxy.h:
+    * WebProcess/WebPage/WebPage.cpp:
+    (WebKit::WebPage::goToBackForwardItem):
+    * WebProcess/WebPage/WebPage.h:
+    * WebProcess/WebPage/WebPage.messages.in:
+    
+    Tools:
+    
+    API test coverage.
+    
+    * TestWebKitAPI/Tests/WebKitCocoa/AppPrivacyReport.mm:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281817 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-08-31  Kate Cheney  <[email protected]>
+
+            Loads after session restore marked app initiated in Safari
+            https://bugs.webkit.org/show_bug.cgi?id=229721
+            <rdar://problem/82084236>
+
+            Reviewed by Brent Fulgham.
+
+            API test coverage.
+
+            * TestWebKitAPI/Tests/WebKitCocoa/AppPrivacyReport.mm:
+
+2021-09-01  Russell Epstein  <[email protected]>
+
         Cherry-pick r281684. rdar://problem/82651474
 
     [JSC] op_put_private_name should use modern IC and remove ByValInfo

Modified: branches/safari-612-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/AppPrivacyReport.mm (281903 => 281904)


--- branches/safari-612-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/AppPrivacyReport.mm	2021-09-02 01:05:29 UTC (rev 281903)
+++ branches/safari-612-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/AppPrivacyReport.mm	2021-09-02 01:05:35 UTC (rev 281904)
@@ -36,6 +36,7 @@
 #import <WebKit/WKPreferencesPrivate.h>
 #import <WebKit/WKWebViewPrivateForTesting.h>
 #import <WebKit/WKWebsiteDataStorePrivate.h>
+#import <WebKit/_WKSessionState.h>
 #import <pal/spi/cf/CFNetworkSPI.h>
 #import <wtf/RunLoop.h>
 #import <wtf/text/WTFString.h>
@@ -733,4 +734,45 @@
     loadSimulatedRequestTest(IsAppInitiated::No);
 }
 
+static void restoreFromSessionStateTest(IsAppInitiated isAppInitiated)
+{
+    auto webView1 = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
+
+    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://www.apple.com/"]];
+    request.attribution = isAppInitiated == IsAppInitiated::Yes ? NSURLRequestAttributionDeveloper : NSURLRequestAttributionUser;
+
+    [webView1 loadRequest:request];
+    [webView1 _test_waitForDidFinishNavigation];
+
+    RetainPtr<_WKSessionState> sessionState = [webView1 _sessionState];
+    sessionState.get().isAppInitiated = isAppInitiated == IsAppInitiated::Yes ? true : false;
+    webView1 = nullptr;
+
+    auto webView2 = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+
+    [webView2 _restoreSessionState:sessionState.get() andNavigate:YES];
+    [webView2 _test_waitForDidFinishNavigation];
+
+    EXPECT_WK_STREQ(@"https://www.apple.com/", [[webView2 URL] absoluteString]);
+
+    static bool isDone = false;
+    bool expectingAppInitiatedRequests = isAppInitiated == IsAppInitiated::Yes ? true : false;
+    [webView2 _appPrivacyReportTestingData:^(struct WKAppPrivacyReportTestingData data) {
+        EXPECT_EQ(data.hasLoadedAppInitiatedRequestTesting, expectingAppInitiatedRequests);
+        EXPECT_EQ(data.hasLoadedNonAppInitiatedRequestTesting, !expectingAppInitiatedRequests);
+        isDone = true;
+    }];
+    TestWebKitAPI::Util::run(&isDone);
+}
+
+TEST(AppPrivacyReport, RestoreFromSessionStateIsAppInitiated)
+{
+    restoreFromSessionStateTest(IsAppInitiated::Yes);
+}
+
+TEST(AppPrivacyReport, RestoreFromSessionStateIsNonAppInitiated)
+{
+    restoreFromSessionStateTest(IsAppInitiated::No);
+}
+
 #endif // APP_PRIVACY_REPORT
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to