Title: [285467] branches/safari-612-branch
Revision
285467
Author
[email protected]
Date
2021-11-08 17:09:20 -0800 (Mon, 08 Nov 2021)

Log Message

Cherry-pick r285208. rdar://problem/84824703

    [iOS] Need API for marking file requests as non-app-initiated
    https://bugs.webkit.org/show_bug.cgi?id=232506
    <rdar://problem/84824703>

    Reviewed by Brent Fulgham.

    Source/WebKit:

    Pass app initiated value through to the WebPage so file loads
    can be attributed correctly.

    * UIProcess/API/Cocoa/WKWebView.mm:
    (-[WKWebView loadFileRequest:allowingReadAccessToURL:]):
    * UIProcess/WebPageProxy.cpp:
    (WebKit::WebPageProxy::loadFile):
    * UIProcess/WebPageProxy.h:

    Tools:

    * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
    * TestWebKitAPI/Tests/WebKitCocoa/AppPrivacyReport.mm:
    * TestWebKitAPI/Tests/WebKitCocoa/file-with-iframe.html: Added.

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

Modified Paths

Added Paths

Diff

Modified: branches/safari-612-branch/Source/WebKit/ChangeLog (285466 => 285467)


--- branches/safari-612-branch/Source/WebKit/ChangeLog	2021-11-09 01:09:17 UTC (rev 285466)
+++ branches/safari-612-branch/Source/WebKit/ChangeLog	2021-11-09 01:09:20 UTC (rev 285467)
@@ -1,5 +1,52 @@
 2021-11-08  Kocsen Chung  <[email protected]>
 
+        Cherry-pick r285208. rdar://problem/84824703
+
+    [iOS] Need API for marking file requests as non-app-initiated
+    https://bugs.webkit.org/show_bug.cgi?id=232506
+    <rdar://problem/84824703>
+    
+    Reviewed by Brent Fulgham.
+    
+    Source/WebKit:
+    
+    Pass app initiated value through to the WebPage so file loads
+    can be attributed correctly.
+    
+    * UIProcess/API/Cocoa/WKWebView.mm:
+    (-[WKWebView loadFileRequest:allowingReadAccessToURL:]):
+    * UIProcess/WebPageProxy.cpp:
+    (WebKit::WebPageProxy::loadFile):
+    * UIProcess/WebPageProxy.h:
+    
+    Tools:
+    
+    * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+    * TestWebKitAPI/Tests/WebKitCocoa/AppPrivacyReport.mm:
+    * TestWebKitAPI/Tests/WebKitCocoa/file-with-iframe.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@285208 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-11-03  Kate Cheney  <[email protected]>
+
+            [iOS] Need API for marking file requests as non-app-initiated
+            https://bugs.webkit.org/show_bug.cgi?id=232506
+            <rdar://problem/84824703>
+
+            Reviewed by Brent Fulgham.
+
+            Pass app initiated value through to the WebPage so file loads
+            can be attributed correctly.
+
+            * UIProcess/API/Cocoa/WKWebView.mm:
+            (-[WKWebView loadFileRequest:allowingReadAccessToURL:]):
+            * UIProcess/WebPageProxy.cpp:
+            (WebKit::WebPageProxy::loadFile):
+            * UIProcess/WebPageProxy.h:
+
+2021-11-08  Kocsen Chung  <[email protected]>
+
         Cherry-pick r285179. rdar://problem/84919898
 
     Crash under WebPage::sendCOEPCORPViolation()

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


--- branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2021-11-09 01:09:17 UTC (rev 285466)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2021-11-09 01:09:20 UTC (rev 285467)
@@ -1763,7 +1763,12 @@
     if (![readAccessURL isFileURL])
         [NSException raise:NSInvalidArgumentException format:@"%@ is not a file URL", readAccessURL];
 
-    return wrapper(_page->loadFile(URL.absoluteString, readAccessURL.absoluteString));
+    bool isAppInitiated = true;
+#if ENABLE(APP_PRIVACY_REPORT)
+    isAppInitiated = request.attribution == NSURLRequestAttributionDeveloper;
+#endif
+
+    return wrapper(_page->loadFile(URL.absoluteString, readAccessURL.absoluteString, isAppInitiated));
 }
 
 - (CocoaColor *)themeColor

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


--- branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-11-09 01:09:17 UTC (rev 285466)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-11-09 01:09:20 UTC (rev 285467)
@@ -1422,7 +1422,7 @@
     process->startResponsivenessTimer();
 }
 
-RefPtr<API::Navigation> WebPageProxy::loadFile(const String& fileURLString, const String& resourceDirectoryURLString, API::Object* userData)
+RefPtr<API::Navigation> WebPageProxy::loadFile(const String& fileURLString, const String& resourceDirectoryURLString, bool isAppInitiated, API::Object* userData)
 {
     WEBPAGEPROXY_RELEASE_LOG(Loading, "loadFile:");
 
@@ -1467,9 +1467,13 @@
 
     m_pageLoadState.setPendingAPIRequest(transaction, { navigation->navigationID(), fileURLString }, resourceDirectoryURL);
 
+    auto request = ResourceRequest(fileURL);
+    request.setIsAppInitiated(isAppInitiated);
+    m_lastNavigationWasAppInitiated = isAppInitiated;
+
     LoadParameters loadParameters;
     loadParameters.navigationID = navigation->navigationID();
-    loadParameters.request = fileURL;
+    loadParameters.request = WTFMove(request);
     loadParameters.shouldOpenExternalURLsPolicy = ShouldOpenExternalURLsPolicy::ShouldNotAllow;
     loadParameters.userData = UserData(process().transformObjectsToHandles(userData).get());
     const bool checkAssumedReadAccessToResourceURL = false;

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


--- branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.h	2021-11-09 01:09:17 UTC (rev 285466)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.h	2021-11-09 01:09:20 UTC (rev 285467)
@@ -640,7 +640,7 @@
 
     void addPlatformLoadParameters(WebProcessProxy&, LoadParameters&);
     RefPtr<API::Navigation> loadRequest(WebCore::ResourceRequest&&, WebCore::ShouldOpenExternalURLsPolicy = WebCore::ShouldOpenExternalURLsPolicy::ShouldAllowExternalSchemesButNotAppLinks, API::Object* userData = nullptr);
-    RefPtr<API::Navigation> loadFile(const String& fileURL, const String& resourceDirectoryURL, API::Object* userData = nullptr);
+    RefPtr<API::Navigation> loadFile(const String& fileURL, const String& resourceDirectoryURL, bool isAppInitiated = true, API::Object* userData = nullptr);
     RefPtr<API::Navigation> loadData(const IPC::DataReference&, const String& MIMEType, const String& encoding, const String& baseURL, API::Object* userData = nullptr, WebCore::ShouldOpenExternalURLsPolicy = WebCore::ShouldOpenExternalURLsPolicy::ShouldNotAllow);
     RefPtr<API::Navigation> loadSimulatedRequest(WebCore::ResourceRequest&&, WebCore::ResourceResponse&&, const IPC::DataReference&);
     void loadAlternateHTML(const IPC::DataReference&, const String& encoding, const URL& baseURL, const URL& unreachableURL, API::Object* userData = nullptr);

Modified: branches/safari-612-branch/Tools/ChangeLog (285466 => 285467)


--- branches/safari-612-branch/Tools/ChangeLog	2021-11-09 01:09:17 UTC (rev 285466)
+++ branches/safari-612-branch/Tools/ChangeLog	2021-11-09 01:09:20 UTC (rev 285467)
@@ -1,5 +1,47 @@
 2021-11-08  Kocsen Chung  <[email protected]>
 
+        Cherry-pick r285208. rdar://problem/84824703
+
+    [iOS] Need API for marking file requests as non-app-initiated
+    https://bugs.webkit.org/show_bug.cgi?id=232506
+    <rdar://problem/84824703>
+    
+    Reviewed by Brent Fulgham.
+    
+    Source/WebKit:
+    
+    Pass app initiated value through to the WebPage so file loads
+    can be attributed correctly.
+    
+    * UIProcess/API/Cocoa/WKWebView.mm:
+    (-[WKWebView loadFileRequest:allowingReadAccessToURL:]):
+    * UIProcess/WebPageProxy.cpp:
+    (WebKit::WebPageProxy::loadFile):
+    * UIProcess/WebPageProxy.h:
+    
+    Tools:
+    
+    * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+    * TestWebKitAPI/Tests/WebKitCocoa/AppPrivacyReport.mm:
+    * TestWebKitAPI/Tests/WebKitCocoa/file-with-iframe.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@285208 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-11-03  Kate Cheney  <[email protected]>
+
+            [iOS] Need API for marking file requests as non-app-initiated
+            https://bugs.webkit.org/show_bug.cgi?id=232506
+            <rdar://problem/84824703>
+
+            Reviewed by Brent Fulgham.
+
+            * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+            * TestWebKitAPI/Tests/WebKitCocoa/AppPrivacyReport.mm:
+            * TestWebKitAPI/Tests/WebKitCocoa/file-with-iframe.html: Added.
+
+2021-11-08  Kocsen Chung  <[email protected]>
+
         Cherry-pick r283180. rdar://problem/85168105
 
     Validate DeviceIdHashSaltStorage persistent data

Modified: branches/safari-612-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (285466 => 285467)


--- branches/safari-612-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2021-11-09 01:09:17 UTC (rev 285466)
+++ branches/safari-612-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2021-11-09 01:09:20 UTC (rev 285467)
@@ -314,6 +314,7 @@
 		498D030A26376B34009CBFAD /* resourceLoadStatisticsMissingUniqueIndex.db in Copy Resources */ = {isa = PBXBuildFile; fileRef = 498D030926376B2C009CBFAD /* resourceLoadStatisticsMissingUniqueIndex.db */; };
 		4995A6F025E8772000E5F0A9 /* csp-document-uri-report.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 4995A6EF25E876A300E5F0A9 /* csp-document-uri-report.html */; };
 		49AEEF6D2407359D00C87E4C /* InAppBrowserPrivacy.mm in Sources */ = {isa = PBXBuildFile; fileRef = 49AEEF6B2407358600C87E4C /* InAppBrowserPrivacy.mm */; };
+		49D2E5C22731E3BC00BCCAED /* file-with-iframe.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 49D2E5C12731E37400BCCAED /* file-with-iframe.html */; };
 		49EF6AD52677C0BE007967DC /* AppPrivacyReport.mm in Sources */ = {isa = PBXBuildFile; fileRef = 49EF6AD42677C0BE007967DC /* AppPrivacyReport.mm */; };
 		4BFDFFA71314776C0061F24B /* HitTestResultNodeHandle_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BFDFFA61314776C0061F24B /* HitTestResultNodeHandle_Bundle.cpp */; };
 		510477721D298DDD009747EB /* IDBDeleteRecovery.sqlite3 in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5104776F1D298D85009747EB /* IDBDeleteRecovery.sqlite3 */; };
@@ -1370,6 +1371,7 @@
 			dstPath = TestWebKitAPI.resources;
 			dstSubfolderSpec = 7;
 			files = (
+				49D2E5C22731E3BC00BCCAED /* file-with-iframe.html in Copy Resources */,
 				55A817FF2181021A0004A39A /* 100x100-red.tga in Copy Resources */,
 				1A9E52C913E65EF4006917F5 /* 18-characters.html in Copy Resources */,
 				55A81800218102210004A39A /* 400x400-green.png in Copy Resources */,
@@ -2143,6 +2145,7 @@
 		4995A6EF25E876A300E5F0A9 /* csp-document-uri-report.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "csp-document-uri-report.html"; sourceTree = "<group>"; };
 		49AEEF682407276F00C87E4C /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
 		49AEEF6B2407358600C87E4C /* InAppBrowserPrivacy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = InAppBrowserPrivacy.mm; sourceTree = "<group>"; };
+		49D2E5C12731E37400BCCAED /* file-with-iframe.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "file-with-iframe.html"; sourceTree = "<group>"; };
 		49D7FBA7241FDDDA00AB67FA /* in-app-browser-privacy-local-file.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "in-app-browser-privacy-local-file.html"; sourceTree = "<group>"; };
 		49EF6AD42677C0BE007967DC /* AppPrivacyReport.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AppPrivacyReport.mm; sourceTree = "<group>"; };
 		4A410F4B19AF7BD6002EBAB5 /* UserMedia.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserMedia.cpp; sourceTree = "<group>"; };
@@ -4227,6 +4230,7 @@
 				51714EB31CF8C761004723C4 /* WebProcessKillIDBCleanup-2.html */,
 				5120C83B1E674E350025B250 /* WebsiteDataStoreCustomPaths.html */,
 				2E131C171D83A97E001BA36C /* wide-autoplaying-video-with-audio.html */,
+				49D2E5C12731E37400BCCAED /* file-with-iframe.html */,
 			);
 			name = Resources;
 			sourceTree = "<group>";

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


--- branches/safari-612-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/AppPrivacyReport.mm	2021-11-09 01:09:17 UTC (rev 285466)
+++ branches/safari-612-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/AppPrivacyReport.mm	2021-11-09 01:09:20 UTC (rev 285467)
@@ -825,4 +825,35 @@
     restoreFromInteractionStateTest(IsAppInitiated::No);
 }
 
+static void loadFileTest(IsAppInitiated isAppInitiated)
+{
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
+
+    NSURL *file = [[NSBundle mainBundle] URLForResource:@"file-with-iframe" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
+    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:file];
+    request.attribution = isAppInitiated == IsAppInitiated::Yes ? NSURLRequestAttributionDeveloper : NSURLRequestAttributionUser;
+
+    [webView loadFileRequest:request allowingReadAccessToURL:file.URLByDeletingLastPathComponent];
+    [webView _test_waitForDidFinishNavigation];
+
+    static bool isDone = false;
+    bool expectingAppInitiatedRequests = isAppInitiated == IsAppInitiated::Yes ? true : false;
+    [webView _appPrivacyReportTestingData:^(struct WKAppPrivacyReportTestingData data) {
+        EXPECT_EQ(data.hasLoadedAppInitiatedRequestTesting, expectingAppInitiatedRequests);
+        EXPECT_EQ(data.hasLoadedNonAppInitiatedRequestTesting, !expectingAppInitiatedRequests);
+        isDone = true;
+    }];
+    TestWebKitAPI::Util::run(&isDone);
+}
+
+TEST(AppPrivacyReport, LoadFileRequestIsAppInitiated)
+{
+    loadFileTest(IsAppInitiated::Yes);
+}
+
+TEST(AppPrivacyReport, LoadFileRequestIsNonAppInitiated)
+{
+    loadFileTest(IsAppInitiated::No);
+}
+
 #endif // APP_PRIVACY_REPORT

Added: branches/safari-612-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/file-with-iframe.html (0 => 285467)


--- branches/safari-612-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/file-with-iframe.html	                        (rev 0)
+++ branches/safari-612-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/file-with-iframe.html	2021-11-09 01:09:20 UTC (rev 285467)
@@ -0,0 +1,5 @@
+<html>
+<body>
+  <iframe src=""
+</body>
+</html>
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to