Diff
Modified: branches/safari-612-branch/Source/WebKit/ChangeLog (285295 => 285296)
--- branches/safari-612-branch/Source/WebKit/ChangeLog 2021-11-04 19:40:01 UTC (rev 285295)
+++ branches/safari-612-branch/Source/WebKit/ChangeLog 2021-11-04 19:40:04 UTC (rev 285296)
@@ -1,5 +1,50 @@
2021-11-04 Russell Epstein <[email protected]>
+ Cherry-pick r285080. rdar://problem/84811692
+
+ [iOS 15] Loads after WKWebView session restore are marked as app-initiated
+ https://bugs.webkit.org/show_bug.cgi?id=232486
+ <rdar://problem/84811692>
+
+ Reviewed by Brent Fulgham.
+
+ Source/WebKit:
+
+ Return app initiated value in the page's SessionState so it can be restored
+ by third party apps using the [WKWebView setInteractionState] API.
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::sessionState const):
+ * UIProcess/mac/LegacySessionStateCoding.cpp:
+ (WebKit::encodeLegacySessionState):
+ (WebKit::decodeLegacySessionState):
+
+ Tools:
+
+ * TestWebKitAPI/Tests/WebKitCocoa/AppPrivacyReport.mm:
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@285080 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-10-30 Kate Cheney <[email protected]>
+
+ [iOS 15] Loads after WKWebView session restore are marked as app-initiated
+ https://bugs.webkit.org/show_bug.cgi?id=232486
+ <rdar://problem/84811692>
+
+ Reviewed by Brent Fulgham.
+
+ Return app initiated value in the page's SessionState so it can be restored
+ by third party apps using the [WKWebView setInteractionState] API.
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::sessionState const):
+ * UIProcess/mac/LegacySessionStateCoding.cpp:
+ (WebKit::encodeLegacySessionState):
+ (WebKit::decodeLegacySessionState):
+
+2021-11-04 Russell Epstein <[email protected]>
+
Cherry-pick r284924. rdar://problem/83455472
REGRESSION (iOS 15): Touch events are not fired during quick successive taps
Modified: branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.cpp (285295 => 285296)
--- branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-11-04 19:40:01 UTC (rev 285295)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-11-04 19:40:04 UTC (rev 285296)
@@ -3824,6 +3824,7 @@
sessionState.provisionalURL = URL(URL(), provisionalURLString);
sessionState.renderTreeSize = renderTreeSize();
+ sessionState.isAppInitiated = m_lastNavigationWasAppInitiated;
return sessionState;
}
Modified: branches/safari-612-branch/Source/WebKit/UIProcess/mac/LegacySessionStateCoding.cpp (285295 => 285296)
--- branches/safari-612-branch/Source/WebKit/UIProcess/mac/LegacySessionStateCoding.cpp 2021-11-04 19:40:01 UTC (rev 285295)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/mac/LegacySessionStateCoding.cpp 2021-11-04 19:40:04 UTC (rev 285296)
@@ -41,6 +41,7 @@
static const CFStringRef sessionHistoryKey = CFSTR("SessionHistory");
static const CFStringRef provisionalURLKey = CFSTR("ProvisionalURL");
static const CFStringRef renderTreeSizeKey = CFSTR("RenderTreeSize");
+static const CFStringRef isAppInitiatedKey = CFSTR("IsAppInitiated");
// Session history keys.
static const uint32_t sessionHistoryVersion = 1;
@@ -481,6 +482,7 @@
auto sessionHistoryDictionary = encodeSessionHistory(sessionState.backForwardListState);
auto provisionalURLString = sessionState.provisionalURL.isNull() ? nullptr : sessionState.provisionalURL.string().createCFString();
RetainPtr<CFNumberRef> renderTreeSizeNumber(adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &sessionState.renderTreeSize)));
+ RetainPtr<CFBooleanRef> isAppInitiated = adoptCF(sessionState.isAppInitiated ? kCFBooleanTrue : kCFBooleanFalse);
RetainPtr<CFDictionaryRef> stateDictionary;
if (provisionalURLString) {
@@ -487,12 +489,14 @@
stateDictionary = createDictionary({
{ sessionHistoryKey, sessionHistoryDictionary.get() },
{ provisionalURLKey, provisionalURLString.get() },
- { renderTreeSizeKey, renderTreeSizeNumber.get() }
+ { renderTreeSizeKey, renderTreeSizeNumber.get() },
+ { isAppInitiatedKey, isAppInitiated.get() }
});
} else {
stateDictionary = createDictionary({
{ sessionHistoryKey, sessionHistoryDictionary.get() },
- { renderTreeSizeKey, renderTreeSizeNumber.get() }
+ { renderTreeSizeKey, renderTreeSizeNumber.get() },
+ { isAppInitiatedKey, isAppInitiated.get() }
});
}
@@ -1152,6 +1156,11 @@
else
sessionState.renderTreeSize = 0;
+ if (auto isAppInitiated = dynamic_cf_cast<CFBooleanRef>(CFDictionaryGetValue(sessionStateDictionary, isAppInitiatedKey)))
+ sessionState.isAppInitiated = isAppInitiated == kCFBooleanTrue;
+ else
+ sessionState.isAppInitiated = true;
+
return true;
}
Modified: branches/safari-612-branch/Tools/ChangeLog (285295 => 285296)
--- branches/safari-612-branch/Tools/ChangeLog 2021-11-04 19:40:01 UTC (rev 285295)
+++ branches/safari-612-branch/Tools/ChangeLog 2021-11-04 19:40:04 UTC (rev 285296)
@@ -1,5 +1,43 @@
2021-11-04 Russell Epstein <[email protected]>
+ Cherry-pick r285080. rdar://problem/84811692
+
+ [iOS 15] Loads after WKWebView session restore are marked as app-initiated
+ https://bugs.webkit.org/show_bug.cgi?id=232486
+ <rdar://problem/84811692>
+
+ Reviewed by Brent Fulgham.
+
+ Source/WebKit:
+
+ Return app initiated value in the page's SessionState so it can be restored
+ by third party apps using the [WKWebView setInteractionState] API.
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::sessionState const):
+ * UIProcess/mac/LegacySessionStateCoding.cpp:
+ (WebKit::encodeLegacySessionState):
+ (WebKit::decodeLegacySessionState):
+
+ Tools:
+
+ * TestWebKitAPI/Tests/WebKitCocoa/AppPrivacyReport.mm:
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@285080 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-10-30 Kate Cheney <[email protected]>
+
+ [iOS 15] Loads after WKWebView session restore are marked as app-initiated
+ https://bugs.webkit.org/show_bug.cgi?id=232486
+ <rdar://problem/84811692>
+
+ Reviewed by Brent Fulgham.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/AppPrivacyReport.mm:
+
+2021-11-04 Russell Epstein <[email protected]>
+
Cherry-pick r284875. rdar://problem/84597422
[ App Privacy Report ] Restoring a session after clearing the cache results in app initiated loads in Safari
Modified: branches/safari-612-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/AppPrivacyReport.mm (285295 => 285296)
--- branches/safari-612-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/AppPrivacyReport.mm 2021-11-04 19:40:01 UTC (rev 285295)
+++ branches/safari-612-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/AppPrivacyReport.mm 2021-11-04 19:40:04 UTC (rev 285296)
@@ -780,4 +780,49 @@
restoreFromSessionStateTest(IsAppInitiated::No);
}
+static void restoreFromInteractionStateTest(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];
+
+ id interactionState = [webView1 interactionState];
+ [webView1 _close];
+
+ static bool isDone = false;
+ [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler:^() {
+ isDone = true;
+ }];
+ TestWebKitAPI::Util::run(&isDone);
+
+ auto webView2 = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+ [webView2 setInteractionState:interactionState];
+ [webView2 _test_waitForDidFinishNavigation];
+
+ EXPECT_WK_STREQ(@"https://www.apple.com/", [[webView2 URL] absoluteString]);
+
+ 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, RestoreFromInteractionStateIsAppInitiated)
+{
+ restoreFromInteractionStateTest(IsAppInitiated::Yes);
+}
+
+TEST(AppPrivacyReport, RestoreFromInteractionStateIsNonAppInitiated)
+{
+ restoreFromInteractionStateTest(IsAppInitiated::No);
+}
+
#endif // APP_PRIVACY_REPORT