Title: [290918] branches/safari-613-branch
Revision
290918
Author
[email protected]
Date
2022-03-07 14:09:04 -0800 (Mon, 07 Mar 2022)

Log Message

Cherry-pick r289121. rdar://problem/88492251

    Fix App Privacy Report redirect attribution
    https://bugs.webkit.org/show_bug.cgi?id=236111

    Reviewed by Brent Fulgham.

    Source/WebCore:

    Test: http/tests/app-privacy-report/user-attribution-redirect.html
    Test: http/tests/app-privacy-report/app-attribution-redirect.html

    * platform/network/cf/ResourceRequestCFNet.cpp:
    (WebCore::ResourceRequest::updateFromDelegatePreservingOldProperties):

    Source/WebKit:

    * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
    (-[WKNetworkSessionDelegate URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:]):

    LayoutTests:

    * http/tests/app-privacy-report/resources/redirect.js: Added.
    * http/tests/app-privacy-report/app-attribution-redirect-expected.txt: Added.
    * http/tests/app-privacy-report/app-attribution-redirect.html: Added.
    * http/tests/app-privacy-report/user-attribution-redirect-expected.txt: Added.
    * http/tests/app-privacy-report/user-attribution-redirect.html: Added.

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

Modified Paths

Added Paths

Diff

Modified: branches/safari-613-branch/LayoutTests/ChangeLog (290917 => 290918)


--- branches/safari-613-branch/LayoutTests/ChangeLog	2022-03-07 22:08:59 UTC (rev 290917)
+++ branches/safari-613-branch/LayoutTests/ChangeLog	2022-03-07 22:09:04 UTC (rev 290918)
@@ -1,5 +1,51 @@
 2022-03-07  Russell Epstein  <[email protected]>
 
+        Cherry-pick r289121. rdar://problem/88492251
+
+    Fix App Privacy Report redirect attribution
+    https://bugs.webkit.org/show_bug.cgi?id=236111
+    
+    Reviewed by Brent Fulgham.
+    
+    Source/WebCore:
+    
+    Test: http/tests/app-privacy-report/user-attribution-redirect.html
+    Test: http/tests/app-privacy-report/app-attribution-redirect.html
+    
+    * platform/network/cf/ResourceRequestCFNet.cpp:
+    (WebCore::ResourceRequest::updateFromDelegatePreservingOldProperties):
+    
+    Source/WebKit:
+    
+    * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+    (-[WKNetworkSessionDelegate URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:]):
+    
+    LayoutTests:
+    
+    * http/tests/app-privacy-report/resources/redirect.js: Added.
+    * http/tests/app-privacy-report/app-attribution-redirect-expected.txt: Added.
+    * http/tests/app-privacy-report/app-attribution-redirect.html: Added.
+    * http/tests/app-privacy-report/user-attribution-redirect-expected.txt: Added.
+    * http/tests/app-privacy-report/user-attribution-redirect.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@289121 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-02-04  Kate Cheney  <[email protected]>
+
+            Fix App Privacy Report redirect attribution
+            https://bugs.webkit.org/show_bug.cgi?id=236111
+
+            Reviewed by Brent Fulgham.
+
+            * http/tests/app-privacy-report/resources/redirect.js: Added.
+            * http/tests/app-privacy-report/app-attribution-redirect-expected.txt: Added.
+            * http/tests/app-privacy-report/app-attribution-redirect.html: Added.
+            * http/tests/app-privacy-report/user-attribution-redirect-expected.txt: Added.
+            * http/tests/app-privacy-report/user-attribution-redirect.html: Added.
+
+2022-03-07  Russell Epstein  <[email protected]>
+
         Cherry-pick r289101. rdar://problem/87625596
 
     Two bopomofo tone marks are not moved to the correct place in vertical text with a particular bopomofo font

Added: branches/safari-613-branch/LayoutTests/http/tests/app-privacy-report/app-attribution-redirect-expected.txt (0 => 290918)


--- branches/safari-613-branch/LayoutTests/http/tests/app-privacy-report/app-attribution-redirect-expected.txt	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/http/tests/app-privacy-report/app-attribution-redirect-expected.txt	2022-03-07 22:09:04 UTC (rev 290918)
@@ -0,0 +1,9 @@
+CONSOLE MESSAGE: Origin http://127.0.0.1:8000 is not allowed by Access-Control-Allow-Origin. Status code: 200
+CONSOLE MESSAGE: XMLHttpRequest cannot load http://localhost:8000/app-privacy-report/resources/redirect.js due to access control checks.
+Test that a cross-origin redirect to a server that responds is indistinguishable from one that does not. Should say PASS:
+
+PASS successfully loaded only app initiated requests
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: branches/safari-613-branch/LayoutTests/http/tests/app-privacy-report/app-attribution-redirect.html (0 => 290918)


--- branches/safari-613-branch/LayoutTests/http/tests/app-privacy-report/app-attribution-redirect.html	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/http/tests/app-privacy-report/app-attribution-redirect.html	2022-03-07 22:09:04 UTC (rev 290918)
@@ -0,0 +1,59 @@
+<!DOCTYPE html><!-- webkit-test-runner [ isAppInitiated=true ] -->
+<head>
+    <script src=""
+</head>
+<body>
+<p>Test that a cross-origin redirect to a server that responds is indistinguishable from one that does not. Should say PASS:</p>
+<pre id='console'></pre>
+<script type="text/_javascript_">
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+    }
+
+    function log(message)
+    {
+        document.getElementById('console').appendChild(document.createTextNode(message + "\n"));
+    }
+
+    if (window.testRunner)
+        testRunner.setAllowsAnySSLCertificate(true);
+
+    window.jsTestIsAsync = true;
+
+    function log(message)
+    {
+        document.getElementById('console').appendChild(document.createTextNode(message + '\n'));
+    }
+
+    function askForAttribution() {
+        var didLoadAppInitiatedRequest = testRunner.didLoadAppInitiatedRequest();
+        var didLoadNonAppInitiatedRequest = testRunner.didLoadNonAppInitiatedRequest();
+
+        if (didLoadNonAppInitiatedRequest) {
+            log("FAIL did load non app initiated request");
+            finishJSTest();
+            return;
+        }
+
+        if (!didLoadAppInitiatedRequest) {
+            log("FAIL did not load app initiated request");
+            finishJSTest();
+            return;
+        }
+
+        log("PASS successfully loaded only app initiated requests");
+
+        finishJSTest();
+    }
+
+    var xhr = new XMLHttpRequest;
+    xhr._onerror_ = function() { setTimeout(askForAttribution, 0); }
+    xhr.open("GET", "/resources/redirect.py?url="" true);
+    xhr.send();
+
+</script>
+<script src=""
+
+</body>
+</html>

Added: branches/safari-613-branch/LayoutTests/http/tests/app-privacy-report/resources/redirect.js (0 => 290918)


--- branches/safari-613-branch/LayoutTests/http/tests/app-privacy-report/resources/redirect.js	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/http/tests/app-privacy-report/resources/redirect.js	2022-03-07 22:09:04 UTC (rev 290918)
@@ -0,0 +1 @@
+console.log("FAIL");

Added: branches/safari-613-branch/LayoutTests/http/tests/app-privacy-report/user-attribution-redirect-expected.txt (0 => 290918)


--- branches/safari-613-branch/LayoutTests/http/tests/app-privacy-report/user-attribution-redirect-expected.txt	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/http/tests/app-privacy-report/user-attribution-redirect-expected.txt	2022-03-07 22:09:04 UTC (rev 290918)
@@ -0,0 +1,9 @@
+CONSOLE MESSAGE: Origin http://127.0.0.1:8000 is not allowed by Access-Control-Allow-Origin. Status code: 200
+CONSOLE MESSAGE: XMLHttpRequest cannot load http://localhost:8000/app-privacy-report/resources/redirect.js due to access control checks.
+Test that a cross-origin redirect to a server that responds is indistinguishable from one that does not. Should say PASS:
+
+PASS successfully loaded only non app initiated requests
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: branches/safari-613-branch/LayoutTests/http/tests/app-privacy-report/user-attribution-redirect.html (0 => 290918)


--- branches/safari-613-branch/LayoutTests/http/tests/app-privacy-report/user-attribution-redirect.html	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/http/tests/app-privacy-report/user-attribution-redirect.html	2022-03-07 22:09:04 UTC (rev 290918)
@@ -0,0 +1,59 @@
+<!DOCTYPE html><!-- webkit-test-runner [ isAppInitiated=false ] -->
+<head>
+    <script src=""
+</head>
+<body>
+<p>Test that a cross-origin redirect to a server that responds is indistinguishable from one that does not. Should say PASS:</p>
+<pre id='console'></pre>
+<script type="text/_javascript_">
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+    }
+
+    function log(message)
+    {
+        document.getElementById('console').appendChild(document.createTextNode(message + "\n"));
+    }
+
+    if (window.testRunner)
+        testRunner.setAllowsAnySSLCertificate(true);
+
+    window.jsTestIsAsync = true;
+
+    function log(message)
+    {
+        document.getElementById('console').appendChild(document.createTextNode(message + '\n'));
+    }
+
+    function askForAttribution() {
+        var didLoadAppBoundRequest = testRunner.didLoadAppInitiatedRequest();
+        var didLoadNonAppBoundRequest = testRunner.didLoadNonAppInitiatedRequest();
+
+        if (didLoadAppBoundRequest) {
+            log("FAIL did load app initiated request");
+            finishJSTest();
+            return;
+        }
+
+        if (!didLoadNonAppBoundRequest) {
+            log("FAIL did not load non app initiated request");
+            finishJSTest();
+            return;
+        }
+
+        log("PASS successfully loaded only non app initiated requests");
+
+        finishJSTest();
+    }
+
+    var xhr = new XMLHttpRequest;
+    xhr._onerror_ = function() { setTimeout(askForAttribution, 0); }
+    xhr.open("GET", "/resources/redirect.py?url="" true);
+    xhr.send();
+
+</script>
+<script src=""
+
+</body>
+</html>

Modified: branches/safari-613-branch/Source/WebCore/ChangeLog (290917 => 290918)


--- branches/safari-613-branch/Source/WebCore/ChangeLog	2022-03-07 22:08:59 UTC (rev 290917)
+++ branches/safari-613-branch/Source/WebCore/ChangeLog	2022-03-07 22:09:04 UTC (rev 290918)
@@ -1,5 +1,51 @@
 2022-03-07  Russell Epstein  <[email protected]>
 
+        Cherry-pick r289121. rdar://problem/88492251
+
+    Fix App Privacy Report redirect attribution
+    https://bugs.webkit.org/show_bug.cgi?id=236111
+    
+    Reviewed by Brent Fulgham.
+    
+    Source/WebCore:
+    
+    Test: http/tests/app-privacy-report/user-attribution-redirect.html
+    Test: http/tests/app-privacy-report/app-attribution-redirect.html
+    
+    * platform/network/cf/ResourceRequestCFNet.cpp:
+    (WebCore::ResourceRequest::updateFromDelegatePreservingOldProperties):
+    
+    Source/WebKit:
+    
+    * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+    (-[WKNetworkSessionDelegate URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:]):
+    
+    LayoutTests:
+    
+    * http/tests/app-privacy-report/resources/redirect.js: Added.
+    * http/tests/app-privacy-report/app-attribution-redirect-expected.txt: Added.
+    * http/tests/app-privacy-report/app-attribution-redirect.html: Added.
+    * http/tests/app-privacy-report/user-attribution-redirect-expected.txt: Added.
+    * http/tests/app-privacy-report/user-attribution-redirect.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@289121 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-02-04  Kate Cheney  <[email protected]>
+
+            Fix App Privacy Report redirect attribution
+            https://bugs.webkit.org/show_bug.cgi?id=236111
+
+            Reviewed by Brent Fulgham.
+
+            Test: http/tests/app-privacy-report/user-attribution-redirect.html
+            Test: http/tests/app-privacy-report/app-attribution-redirect.html
+
+            * platform/network/cf/ResourceRequestCFNet.cpp:
+            (WebCore::ResourceRequest::updateFromDelegatePreservingOldProperties):
+
+2022-03-07  Russell Epstein  <[email protected]>
+
         Cherry-pick r289101. rdar://problem/87625596
 
     Two bopomofo tone marks are not moved to the correct place in vertical text with a particular bopomofo font

Modified: branches/safari-613-branch/Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp (290917 => 290918)


--- branches/safari-613-branch/Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp	2022-03-07 22:08:59 UTC (rev 290917)
+++ branches/safari-613-branch/Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp	2022-03-07 22:09:04 UTC (rev 290918)
@@ -370,6 +370,7 @@
     auto oldRequester = requester();
     auto oldInitiatorIdentifier = initiatorIdentifier();
     auto oldInspectorInitiatorNodeIdentifier = inspectorInitiatorNodeIdentifier();
+    auto oldAppInitiatedValue = isAppInitiated();
 
     *this = delegateProvidedRequest;
 
@@ -380,6 +381,7 @@
     setInitiatorIdentifier(oldInitiatorIdentifier);
     if (oldInspectorInitiatorNodeIdentifier)
         setInspectorInitiatorNodeIdentifier(*oldInspectorInitiatorNodeIdentifier);
+    setIsAppInitiated(oldAppInitiatedValue);
 }
 
 bool ResourceRequest::httpPipeliningEnabled()

Modified: branches/safari-613-branch/Source/WebKit/ChangeLog (290917 => 290918)


--- branches/safari-613-branch/Source/WebKit/ChangeLog	2022-03-07 22:08:59 UTC (rev 290917)
+++ branches/safari-613-branch/Source/WebKit/ChangeLog	2022-03-07 22:09:04 UTC (rev 290918)
@@ -1,5 +1,48 @@
 2022-03-07  Russell Epstein  <[email protected]>
 
+        Cherry-pick r289121. rdar://problem/88492251
+
+    Fix App Privacy Report redirect attribution
+    https://bugs.webkit.org/show_bug.cgi?id=236111
+    
+    Reviewed by Brent Fulgham.
+    
+    Source/WebCore:
+    
+    Test: http/tests/app-privacy-report/user-attribution-redirect.html
+    Test: http/tests/app-privacy-report/app-attribution-redirect.html
+    
+    * platform/network/cf/ResourceRequestCFNet.cpp:
+    (WebCore::ResourceRequest::updateFromDelegatePreservingOldProperties):
+    
+    Source/WebKit:
+    
+    * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+    (-[WKNetworkSessionDelegate URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:]):
+    
+    LayoutTests:
+    
+    * http/tests/app-privacy-report/resources/redirect.js: Added.
+    * http/tests/app-privacy-report/app-attribution-redirect-expected.txt: Added.
+    * http/tests/app-privacy-report/app-attribution-redirect.html: Added.
+    * http/tests/app-privacy-report/user-attribution-redirect-expected.txt: Added.
+    * http/tests/app-privacy-report/user-attribution-redirect.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@289121 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-02-04  Kate Cheney  <[email protected]>
+
+            Fix App Privacy Report redirect attribution
+            https://bugs.webkit.org/show_bug.cgi?id=236111
+
+            Reviewed by Brent Fulgham.
+
+            * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+            (-[WKNetworkSessionDelegate URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:]):
+
+2022-03-07  Russell Epstein  <[email protected]>
+
         Cherry-pick r288237. rdar://problem/87275093
 
     WebKit::AuthenticatorPresenterCoordinator() constructor falls through ASSERT_NOT_REACHED()

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm (290917 => 290918)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2022-03-07 22:08:59 UTC (rev 290917)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2022-03-07 22:09:04 UTC (rev 290918)
@@ -596,12 +596,7 @@
         WebCore::ResourceResponse resourceResponse(response);
         networkDataTask->checkTAO(resourceResponse);
 
-        bool isAppInitiated = true;
-#if ENABLE(APP_PRIVACY_REPORT)
-        isAppInitiated = request.attribution == NSURLRequestAttributionDeveloper;
-#endif
-
-        networkDataTask->willPerformHTTPRedirection(WTFMove(resourceResponse), request, [session = networkDataTask->networkSession(), completionHandler = makeBlockPtr(completionHandler), taskIdentifier, shouldIgnoreHSTS, isAppInitiated](auto&& request) {
+        networkDataTask->willPerformHTTPRedirection(WTFMove(resourceResponse), request, [session = networkDataTask->networkSession(), completionHandler = makeBlockPtr(completionHandler), taskIdentifier, shouldIgnoreHSTS](auto&& request) {
 #if !LOG_DISABLED
             LOG(NetworkSession, "%llu willPerformHTTPRedirection completionHandler (%s)", taskIdentifier, request.url().string().utf8().data());
 #else
@@ -608,19 +603,6 @@
             UNUSED_PARAM(taskIdentifier);
 #endif
             auto nsRequest = retainPtr(request.nsURLRequest(WebCore::HTTPBodyUpdatePolicy::UpdateHTTPBody));
-
-#if ENABLE(APP_PRIVACY_REPORT)
-            if (session) {
-                RetainPtr<NSMutableURLRequest> mutableRequest = adoptNS([nsRequest mutableCopy]);
-                mutableRequest.get().attribution = isAppInitiated ? NSURLRequestAttributionDeveloper : NSURLRequestAttributionUser;
-                nsRequest = mutableRequest.get();
-
-                session->appPrivacyReportTestingData().didLoadAppInitiatedRequest(nsRequest.get().attribution == NSURLRequestAttributionDeveloper);
-            }
-#else
-            UNUSED_PARAM(isAppInitiated);
-            UNUSED_PARAM(session);
-#endif
             updateIgnoreStrictTransportSecuritySetting(nsRequest, shouldIgnoreHSTS);
             completionHandler(nsRequest.get());
         });
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to