Title: [279874] trunk
Revision
279874
Author
katherine_che...@apple.com
Date
2021-07-13 09:40:12 -0700 (Tue, 13 Jul 2021)

Log Message

Allow layout tests to specify app initiated loads or not
https://bugs.webkit.org/show_bug.cgi?id=227825
<rdar://problem/80355582>

Reviewed by Brent Fulgham.

Source/WebKit:

Tests: http/tests/app-privacy-report/app-attribution-load-url.html
       http/tests/app-privacy-report/app-attribution-ping-load.html
       http/tests/app-privacy-report/app-attribution-post-request.html
       http/tests/app-privacy-report/app-attribution-preflight-async.html
       http/tests/app-privacy-report/app-attribution-preflight-sync.html
       http/tests/app-privacy-report/app-attribution-speculative-revalidation.html
       http/tests/app-privacy-report/user-attribution-load-url.html
       http/tests/app-privacy-report/user-attribution-ping-load.html
       http/tests/app-privacy-report/user-attribution-post-request.html
       http/tests/app-privacy-report/user-attribution-preflight-async.html
       http/tests/app-privacy-report/user-attribution-preflight-sync.html
       http/tests/app-privacy-report/user-attribution-speculative-revalidation.html

Add a parameter to the WebView configuration that allows a test to
override the default NSURLRequest attribution value. We don't need
this to be dynamic per-test, so we can store it in the configuration.

* UIProcess/API/APIPageConfiguration.cpp:
(API::PageConfiguration::copy const):
* UIProcess/API/APIPageConfiguration.h:
(API::PageConfiguration::appInitiatedOverrideValueForTesting const):
(API::PageConfiguration::setAppInitiatedOverrideValueForTesting):
* UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(toWKAttributionOverrideTesting):
(toAttributionOverrideTesting):
(-[WKWebViewConfiguration _setAppInitiatedOverrideValueForTesting:]):
(-[WKWebViewConfiguration _appInitiatedOverrideValueForTesting]):
* UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
* UIProcess/Cocoa/WebPageProxyCocoa.mm:
(WebKit::WebPageProxy::setLastNavigationWasAppInitiated):

Tools:

Add a test option that specifies whether the test should mark the
main page navigation as app-initiated or not.

* WebKitTestRunner/TestOptions.cpp:
(WTR::TestOptions::defaults):
(WTR::TestOptions::keyTypeMapping):
* WebKitTestRunner/TestOptions.h:
(WTR::TestOptions::isAppInitiated const):
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::TestController::platformCreateWebView):

LayoutTests:

Added new tests to cover the user initiated case.

* http/tests/app-privacy-report/app-attribution-load-url-expected.txt: Renamed from LayoutTests/http/tests/app-privacy-report/attribution-load-url-expected.txt.
* http/tests/app-privacy-report/app-attribution-load-url.html: Copied from LayoutTests/http/tests/app-privacy-report/attribution-load-url.html.
* http/tests/app-privacy-report/app-attribution-ping-load-expected.txt: Copied from LayoutTests/http/tests/app-privacy-report/attribution-ping-load-expected.txt.
* http/tests/app-privacy-report/app-attribution-ping-load.html: Copied from LayoutTests/http/tests/app-privacy-report/attribution-ping-load.html.
* http/tests/app-privacy-report/app-attribution-post-request-expected.txt: Renamed from LayoutTests/http/tests/app-privacy-report/attribution-post-request-expected.txt.
* http/tests/app-privacy-report/app-attribution-post-request.html: Copied from LayoutTests/http/tests/app-privacy-report/attribution-post-request.html.
* http/tests/app-privacy-report/app-attribution-preflight-async-expected.txt: Copied from LayoutTests/http/tests/app-privacy-report/attribution-preflight-async-expected.txt.
* http/tests/app-privacy-report/app-attribution-preflight-async.html: Copied from LayoutTests/http/tests/app-privacy-report/attribution-preflight-async.html.
* http/tests/app-privacy-report/app-attribution-preflight-sync-expected.txt: Copied from LayoutTests/http/tests/app-privacy-report/attribution-preflight-sync-expected.txt.
* http/tests/app-privacy-report/app-attribution-preflight-sync.html: Copied from LayoutTests/http/tests/app-privacy-report/attribution-preflight-sync.html.
* http/tests/app-privacy-report/app-attribution-speculative-revalidation-expected.txt: Copied from LayoutTests/http/tests/app-privacy-report/attribution-speculative-revalidation-expected.txt.
* http/tests/app-privacy-report/app-attribution-speculative-revalidation.html: Copied from LayoutTests/http/tests/app-privacy-report/attribution-speculative-revalidation.html.
* http/tests/app-privacy-report/resources/app-initiated-post.py: Copied from LayoutTests/http/tests/app-privacy-report/resources/post.py.
* http/tests/app-privacy-report/resources/user-initiated-post.py: Renamed from LayoutTests/http/tests/app-privacy-report/resources/post.py.
* http/tests/app-privacy-report/user-attribution-load-url-expected.txt: Added.
* http/tests/app-privacy-report/user-attribution-load-url.html: Renamed from LayoutTests/http/tests/app-privacy-report/attribution-load-url.html.
* http/tests/app-privacy-report/user-attribution-ping-load-expected.txt: Renamed from LayoutTests/http/tests/app-privacy-report/attribution-ping-load-expected.txt.
* http/tests/app-privacy-report/user-attribution-ping-load.html: Renamed from LayoutTests/http/tests/app-privacy-report/attribution-ping-load.html.
* http/tests/app-privacy-report/user-attribution-post-request-expected.txt: Added.
* http/tests/app-privacy-report/user-attribution-post-request.html: Renamed from LayoutTests/http/tests/app-privacy-report/attribution-post-request.html.
* http/tests/app-privacy-report/user-attribution-preflight-async-expected.txt: Renamed from LayoutTests/http/tests/app-privacy-report/attribution-preflight-async-expected.txt.
* http/tests/app-privacy-report/user-attribution-preflight-async.html: Renamed from LayoutTests/http/tests/app-privacy-report/attribution-preflight-async.html.
* http/tests/app-privacy-report/user-attribution-preflight-sync-expected.txt: Renamed from LayoutTests/http/tests/app-privacy-report/attribution-preflight-sync-expected.txt.
* http/tests/app-privacy-report/user-attribution-preflight-sync.html: Renamed from LayoutTests/http/tests/app-privacy-report/attribution-preflight-sync.html.
* http/tests/app-privacy-report/user-attribution-speculative-revalidation-expected.txt: Renamed from LayoutTests/http/tests/app-privacy-report/attribution-speculative-revalidation-expected.txt.
* http/tests/app-privacy-report/user-attribution-speculative-revalidation.html: Renamed from LayoutTests/http/tests/app-privacy-report/attribution-speculative-revalidation.html.
* http/tests/navigation/resources/check-ping-user-initiated-data.py: Added.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (279873 => 279874)


--- trunk/LayoutTests/ChangeLog	2021-07-13 16:33:26 UTC (rev 279873)
+++ trunk/LayoutTests/ChangeLog	2021-07-13 16:40:12 UTC (rev 279874)
@@ -1,3 +1,41 @@
+2021-07-13  Kate Cheney  <katherine_che...@apple.com>
+
+        Allow layout tests to specify app initiated loads or not
+        https://bugs.webkit.org/show_bug.cgi?id=227825
+        <rdar://problem/80355582>
+
+        Reviewed by Brent Fulgham.
+
+        Added new tests to cover the user initiated case.
+
+        * http/tests/app-privacy-report/app-attribution-load-url-expected.txt: Renamed from LayoutTests/http/tests/app-privacy-report/attribution-load-url-expected.txt.
+        * http/tests/app-privacy-report/app-attribution-load-url.html: Copied from LayoutTests/http/tests/app-privacy-report/attribution-load-url.html.
+        * http/tests/app-privacy-report/app-attribution-ping-load-expected.txt: Copied from LayoutTests/http/tests/app-privacy-report/attribution-ping-load-expected.txt.
+        * http/tests/app-privacy-report/app-attribution-ping-load.html: Copied from LayoutTests/http/tests/app-privacy-report/attribution-ping-load.html.
+        * http/tests/app-privacy-report/app-attribution-post-request-expected.txt: Renamed from LayoutTests/http/tests/app-privacy-report/attribution-post-request-expected.txt.
+        * http/tests/app-privacy-report/app-attribution-post-request.html: Copied from LayoutTests/http/tests/app-privacy-report/attribution-post-request.html.
+        * http/tests/app-privacy-report/app-attribution-preflight-async-expected.txt: Copied from LayoutTests/http/tests/app-privacy-report/attribution-preflight-async-expected.txt.
+        * http/tests/app-privacy-report/app-attribution-preflight-async.html: Copied from LayoutTests/http/tests/app-privacy-report/attribution-preflight-async.html.
+        * http/tests/app-privacy-report/app-attribution-preflight-sync-expected.txt: Copied from LayoutTests/http/tests/app-privacy-report/attribution-preflight-sync-expected.txt.
+        * http/tests/app-privacy-report/app-attribution-preflight-sync.html: Copied from LayoutTests/http/tests/app-privacy-report/attribution-preflight-sync.html.
+        * http/tests/app-privacy-report/app-attribution-speculative-revalidation-expected.txt: Copied from LayoutTests/http/tests/app-privacy-report/attribution-speculative-revalidation-expected.txt.
+        * http/tests/app-privacy-report/app-attribution-speculative-revalidation.html: Copied from LayoutTests/http/tests/app-privacy-report/attribution-speculative-revalidation.html.
+        * http/tests/app-privacy-report/resources/app-initiated-post.py: Copied from LayoutTests/http/tests/app-privacy-report/resources/post.py.
+        * http/tests/app-privacy-report/resources/user-initiated-post.py: Renamed from LayoutTests/http/tests/app-privacy-report/resources/post.py.
+        * http/tests/app-privacy-report/user-attribution-load-url-expected.txt: Added.
+        * http/tests/app-privacy-report/user-attribution-load-url.html: Renamed from LayoutTests/http/tests/app-privacy-report/attribution-load-url.html.
+        * http/tests/app-privacy-report/user-attribution-ping-load-expected.txt: Renamed from LayoutTests/http/tests/app-privacy-report/attribution-ping-load-expected.txt.
+        * http/tests/app-privacy-report/user-attribution-ping-load.html: Renamed from LayoutTests/http/tests/app-privacy-report/attribution-ping-load.html.
+        * http/tests/app-privacy-report/user-attribution-post-request-expected.txt: Added.
+        * http/tests/app-privacy-report/user-attribution-post-request.html: Renamed from LayoutTests/http/tests/app-privacy-report/attribution-post-request.html.
+        * http/tests/app-privacy-report/user-attribution-preflight-async-expected.txt: Renamed from LayoutTests/http/tests/app-privacy-report/attribution-preflight-async-expected.txt.
+        * http/tests/app-privacy-report/user-attribution-preflight-async.html: Renamed from LayoutTests/http/tests/app-privacy-report/attribution-preflight-async.html.
+        * http/tests/app-privacy-report/user-attribution-preflight-sync-expected.txt: Renamed from LayoutTests/http/tests/app-privacy-report/attribution-preflight-sync-expected.txt.
+        * http/tests/app-privacy-report/user-attribution-preflight-sync.html: Renamed from LayoutTests/http/tests/app-privacy-report/attribution-preflight-sync.html.
+        * http/tests/app-privacy-report/user-attribution-speculative-revalidation-expected.txt: Renamed from LayoutTests/http/tests/app-privacy-report/attribution-speculative-revalidation-expected.txt.
+        * http/tests/app-privacy-report/user-attribution-speculative-revalidation.html: Renamed from LayoutTests/http/tests/app-privacy-report/attribution-speculative-revalidation.html.
+        * http/tests/navigation/resources/check-ping-user-initiated-data.py: Added.
+
 2021-07-13  Commit Queue  <commit-qu...@webkit.org>
 
         Unreviewed, reverting r279705.

Copied: trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-load-url-expected.txt (from rev 279873, trunk/LayoutTests/http/tests/app-privacy-report/attribution-load-url-expected.txt) (0 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-load-url-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-load-url-expected.txt	2021-07-13 16:40:12 UTC (rev 279874)
@@ -0,0 +1,3 @@
+Test loadURL requests are succesfully attributed as app initiated.
+PASS successfully loaded only app initiated requests
+

Copied: trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-load-url.html (from rev 279873, trunk/LayoutTests/http/tests/app-privacy-report/attribution-load-url.html) (0 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-load-url.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-load-url.html	2021-07-13 16:40:12 UTC (rev 279874)
@@ -0,0 +1,48 @@
+<!DOCTYPE html><!-- webkit-test-runner [ isAppInitiated=true ] -->
+<html>
+<head>
+    <script src=""
+</head>
+<body _onload_="setTimeout('runTest()', 0)">
+<div id="description">Test loadURL requests are succesfully attributed as app initiated.</div>
+<pre id="console"></pre>
+<script>
+    if (window.testRunner) {
+        testRunner.waitUntilDone();
+        testRunner.dumpAsText();
+    }
+
+    function loadURL() {
+        document.location.href = "" + "/app-privacy-report/app-attribution-load-url.html";
+    }
+
+    function log(message) {
+        document.getElementById('console').appendChild(document.createTextNode(message + '\n'));
+    }
+
+    const destinationOrigin = "http://localhost:8000";
+    const startingOrigin = "http://127.0.0.1:8000";
+    function runTest() {
+        if (document.location.origin === startingOrigin) {
+            loadURL();
+        } else {
+            var didLoadAppInitiatedRequest = testRunner.didLoadAppInitiatedRequest();
+            var didLoadNonAppInitiatedRequest = testRunner.didLoadNonAppInitiatedRequest();
+
+            if (didLoadNonAppInitiatedRequest) {
+                log("FAIL did load non app initiated request");
+                testRunner.notifyDone();
+            }
+
+            if (!didLoadAppInitiatedRequest) {
+                log("FAIL did not load app initiated request");
+                testRunner.notifyDone();
+            }
+
+            log("PASS successfully loaded only app initiated requests");
+            testRunner.notifyDone();
+        }
+    }
+</script>
+</body>
+</html>

Copied: trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-ping-load-expected.txt (from rev 279873, trunk/LayoutTests/http/tests/app-privacy-report/attribution-ping-load-expected.txt) (0 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-ping-load-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-ping-load-expected.txt	2021-07-13 16:40:12 UTC (rev 279874)
@@ -0,0 +1,8 @@
+CONSOLE MESSAGE: PASS successfully loaded only app initiated requests
+Ping sent successfully
+CONTENT_TYPE: text/ping
+HTTP_HOST: 127.0.0.1:8000
+HTTP_PING_FROM: http://127.0.0.1:8000/app-privacy-report/app-attribution-ping-load.html
+HTTP_PING_TO: http://127.0.0.1:8000/navigation/resources/check-ping-app-initiated-data.py
+REQUEST_METHOD: POST
+REQUEST_URI: /navigation/resources/save-ping.py

Copied: trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-ping-load.html (from rev 279873, trunk/LayoutTests/http/tests/app-privacy-report/attribution-ping-load.html) (0 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-ping-load.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-ping-load.html	2021-07-13 16:40:12 UTC (rev 279874)
@@ -0,0 +1,31 @@
+<!DOCTYPE html><!-- webkit-test-runner [ isAppInitiated=true ] -->
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+if (window.testRunner && window.internals) {
+    testRunner.dumpAsText();
+    testRunner.setStatisticsShouldDowngradeReferrer(false, function () { });
+    internals.settings.setHyperlinkAuditingEnabled(true);
+    testRunner.waitUntilDone();
+}
+
+function test()
+{
+    clickElement(document.querySelector("img"));
+}
+
+window._onload_ = function ()
+{
+    clearLastPingResultAndRunTest(test);
+}
+</script>
+</head>
+<body>
+    <img src="" width="128" height="128" usemap=""
+    <map name="imagemap">
+        <area shape="rect" coords="0,0,128,128" href="" ping="../navigation/resources/save-ping.py">
+    </map>
+</body>
+</html>

Copied: trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-post-request-expected.txt (from rev 279873, trunk/LayoutTests/http/tests/app-privacy-report/attribution-post-request-expected.txt) (0 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-post-request-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-post-request-expected.txt	2021-07-13 16:40:12 UTC (rev 279874)
@@ -0,0 +1,4 @@
+CONSOLE MESSAGE: PASS successfully loaded only app initiated requests
+Tests app initiated requests get marked for POST requests.
+
+

Copied: trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-post-request.html (from rev 279873, trunk/LayoutTests/http/tests/app-privacy-report/attribution-post-request.html) (0 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-post-request.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-post-request.html	2021-07-13 16:40:12 UTC (rev 279874)
@@ -0,0 +1,22 @@
+<!DOCTYPE html><!-- webkit-test-runner [ isAppInitiated=true ] -->
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+</head>
+<body>
+<p>Tests app initiated requests get marked for POST requests.</p>
+<form id="testForm" action="" target="_blank" rel="noreferrer" method="post">
+<input type="submit" value="Test"></input>
+<form>
+<script>
+if (window.testRunner) {
+    testRunner.waitUntilDone();
+    testRunner.setCanOpenWindows(true);
+}
+
+document.forms[0].submit();
+
+</script>
+</body>
+</html>

Copied: trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-preflight-async-expected.txt (from rev 279873, trunk/LayoutTests/http/tests/app-privacy-report/attribution-preflight-async-expected.txt) (0 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-preflight-async-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-preflight-async-expected.txt	2021-07-13 16:40:12 UTC (rev 279874)
@@ -0,0 +1,6 @@
+CONSOLE MESSAGE: Preflight response is not successful
+CONSOLE MESSAGE: XMLHttpRequest cannot load http://localhost:8000/xmlhttprequest/resources/status-404-without-body.py due to access control checks.
+Tests app initiated requests get marked for async preflights
+
+PASS successfully loaded only app initiated requests
+

Copied: trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-preflight-async.html (from rev 279873, trunk/LayoutTests/http/tests/app-privacy-report/attribution-preflight-async.html) (0 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-preflight-async.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-preflight-async.html	2021-07-13 16:40:12 UTC (rev 279874)
@@ -0,0 +1,47 @@
+<!DOCTYPE html><!-- webkit-test-runner [ isAppInitiated=true ] -->
+<p>Tests app initiated requests get marked for async preflights</p>
+
+<pre id="console"></pre>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+function log(message)
+{
+    document.getElementById('console').appendChild(document.createTextNode(message + '\n'));
+}
+
+var preflightLinkDomain = "localhost";
+var contextHost = "127.0.0.1";
+var url = ""
+
+function runTest()
+{
+    var req = new XMLHttpRequest();
+    req.open("GET", url, true);
+    req.setRequestHeader("x-webkit", "foo");
+
+    req._onerror_ = function() {
+        var didLoadAppInitiatedRequest = testRunner.didLoadAppInitiatedRequest();
+        var didLoadNonAppInitiatedRequest = testRunner.didLoadNonAppInitiatedRequest();
+
+        if (didLoadNonAppInitiatedRequest) {
+            log("FAIL did load non app initiated request");
+            testRunner.notifyDone();
+        }
+
+        if (!didLoadAppInitiatedRequest) {
+            log("FAIL did not load app initiated request");
+            testRunner.notifyDone();
+        }
+
+        log("PASS successfully loaded only app initiated requests");
+        testRunner.notifyDone();
+    }
+    req.send(null);
+}
+
+runTest();
+</script>

Copied: trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-preflight-sync-expected.txt (from rev 279873, trunk/LayoutTests/http/tests/app-privacy-report/attribution-preflight-sync-expected.txt) (0 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-preflight-sync-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-preflight-sync-expected.txt	2021-07-13 16:40:12 UTC (rev 279874)
@@ -0,0 +1,7 @@
+CONSOLE MESSAGE: Preflight response is not successful
+CONSOLE MESSAGE: XMLHttpRequest cannot load http://localhost:8000/xmlhttprequest/resources/status-404-without-body.py due to access control checks.
+Tests app initiated requests get marked for sync preflights
+
+PASS: NetworkError:  A network error occurred.
+PASS successfully loaded only app initiated requests
+

Copied: trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-preflight-sync.html (from rev 279873, trunk/LayoutTests/http/tests/app-privacy-report/attribution-preflight-sync.html) (0 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-preflight-sync.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-preflight-sync.html	2021-07-13 16:40:12 UTC (rev 279874)
@@ -0,0 +1,50 @@
+<!DOCTYPE html><!-- webkit-test-runner [ isAppInitiated=true ] -->
+<p>Tests app initiated requests get marked for sync preflights</p>
+
+<pre id="console"></pre>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+function log(message)
+{
+    document.getElementById('console').appendChild(document.createTextNode(message + '\n'));
+}
+
+var preflightLinkDomain = "localhost";
+var contextHost = "127.0.0.1";
+var url = ""
+
+function runTest()
+{
+    var req = new XMLHttpRequest();
+    req.open("GET", url, false);
+    req.setRequestHeader("x-webkit", "foo");
+
+    try {
+        req.send(null);
+        log("PASS: " + req.responseText);
+    } catch (ex) {
+        log("PASS: " + ex);
+        var didLoadAppInitiatedRequest = testRunner.didLoadAppInitiatedRequest();
+        var didLoadNonAppInitiatedRequest = testRunner.didLoadNonAppInitiatedRequest();
+
+        if (didLoadNonAppInitiatedRequest) {
+            log("FAIL did load non app initiated request");
+            testRunner.notifyDone();
+        }
+
+        if (!didLoadAppInitiatedRequest) {
+            log("FAIL did not load app initiated request");
+            testRunner.notifyDone();
+        }
+
+        log("PASS successfully loaded only app initiated requests");
+        testRunner.notifyDone();
+    }
+}
+
+runTest();
+</script>

Copied: trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-speculative-revalidation-expected.txt (from rev 279873, trunk/LayoutTests/http/tests/app-privacy-report/attribution-speculative-revalidation-expected.txt) (0 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-speculative-revalidation-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-speculative-revalidation-expected.txt	2021-07-13 16:40:12 UTC (rev 279874)
@@ -0,0 +1,14 @@
+127.0.0.1:8000 - didReceiveAuthenticationChallenge - ProtectionSpaceAuthenticationSchemeHTTPBasic - Responding with testUsername:testPassword
+127.0.0.1:8000 - didReceiveAuthenticationChallenge - ProtectionSpaceAuthenticationSchemeHTTPBasic - Simulating cancelled authentication sheet
+Tests speculative revalidation of authenticated resources.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS xhr.status is 401
+PASS Successfuly loaded.
+PASS successfully loaded only app initiated requests
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Copied: trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-speculative-revalidation.html (from rev 279873, trunk/LayoutTests/http/tests/app-privacy-report/attribution-speculative-revalidation.html) (0 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-speculative-revalidation.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/app-attribution-speculative-revalidation.html	2021-07-13 16:40:12 UTC (rev 279874)
@@ -0,0 +1,73 @@
+<!DOCTYPE html><!-- webkit-test-runner [ isAppInitiated=true ] -->
+<script src=""
+<script>
+description("Tests speculative revalidation of authenticated resources.");
+jsTestIsAsync = true;
+
+testRunner.setHandlesAuthenticationChallenges(true);
+testRunner.setAuthenticationUsername("testUsername");
+testRunner.setAuthenticationPassword("testPassword");
+
+state = "warmup";
+
+function clearCredentialStorage()
+{
+    xhr = new XMLHttpRequest();
+    xhr.open("GET", "resources/resource-with-auth.py?other", false, "badUsername", "badPassword");
+    xhr.send();
+    shouldBe("xhr.status", "401");
+}
+
+function log(message)
+{
+    document.getElementById('console').appendChild(document.createTextNode(message + '\n'));
+}
+
+function frameLoaded()
+{
+    if (state == "warmup") {
+        // Navigate frame to 'about:blank' to flush to subresource loads metadata to disk.
+        state = "flushingMetadata";
+        testRunner.setHandlesAuthenticationChallenges(false);
+        document.getElementById("testFrame").src = ""
+        return;
+    }
+    if (state == "flushingMetadata") {
+        clearCredentialStorage();
+
+        internals.clearMemoryCache();
+        testRunner.setHandlesAuthenticationChallenges(false);
+
+        // Navigate frame to its original location again. This time it should speculatively
+        // validate subresources as we have subresource loads metadata in the disk cache.
+        state = "speculativeRevalidation";
+        document.getElementById("testFrame").src = ""
+        return;
+    }
+    if (state == "speculativeRevalidation") {
+        testPassed("Successfuly loaded.");
+        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();
+        return;
+    }
+}
+
+</script>
+<iframe id="testFrame" src="" _onload_="frameLoaded()"></iframe>
+<script src=""

Deleted: trunk/LayoutTests/http/tests/app-privacy-report/attribution-load-url-expected.txt (279873 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/attribution-load-url-expected.txt	2021-07-13 16:33:26 UTC (rev 279873)
+++ trunk/LayoutTests/http/tests/app-privacy-report/attribution-load-url-expected.txt	2021-07-13 16:40:12 UTC (rev 279874)
@@ -1,3 +0,0 @@
-Test loadURL requests are succesfully attributed as app initiated.
-PASS successfully loaded only app initiated requests
-

Deleted: trunk/LayoutTests/http/tests/app-privacy-report/attribution-load-url.html (279873 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/attribution-load-url.html	2021-07-13 16:33:26 UTC (rev 279873)
+++ trunk/LayoutTests/http/tests/app-privacy-report/attribution-load-url.html	2021-07-13 16:40:12 UTC (rev 279874)
@@ -1,48 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-    <script src=""
-</head>
-<body _onload_="setTimeout('runTest()', 0)">
-<div id="description">Test loadURL requests are succesfully attributed as app initiated.</div>
-<pre id="console"></pre>
-<script>
-    if (window.testRunner) {
-        testRunner.waitUntilDone();
-        testRunner.dumpAsText();
-    }
-
-    function loadURL() {
-        document.location.href = "" + "/app-privacy-report/attribution-load-url.html";
-    }
-
-    function log(message) {
-        document.getElementById('console').appendChild(document.createTextNode(message + '\n'));
-    }
-
-    const destinationOrigin = "http://localhost:8000";
-    const startingOrigin = "http://127.0.0.1:8000";
-    function runTest() {
-        if (document.location.origin === startingOrigin) {
-            loadURL();
-        } else {
-            var didLoadAppInitiatedRequest = testRunner.didLoadAppInitiatedRequest();
-            var didLoadNonAppInitiatedRequest = testRunner.didLoadNonAppInitiatedRequest();
-
-            if (didLoadNonAppInitiatedRequest) {
-                log("FAIL did load non app initiated request");
-                testRunner.notifyDone();
-            }
-
-            if (!didLoadAppInitiatedRequest) {
-                log("FAIL did not load app initiated request");
-                testRunner.notifyDone();
-            }
-
-            log("PASS successfully loaded only app initiated requests");
-            testRunner.notifyDone();
-        }
-    }
-</script>
-</body>
-</html>

Deleted: trunk/LayoutTests/http/tests/app-privacy-report/attribution-ping-load-expected.txt (279873 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/attribution-ping-load-expected.txt	2021-07-13 16:33:26 UTC (rev 279873)
+++ trunk/LayoutTests/http/tests/app-privacy-report/attribution-ping-load-expected.txt	2021-07-13 16:40:12 UTC (rev 279874)
@@ -1,8 +0,0 @@
-CONSOLE MESSAGE: PASS successfully loaded only app initiated requests
-Ping sent successfully
-CONTENT_TYPE: text/ping
-HTTP_HOST: 127.0.0.1:8000
-HTTP_PING_FROM: http://127.0.0.1:8000/app-privacy-report/attribution-ping-load.html
-HTTP_PING_TO: http://127.0.0.1:8000/navigation/resources/check-ping-app-initiated-data.py
-REQUEST_METHOD: POST
-REQUEST_URI: /navigation/resources/save-ping.py

Deleted: trunk/LayoutTests/http/tests/app-privacy-report/attribution-ping-load.html (279873 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/attribution-ping-load.html	2021-07-13 16:33:26 UTC (rev 279873)
+++ trunk/LayoutTests/http/tests/app-privacy-report/attribution-ping-load.html	2021-07-13 16:40:12 UTC (rev 279874)
@@ -1,30 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<script src=""
-<script>
-if (window.testRunner && window.internals) {
-    testRunner.dumpAsText();
-    testRunner.setStatisticsShouldDowngradeReferrer(false, function () { });
-    internals.settings.setHyperlinkAuditingEnabled(true);
-    testRunner.waitUntilDone();
-}
-
-function test()
-{
-    clickElement(document.querySelector("img"));
-}
-
-window._onload_ = function ()
-{
-    clearLastPingResultAndRunTest(test);
-}
-</script>
-</head>
-<body>
-    <img src="" width="128" height="128" usemap=""
-    <map name="imagemap">
-        <area shape="rect" coords="0,0,128,128" href="" ping="../navigation/resources/save-ping.py">
-    </map>
-</body>
-</html>

Deleted: trunk/LayoutTests/http/tests/app-privacy-report/attribution-post-request-expected.txt (279873 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/attribution-post-request-expected.txt	2021-07-13 16:33:26 UTC (rev 279873)
+++ trunk/LayoutTests/http/tests/app-privacy-report/attribution-post-request-expected.txt	2021-07-13 16:40:12 UTC (rev 279874)
@@ -1,4 +0,0 @@
-CONSOLE MESSAGE: PASS successfully loaded only app initiated requests
-Tests app initiated requests get marked for POST requests.
-
-

Deleted: trunk/LayoutTests/http/tests/app-privacy-report/attribution-post-request.html (279873 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/attribution-post-request.html	2021-07-13 16:33:26 UTC (rev 279873)
+++ trunk/LayoutTests/http/tests/app-privacy-report/attribution-post-request.html	2021-07-13 16:40:12 UTC (rev 279874)
@@ -1,22 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<meta charset="utf-8">
-<script src=""
-</head>
-<body>
-<p>Tests app initiated requests get marked for POST requests.</p>
-<form id="testForm" action="" target="_blank" rel="noreferrer" method="post">
-<input type="submit" value="Test"></input>
-<form>
-<script>
-if (window.testRunner) {
-    testRunner.waitUntilDone();
-    testRunner.setCanOpenWindows(true);
-}
-
-document.forms[0].submit();
-
-</script>
-</body>
-</html>

Deleted: trunk/LayoutTests/http/tests/app-privacy-report/attribution-preflight-async-expected.txt (279873 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/attribution-preflight-async-expected.txt	2021-07-13 16:33:26 UTC (rev 279873)
+++ trunk/LayoutTests/http/tests/app-privacy-report/attribution-preflight-async-expected.txt	2021-07-13 16:40:12 UTC (rev 279874)
@@ -1,6 +0,0 @@
-CONSOLE MESSAGE: Preflight response is not successful
-CONSOLE MESSAGE: XMLHttpRequest cannot load http://localhost:8000/xmlhttprequest/resources/status-404-without-body.py due to access control checks.
-Tests app initiated requests get marked for async preflights
-
-PASS successfully loaded only app initiated requests
-

Deleted: trunk/LayoutTests/http/tests/app-privacy-report/attribution-preflight-async.html (279873 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/attribution-preflight-async.html	2021-07-13 16:33:26 UTC (rev 279873)
+++ trunk/LayoutTests/http/tests/app-privacy-report/attribution-preflight-async.html	2021-07-13 16:40:12 UTC (rev 279874)
@@ -1,46 +0,0 @@
-<p>Tests app initiated requests get marked for async preflights</p>
-
-<pre id="console"></pre>
-<script>
-if (window.testRunner) {
-    testRunner.dumpAsText();
-    testRunner.waitUntilDone();
-}
-
-function log(message)
-{
-    document.getElementById('console').appendChild(document.createTextNode(message + '\n'));
-}
-
-var preflightLinkDomain = "localhost";
-var contextHost = "127.0.0.1";
-var url = ""
-
-function runTest()
-{
-    var req = new XMLHttpRequest();
-    req.open("GET", url, true);
-    req.setRequestHeader("x-webkit", "foo");
-
-    req._onerror_ = function() {
-        var didLoadAppInitiatedRequest = testRunner.didLoadAppInitiatedRequest();
-        var didLoadNonAppInitiatedRequest = testRunner.didLoadNonAppInitiatedRequest();
-
-        if (didLoadNonAppInitiatedRequest) {
-            log("FAIL did load non app initiated request");
-            testRunner.notifyDone();
-        }
-
-        if (!didLoadAppInitiatedRequest) {
-            log("FAIL did not load app initiated request");
-            testRunner.notifyDone();
-        }
-
-        log("PASS successfully loaded only app initiated requests");
-        testRunner.notifyDone();
-    }
-    req.send(null);
-}
-
-runTest();
-</script>

Deleted: trunk/LayoutTests/http/tests/app-privacy-report/attribution-preflight-sync-expected.txt (279873 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/attribution-preflight-sync-expected.txt	2021-07-13 16:33:26 UTC (rev 279873)
+++ trunk/LayoutTests/http/tests/app-privacy-report/attribution-preflight-sync-expected.txt	2021-07-13 16:40:12 UTC (rev 279874)
@@ -1,7 +0,0 @@
-CONSOLE MESSAGE: Preflight response is not successful
-CONSOLE MESSAGE: XMLHttpRequest cannot load http://localhost:8000/xmlhttprequest/resources/status-404-without-body.py due to access control checks.
-Tests app initiated requests get marked for sync preflights
-
-PASS: NetworkError:  A network error occurred.
-PASS successfully loaded only app initiated requests
-

Deleted: trunk/LayoutTests/http/tests/app-privacy-report/attribution-preflight-sync.html (279873 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/attribution-preflight-sync.html	2021-07-13 16:33:26 UTC (rev 279873)
+++ trunk/LayoutTests/http/tests/app-privacy-report/attribution-preflight-sync.html	2021-07-13 16:40:12 UTC (rev 279874)
@@ -1,49 +0,0 @@
-<p>Tests app initiated requests get marked for sync preflights</p>
-
-<pre id="console"></pre>
-<script>
-if (window.testRunner) {
-    testRunner.dumpAsText();
-    testRunner.waitUntilDone();
-}
-
-function log(message)
-{
-    document.getElementById('console').appendChild(document.createTextNode(message + '\n'));
-}
-
-var preflightLinkDomain = "localhost";
-var contextHost = "127.0.0.1";
-var url = ""
-
-function runTest()
-{
-    var req = new XMLHttpRequest();
-    req.open("GET", url, false);
-    req.setRequestHeader("x-webkit", "foo");
-
-    try {
-        req.send(null);
-        log("PASS: " + req.responseText);
-    } catch (ex) {
-        log("PASS: " + ex);
-        var didLoadAppInitiatedRequest = testRunner.didLoadAppInitiatedRequest();
-        var didLoadNonAppInitiatedRequest = testRunner.didLoadNonAppInitiatedRequest();
-
-        if (didLoadNonAppInitiatedRequest) {
-            log("FAIL did load non app initiated request");
-            testRunner.notifyDone();
-        }
-
-        if (!didLoadAppInitiatedRequest) {
-            log("FAIL did not load app initiated request");
-            testRunner.notifyDone();
-        }
-
-        log("PASS successfully loaded only app initiated requests");
-        testRunner.notifyDone();
-    }
-}
-
-runTest();
-</script>

Deleted: trunk/LayoutTests/http/tests/app-privacy-report/attribution-speculative-revalidation-expected.txt (279873 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/attribution-speculative-revalidation-expected.txt	2021-07-13 16:33:26 UTC (rev 279873)
+++ trunk/LayoutTests/http/tests/app-privacy-report/attribution-speculative-revalidation-expected.txt	2021-07-13 16:40:12 UTC (rev 279874)
@@ -1,14 +0,0 @@
-127.0.0.1:8000 - didReceiveAuthenticationChallenge - ProtectionSpaceAuthenticationSchemeHTTPBasic - Responding with testUsername:testPassword
-127.0.0.1:8000 - didReceiveAuthenticationChallenge - ProtectionSpaceAuthenticationSchemeHTTPBasic - Simulating cancelled authentication sheet
-Tests speculative revalidation of authenticated resources.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-PASS xhr.status is 401
-PASS Successfuly loaded.
-PASS successfully loaded only app initiated requests
-PASS successfullyParsed is true
-
-TEST COMPLETE
-

Deleted: trunk/LayoutTests/http/tests/app-privacy-report/attribution-speculative-revalidation.html (279873 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/attribution-speculative-revalidation.html	2021-07-13 16:33:26 UTC (rev 279873)
+++ trunk/LayoutTests/http/tests/app-privacy-report/attribution-speculative-revalidation.html	2021-07-13 16:40:12 UTC (rev 279874)
@@ -1,72 +0,0 @@
-<script src=""
-<script>
-description("Tests speculative revalidation of authenticated resources.");
-jsTestIsAsync = true;
-
-testRunner.setHandlesAuthenticationChallenges(true);
-testRunner.setAuthenticationUsername("testUsername");
-testRunner.setAuthenticationPassword("testPassword");
-
-state = "warmup";
-
-function clearCredentialStorage()
-{
-    xhr = new XMLHttpRequest();
-    xhr.open("GET", "resources/resource-with-auth.py?other", false, "badUsername", "badPassword");
-    xhr.send();
-    shouldBe("xhr.status", "401");
-}
-
-function log(message)
-{
-    document.getElementById('console').appendChild(document.createTextNode(message + '\n'));
-}
-
-function frameLoaded()
-{
-    if (state == "warmup") {
-        // Navigate frame to 'about:blank' to flush to subresource loads metadata to disk.
-        state = "flushingMetadata";
-        testRunner.setHandlesAuthenticationChallenges(false);
-        document.getElementById("testFrame").src = ""
-        return;
-    }
-    if (state == "flushingMetadata") {
-        clearCredentialStorage();
-
-        internals.clearMemoryCache();
-        testRunner.setHandlesAuthenticationChallenges(false);
-
-        // Navigate frame to its original location again. This time it should speculatively
-        // validate subresources as we have subresource loads metadata in the disk cache.
-        state = "speculativeRevalidation";
-        document.getElementById("testFrame").src = ""
-        return;
-    }
-    if (state == "speculativeRevalidation") {
-        testPassed("Successfuly loaded.");
-        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();
-        return;
-    }
-}
-
-</script>
-<iframe id="testFrame" src="" _onload_="frameLoaded()"></iframe>
-<script src=""

Copied: trunk/LayoutTests/http/tests/app-privacy-report/resources/app-initiated-post.py (from rev 279873, trunk/LayoutTests/http/tests/app-privacy-report/resources/post.py) (0 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/resources/app-initiated-post.py	                        (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/resources/app-initiated-post.py	2021-07-13 16:40:12 UTC (rev 279874)
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+
+import os
+import sys
+
+referer = os.environ.get('HTTP_REFERER', '')
+
+sys.stdout.write(
+    'Content-Type: text/html\r\n\r\n'
+    '<p>Referrer: {referer}</p>\n'
+    '<script>\n'
+    'if (window.testRunner) {{\n'
+    '    var didLoadAppInitiatedRequest = testRunner.didLoadAppInitiatedRequest();\n'
+    '    var didLoadNonAppInitiatedRequest = testRunner.didLoadNonAppInitiatedRequest();\n'
+    '    if (didLoadNonAppInitiatedRequest) {{\n'
+    '        console.log("FAIL did load non app initiated request");\n'
+    '        testRunner.notifyDone();\n'
+    '    }}\n'
+    '    if (!didLoadAppInitiatedRequest) {{\n'
+    '         console.log("FAIL did not load app initiated request");\n'
+    '        testRunner.notifyDone();\n'
+    '     }}\n'
+    '    console.log("PASS successfully loaded only app initiated requests");\n'
+    '    testRunner.notifyDone();\n'
+    '}}\n'
+    '</script>\n'.format(referer=referer)
+)

Deleted: trunk/LayoutTests/http/tests/app-privacy-report/resources/post.py (279873 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/resources/post.py	2021-07-13 16:33:26 UTC (rev 279873)
+++ trunk/LayoutTests/http/tests/app-privacy-report/resources/post.py	2021-07-13 16:40:12 UTC (rev 279874)
@@ -1,27 +0,0 @@
-#!/usr/bin/env python3
-
-import os
-import sys
-
-referer = os.environ.get('HTTP_REFERER', '')
-
-sys.stdout.write(
-    'Content-Type: text/html\r\n\r\n'
-    '<p>Referrer: {referer}</p>\n'
-    '<script>\n'
-    'if (window.testRunner) {{\n'
-    '    var didLoadAppInitiatedRequest = testRunner.didLoadAppInitiatedRequest();\n'
-    '    var didLoadNonAppInitiatedRequest = testRunner.didLoadNonAppInitiatedRequest();\n'
-    '    if (didLoadNonAppInitiatedRequest) {{\n'
-    '        console.log("FAIL did load non app initiated request");\n'
-    '        testRunner.notifyDone();\n'
-    '    }}\n'
-    '    if (!didLoadAppInitiatedRequest) {{\n'
-    '         console.log("FAIL did not load app initiated request");\n'
-    '        testRunner.notifyDone();\n'
-    '     }}\n'
-    '    console.log("PASS successfully loaded only app initiated requests");\n'
-    '    testRunner.notifyDone();\n'
-    '}}\n'
-    '</script>\n'.format(referer=referer)
-)

Copied: trunk/LayoutTests/http/tests/app-privacy-report/resources/user-initiated-post.py (from rev 279873, trunk/LayoutTests/http/tests/app-privacy-report/resources/post.py) (0 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/resources/user-initiated-post.py	                        (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/resources/user-initiated-post.py	2021-07-13 16:40:12 UTC (rev 279874)
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+
+import os
+import sys
+
+referer = os.environ.get('HTTP_REFERER', '')
+
+sys.stdout.write(
+    'Content-Type: text/html\r\n\r\n'
+    '<p>Referrer: {referer}</p>\n'
+    '<script>\n'
+    'if (window.testRunner) {{\n'
+    '    var didLoadAppInitiatedRequest = testRunner.didLoadAppInitiatedRequest();\n'
+    '    var didLoadNonAppInitiatedRequest = testRunner.didLoadNonAppInitiatedRequest();\n'
+    '    if (didLoadAppInitiatedRequest) {{\n'
+    '        console.log("FAIL did load app initiated request");\n'
+    '        testRunner.notifyDone();\n'
+    '    }}\n'
+    '    if (!didLoadNonAppInitiatedRequest) {{\n'
+    '         console.log("FAIL did not load non app initiated request");\n'
+    '        testRunner.notifyDone();\n'
+    '     }}\n'
+    '    console.log("PASS successfully loaded only non app initiated requests");\n'
+    '    testRunner.notifyDone();\n'
+    '}}\n'
+    '</script>\n'.format(referer=referer)
+)

Added: trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-load-url-expected.txt (0 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-load-url-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-load-url-expected.txt	2021-07-13 16:40:12 UTC (rev 279874)
@@ -0,0 +1,3 @@
+Test loadURL requests are succesfully attributed as non app initiated.
+PASS successfully loaded only non app initiated requests
+

Copied: trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-load-url.html (from rev 279873, trunk/LayoutTests/http/tests/app-privacy-report/attribution-load-url.html) (0 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-load-url.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-load-url.html	2021-07-13 16:40:12 UTC (rev 279874)
@@ -0,0 +1,48 @@
+<!DOCTYPE html><!-- webkit-test-runner [ isAppInitiated=false ] -->
+<html>
+<head>
+    <script src=""
+</head>
+<body _onload_="setTimeout('runTest()', 0)">
+<div id="description">Test loadURL requests are succesfully attributed as non app initiated.</div>
+<pre id="console"></pre>
+<script>
+    if (window.testRunner) {
+        testRunner.waitUntilDone();
+        testRunner.dumpAsText();
+    }
+
+    function loadURL() {
+        document.location.href = "" + "/app-privacy-report/user-attribution-load-url.html";
+    }
+
+    function log(message) {
+        document.getElementById('console').appendChild(document.createTextNode(message + '\n'));
+    }
+
+    const destinationOrigin = "http://localhost:8000";
+    const startingOrigin = "http://127.0.0.1:8000";
+    function runTest() {
+        if (document.location.origin === startingOrigin) {
+            loadURL();
+        } else {
+            var didLoadAppInitiatedRequest = testRunner.didLoadAppInitiatedRequest();
+            var didLoadNonAppInitiatedRequest = testRunner.didLoadNonAppInitiatedRequest();
+
+            if (didLoadAppInitiatedRequest) {
+                log("FAIL did load app initiated request");
+                testRunner.notifyDone();
+            }
+
+            if (!didLoadNonAppInitiatedRequest) {
+                log("FAIL did not load non app initiated request");
+                testRunner.notifyDone();
+            }
+
+            log("PASS successfully loaded only non app initiated requests");
+            testRunner.notifyDone();
+        }
+    }
+</script>
+</body>
+</html>

Copied: trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-ping-load-expected.txt (from rev 279873, trunk/LayoutTests/http/tests/app-privacy-report/attribution-ping-load-expected.txt) (0 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-ping-load-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-ping-load-expected.txt	2021-07-13 16:40:12 UTC (rev 279874)
@@ -0,0 +1,8 @@
+CONSOLE MESSAGE: PASS successfully loaded only non app initiated requests
+Ping sent successfully
+CONTENT_TYPE: text/ping
+HTTP_HOST: 127.0.0.1:8000
+HTTP_PING_FROM: http://127.0.0.1:8000/app-privacy-report/user-attribution-ping-load.html
+HTTP_PING_TO: http://127.0.0.1:8000/navigation/resources/check-ping-user-initiated-data.py
+REQUEST_METHOD: POST
+REQUEST_URI: /navigation/resources/save-ping.py

Copied: trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-ping-load.html (from rev 279873, trunk/LayoutTests/http/tests/app-privacy-report/attribution-ping-load.html) (0 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-ping-load.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-ping-load.html	2021-07-13 16:40:12 UTC (rev 279874)
@@ -0,0 +1,31 @@
+<!DOCTYPE html><!-- webkit-test-runner [ isAppInitiated=false ] -->
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+if (window.testRunner && window.internals) {
+    testRunner.dumpAsText();
+    testRunner.setStatisticsShouldDowngradeReferrer(false, function () { });
+    internals.settings.setHyperlinkAuditingEnabled(true);
+    testRunner.waitUntilDone();
+}
+
+function test()
+{
+    clickElement(document.querySelector("img"));
+}
+
+window._onload_ = function ()
+{
+    clearLastPingResultAndRunTest(test);
+}
+</script>
+</head>
+<body>
+    <img src="" width="128" height="128" usemap=""
+    <map name="imagemap">
+        <area shape="rect" coords="0,0,128,128" href="" ping="../navigation/resources/save-ping.py">
+    </map>
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-post-request-expected.txt (0 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-post-request-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-post-request-expected.txt	2021-07-13 16:40:12 UTC (rev 279874)
@@ -0,0 +1,4 @@
+CONSOLE MESSAGE: PASS successfully loaded only non app initiated requests
+Tests non app initiated requests get marked for POST requests.
+
+

Copied: trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-post-request.html (from rev 279873, trunk/LayoutTests/http/tests/app-privacy-report/attribution-post-request.html) (0 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-post-request.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-post-request.html	2021-07-13 16:40:12 UTC (rev 279874)
@@ -0,0 +1,22 @@
+<!DOCTYPE html><!-- webkit-test-runner [ isAppInitiated=false ] -->
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+</head>
+<body>
+<p>Tests non app initiated requests get marked for POST requests.</p>
+<form id="testForm" action="" target="_blank" rel="noreferrer" method="post">
+<input type="submit" value="Test"></input>
+<form>
+<script>
+if (window.testRunner) {
+    testRunner.waitUntilDone();
+    testRunner.setCanOpenWindows(true);
+}
+
+document.forms[0].submit();
+
+</script>
+</body>
+</html>

Copied: trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-preflight-async-expected.txt (from rev 279873, trunk/LayoutTests/http/tests/app-privacy-report/attribution-preflight-async-expected.txt) (0 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-preflight-async-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-preflight-async-expected.txt	2021-07-13 16:40:12 UTC (rev 279874)
@@ -0,0 +1,6 @@
+CONSOLE MESSAGE: Preflight response is not successful
+CONSOLE MESSAGE: XMLHttpRequest cannot load http://localhost:8000/xmlhttprequest/resources/status-404-without-body.py due to access control checks.
+Tests non app initiated requests get marked for async preflights
+
+PASS successfully loaded only non app initiated requests
+

Copied: trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-preflight-async.html (from rev 279873, trunk/LayoutTests/http/tests/app-privacy-report/attribution-preflight-async.html) (0 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-preflight-async.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-preflight-async.html	2021-07-13 16:40:12 UTC (rev 279874)
@@ -0,0 +1,47 @@
+<!DOCTYPE html><!-- webkit-test-runner [ isAppInitiated=false ] -->
+<p>Tests non app initiated requests get marked for async preflights</p>
+
+<pre id="console"></pre>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+function log(message)
+{
+    document.getElementById('console').appendChild(document.createTextNode(message + '\n'));
+}
+
+var preflightLinkDomain = "localhost";
+var contextHost = "127.0.0.1";
+var url = ""
+
+function runTest()
+{
+    var req = new XMLHttpRequest();
+    req.open("GET", url, true);
+    req.setRequestHeader("x-webkit", "foo");
+
+    req._onerror_ = function() {
+        var didLoadAppInitiatedRequest = testRunner.didLoadAppInitiatedRequest();
+        var didLoadNonAppInitiatedRequest = testRunner.didLoadNonAppInitiatedRequest();
+
+        if (didLoadAppInitiatedRequest) {
+            log("FAIL did load app initiated request");
+            testRunner.notifyDone();
+        }
+
+        if (!didLoadNonAppInitiatedRequest) {
+            log("FAIL did not load non app initiated request");
+            testRunner.notifyDone();
+        }
+
+        log("PASS successfully loaded only non app initiated requests");
+        testRunner.notifyDone();
+    }
+    req.send(null);
+}
+
+runTest();
+</script>

Copied: trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-preflight-sync-expected.txt (from rev 279873, trunk/LayoutTests/http/tests/app-privacy-report/attribution-preflight-sync-expected.txt) (0 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-preflight-sync-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-preflight-sync-expected.txt	2021-07-13 16:40:12 UTC (rev 279874)
@@ -0,0 +1,7 @@
+CONSOLE MESSAGE: Preflight response is not successful
+CONSOLE MESSAGE: XMLHttpRequest cannot load http://localhost:8000/xmlhttprequest/resources/status-404-without-body.py due to access control checks.
+Tests non app initiated requests get marked for sync preflights
+
+PASS: NetworkError:  A network error occurred.
+PASS successfully loaded only non app initiated requests
+

Copied: trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-preflight-sync.html (from rev 279873, trunk/LayoutTests/http/tests/app-privacy-report/attribution-preflight-sync.html) (0 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-preflight-sync.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-preflight-sync.html	2021-07-13 16:40:12 UTC (rev 279874)
@@ -0,0 +1,50 @@
+<!DOCTYPE html><!-- webkit-test-runner [ isAppInitiated=false ] -->
+<p>Tests non app initiated requests get marked for sync preflights</p>
+
+<pre id="console"></pre>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+function log(message)
+{
+    document.getElementById('console').appendChild(document.createTextNode(message + '\n'));
+}
+
+var preflightLinkDomain = "localhost";
+var contextHost = "127.0.0.1";
+var url = ""
+
+function runTest()
+{
+    var req = new XMLHttpRequest();
+    req.open("GET", url, false);
+    req.setRequestHeader("x-webkit", "foo");
+
+    try {
+        req.send(null);
+        log("PASS: " + req.responseText);
+    } catch (ex) {
+        log("PASS: " + ex);
+        var didLoadAppInitiatedRequest = testRunner.didLoadAppInitiatedRequest();
+        var didLoadNonAppInitiatedRequest = testRunner.didLoadNonAppInitiatedRequest();
+
+        if (didLoadAppInitiatedRequest) {
+            log("FAIL did load app initiated request");
+            testRunner.notifyDone();
+        }
+
+        if (!didLoadNonAppInitiatedRequest) {
+            log("FAIL did not load non app initiated request");
+            testRunner.notifyDone();
+        }
+
+        log("PASS successfully loaded only non app initiated requests");
+        testRunner.notifyDone();
+    }
+}
+
+runTest();
+</script>

Copied: trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-speculative-revalidation-expected.txt (from rev 279873, trunk/LayoutTests/http/tests/app-privacy-report/attribution-speculative-revalidation-expected.txt) (0 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-speculative-revalidation-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-speculative-revalidation-expected.txt	2021-07-13 16:40:12 UTC (rev 279874)
@@ -0,0 +1,14 @@
+127.0.0.1:8000 - didReceiveAuthenticationChallenge - ProtectionSpaceAuthenticationSchemeHTTPBasic - Responding with testUsername:testPassword
+127.0.0.1:8000 - didReceiveAuthenticationChallenge - ProtectionSpaceAuthenticationSchemeHTTPBasic - Simulating cancelled authentication sheet
+Tests speculative revalidation of authenticated resources.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS xhr.status is 401
+PASS Successfuly loaded.
+PASS successfully loaded only non app initiated requests
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Copied: trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-speculative-revalidation.html (from rev 279873, trunk/LayoutTests/http/tests/app-privacy-report/attribution-speculative-revalidation.html) (0 => 279874)


--- trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-speculative-revalidation.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/app-privacy-report/user-attribution-speculative-revalidation.html	2021-07-13 16:40:12 UTC (rev 279874)
@@ -0,0 +1,70 @@
+<!DOCTYPE html><!-- webkit-test-runner [ isAppInitiated=false ] -->
+<script src=""
+<script>
+description("Tests speculative revalidation of authenticated resources.");
+jsTestIsAsync = true;
+
+testRunner.setHandlesAuthenticationChallenges(true);
+testRunner.setAuthenticationUsername("testUsername");
+testRunner.setAuthenticationPassword("testPassword");
+
+state = "warmup";
+
+function clearCredentialStorage()
+{
+    xhr = new XMLHttpRequest();
+    xhr.open("GET", "resources/resource-with-auth.py?other", false, "badUsername", "badPassword");
+    xhr.send();
+    shouldBe("xhr.status", "401");
+}
+
+function log(message)
+{
+    document.getElementById('console').appendChild(document.createTextNode(message + '\n'));
+}
+
+function frameLoaded()
+{
+    if (state == "warmup") {
+        // Navigate frame to 'about:blank' to flush to subresource loads metadata to disk.
+        state = "flushingMetadata";
+        testRunner.setHandlesAuthenticationChallenges(false);
+        document.getElementById("testFrame").src = ""
+        return;
+    }
+    if (state == "flushingMetadata") {
+        clearCredentialStorage();
+
+        internals.clearMemoryCache();
+        testRunner.setHandlesAuthenticationChallenges(false);
+
+        // Navigate frame to its original location again. This time it should speculatively
+        // validate subresources as we have subresource loads metadata in the disk cache.
+        state = "speculativeRevalidation";
+        document.getElementById("testFrame").src = ""
+        return;
+    }
+    if (state == "speculativeRevalidation") {
+        testPassed("Successfuly loaded.");
+        var didLoadAppInitiatedRequest = testRunner.didLoadAppInitiatedRequest();
+        var didLoadNonAppInitiatedRequest = testRunner.didLoadNonAppInitiatedRequest();
+
+        if (didLoadAppInitiatedRequest) {
+            log("FAIL did load app initiated request");
+            finishJSTest();
+        }
+
+        if (!didLoadNonAppInitiatedRequest) {
+            log("FAIL did not load non app initiated request");
+            finishJSTest();
+        }
+
+        log("PASS successfully loaded only non app initiated requests");
+        finishJSTest();
+        return;
+    }
+}
+
+</script>
+<iframe id="testFrame" src="" _onload_="frameLoaded()"></iframe>
+<script src=""

Added: trunk/LayoutTests/http/tests/navigation/resources/check-ping-user-initiated-data.py (0 => 279874)


--- trunk/LayoutTests/http/tests/navigation/resources/check-ping-user-initiated-data.py	                        (rev 0)
+++ trunk/LayoutTests/http/tests/navigation/resources/check-ping-user-initiated-data.py	2021-07-13 16:40:12 UTC (rev 279874)
@@ -0,0 +1,44 @@
+#!/usr/bin/env python3
+
+import os
+import sys
+import time
+from ping_file_path import ping_filepath
+
+sys.stdout.write('Content-Type: text/html\r\n\r\n')
+
+while not os.path.isfile(ping_filepath):
+    time.sleep(0.01)
+
+sys.stdout.write(
+    '<html><body>\n'
+    'Ping sent successfully'
+)
+
+ping_file = open(ping_filepath, 'r')
+for line in ping_file.readlines():
+    sys.stdout.write('<br>{}'.format(line.strip()))
+
+ping_file.close()
+if os.path.isfile(ping_filepath):
+    os.remove(ping_filepath)
+
+sys.stdout.write(
+    '<script>'
+    'if (window.testRunner) {{\n'
+    '    var didLoadAppInitiatedRequest = testRunner.didLoadAppInitiatedRequest();\n'
+    '    var didLoadNonAppInitiatedRequest = testRunner.didLoadNonAppInitiatedRequest();\n'
+    '    if (didLoadAppInitiatedRequest) {{\n'
+    '        console.log("FAIL did load app initiated request");\n'
+    '        testRunner.notifyDone();\n'
+    '    }}\n'
+    '    if (!didLoadNonAppInitiatedRequest) {{\n'
+    '         console.log("FAIL did not load non app initiated request");\n'
+    '        testRunner.notifyDone();\n'
+    '     }}\n'
+    '    console.log("PASS successfully loaded only non app initiated requests");\n'
+    '    testRunner.notifyDone();\n'
+    '}}\n'
+    '</script>'
+    '</body></html>'
+)
Property changes on: trunk/LayoutTests/http/tests/navigation/resources/check-ping-user-initiated-data.py
___________________________________________________________________

Added: svn:executable

+* \ No newline at end of property

Modified: trunk/Source/WebKit/ChangeLog (279873 => 279874)


--- trunk/Source/WebKit/ChangeLog	2021-07-13 16:33:26 UTC (rev 279873)
+++ trunk/Source/WebKit/ChangeLog	2021-07-13 16:40:12 UTC (rev 279874)
@@ -1,3 +1,42 @@
+2021-07-13  Kate Cheney  <katherine_che...@apple.com>
+
+        Allow layout tests to specify app initiated loads or not
+        https://bugs.webkit.org/show_bug.cgi?id=227825
+        <rdar://problem/80355582>
+
+        Reviewed by Brent Fulgham.
+
+        Tests: http/tests/app-privacy-report/app-attribution-load-url.html
+               http/tests/app-privacy-report/app-attribution-ping-load.html
+               http/tests/app-privacy-report/app-attribution-post-request.html
+               http/tests/app-privacy-report/app-attribution-preflight-async.html
+               http/tests/app-privacy-report/app-attribution-preflight-sync.html
+               http/tests/app-privacy-report/app-attribution-speculative-revalidation.html
+               http/tests/app-privacy-report/user-attribution-load-url.html
+               http/tests/app-privacy-report/user-attribution-ping-load.html
+               http/tests/app-privacy-report/user-attribution-post-request.html
+               http/tests/app-privacy-report/user-attribution-preflight-async.html
+               http/tests/app-privacy-report/user-attribution-preflight-sync.html
+               http/tests/app-privacy-report/user-attribution-speculative-revalidation.html
+
+        Add a parameter to the WebView configuration that allows a test to
+        override the default NSURLRequest attribution value. We don't need
+        this to be dynamic per-test, so we can store it in the configuration.
+
+        * UIProcess/API/APIPageConfiguration.cpp:
+        (API::PageConfiguration::copy const):
+        * UIProcess/API/APIPageConfiguration.h:
+        (API::PageConfiguration::appInitiatedOverrideValueForTesting const):
+        (API::PageConfiguration::setAppInitiatedOverrideValueForTesting):
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+        (toWKAttributionOverrideTesting):
+        (toAttributionOverrideTesting):
+        (-[WKWebViewConfiguration _setAppInitiatedOverrideValueForTesting:]):
+        (-[WKWebViewConfiguration _appInitiatedOverrideValueForTesting]):
+        * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
+        * UIProcess/Cocoa/WebPageProxyCocoa.mm:
+        (WebKit::WebPageProxy::setLastNavigationWasAppInitiated):
+
 2021-07-13  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [GTK][WPE] Expose support for client certificate auth

Modified: trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.cpp (279873 => 279874)


--- trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.cpp	2021-07-13 16:33:26 UTC (rev 279873)
+++ trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.cpp	2021-07-13 16:40:12 UTC (rev 279874)
@@ -96,6 +96,9 @@
 
     copy->m_mediaCaptureEnabled = this->m_mediaCaptureEnabled;
     copy->m_httpsUpgradeEnabled = this->m_httpsUpgradeEnabled;
+#if ENABLE(APP_PRIVACY_REPORT)
+    copy->m_appInitiatedOverrideValueForTesting = this->m_appInitiatedOverrideValueForTesting;
+#endif
 
     return copy;
 }

Modified: trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.h (279873 => 279874)


--- trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.h	2021-07-13 16:33:26 UTC (rev 279873)
+++ trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.h	2021-07-13 16:40:12 UTC (rev 279874)
@@ -47,6 +47,15 @@
 class WebURLSchemeHandler;
 class WebUserContentControllerProxy;
 class WebsiteDataStore;
+
+#if ENABLE(APP_PRIVACY_REPORT)
+enum class AttributionOverrideTesting : uint8_t {
+    NoOverride,
+    UserInitiated,
+    AppInitiated
+};
+#endif
+
 }
 
 namespace API {
@@ -170,6 +179,11 @@
     void setAttributedBundleIdentifier(WTF::String&& identifier) { m_attributedBundleIdentifier = WTFMove(identifier); }
     const WTF::String& attributedBundleIdentifier() const { return m_attributedBundleIdentifier; }
 
+#if ENABLE(APP_PRIVACY_REPORT)
+    WebKit::AttributionOverrideTesting appInitiatedOverrideValueForTesting() const { return m_appInitiatedOverrideValueForTesting; }
+    void setAppInitiatedOverrideValueForTesting(WebKit::AttributionOverrideTesting appInitiatedOverrideValueForTesting) { m_appInitiatedOverrideValueForTesting = appInitiatedOverrideValueForTesting; }
+#endif
+
 private:
 
     RefPtr<WebKit::WebProcessPool> m_processPool;
@@ -221,6 +235,10 @@
 
     WebCore::ShouldRelaxThirdPartyCookieBlocking m_shouldRelaxThirdPartyCookieBlocking { WebCore::ShouldRelaxThirdPartyCookieBlocking::No };
     WTF::String m_attributedBundleIdentifier;
+
+#if ENABLE(APP_PRIVACY_REPORT)
+    WebKit::AttributionOverrideTesting m_appInitiatedOverrideValueForTesting { WebKit::AttributionOverrideTesting::NoOverride };
+#endif
 };
 
 } // namespace API

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm (279873 => 279874)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm	2021-07-13 16:33:26 UTC (rev 279873)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm	2021-07-13 16:40:12 UTC (rev 279874)
@@ -844,6 +844,35 @@
 {
     _pageConfiguration->setLimitsNavigationsToAppBoundDomains(limitsToAppBoundDomains);
 }
+
+static _WKAttributionOverrideTesting toWKAttributionOverrideTesting(WebKit::AttributionOverrideTesting value)
+{
+    if (value == WebKit::AttributionOverrideTesting::AppInitiated)
+        return _WKAttributionOverrideTestingAppInitiated;
+    if (value == WebKit::AttributionOverrideTesting::UserInitiated)
+        return _WKAttributionOverrideTestingUserInitiated;
+    return _WKAttributionOverrideTestingNoOverride;
+}
+
+static WebKit::AttributionOverrideTesting toAttributionOverrideTesting(_WKAttributionOverrideTesting value)
+{
+    if (value == _WKAttributionOverrideTestingAppInitiated)
+        return WebKit::AttributionOverrideTesting::AppInitiated;
+    if (value == _WKAttributionOverrideTestingUserInitiated)
+        return WebKit::AttributionOverrideTesting::UserInitiated;
+    return WebKit::AttributionOverrideTesting::NoOverride;
+}
+
+- (void)_setAppInitiatedOverrideValueForTesting:(_WKAttributionOverrideTesting)value
+{
+    _pageConfiguration->setAppInitiatedOverrideValueForTesting(toAttributionOverrideTesting(value));
+}
+
+- (_WKAttributionOverrideTesting)_appInitiatedOverrideValueForTesting
+{
+    return toWKAttributionOverrideTesting(_pageConfiguration->appInitiatedOverrideValueForTesting());
+}
+
 #endif // PLATFORM(IOS_FAMILY)
 
 - (BOOL)_ignoresAppBoundDomains

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h (279873 => 279874)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h	2021-07-13 16:33:26 UTC (rev 279873)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h	2021-07-13 16:40:12 UTC (rev 279874)
@@ -33,6 +33,12 @@
     _WKDragLiftDelayLong
 } WK_API_AVAILABLE(ios(11.0));
 
+typedef NS_ENUM(NSUInteger, _WKAttributionOverrideTesting) {
+    _WKAttributionOverrideTestingNoOverride = 0,
+    _WKAttributionOverrideTestingAppInitiated,
+    _WKAttributionOverrideTestingUserInitiated
+} WK_API_AVAILABLE(ios(15.0));
+
 @protocol _UIClickInteractionDriving;
 #endif
 
@@ -95,6 +101,7 @@
 @property (nonatomic, setter=_setShouldDecidePolicyBeforeLoadingQuickLookPreview:) BOOL _shouldDecidePolicyBeforeLoadingQuickLookPreview WK_API_AVAILABLE(ios(13.0));
 @property (nonatomic, setter=_setCanShowWhileLocked:) BOOL _canShowWhileLocked WK_API_AVAILABLE(ios(13.0));
 @property (nonatomic, setter=_setClickInteractionDriverForTesting:) id <_UIClickInteractionDriving> _clickInteractionDriverForTesting WK_API_AVAILABLE(ios(13.0));
+@property (nonatomic, setter=_setAppInitiatedOverrideValueForTesting:) _WKAttributionOverrideTesting _appInitiatedOverrideValueForTesting WK_API_AVAILABLE(ios(15.0));
 #else
 @property (nonatomic, setter=_setShowsURLsInToolTips:) BOOL _showsURLsInToolTips WK_API_AVAILABLE(macos(10.12));
 @property (nonatomic, setter=_setServiceControlsEnabled:) BOOL _serviceControlsEnabled WK_API_AVAILABLE(macos(10.12));

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm (279873 => 279874)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm	2021-07-13 16:33:26 UTC (rev 279873)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm	2021-07-13 16:40:12 UTC (rev 279874)
@@ -27,6 +27,7 @@
 #import "WebPageProxy.h"
 
 #import "APIAttachment.h"
+#import "APIPageConfiguration.h"
 #import "APIUIClient.h"
 #import "CocoaImage.h"
 #import "Connection.h"
@@ -663,6 +664,9 @@
 {
 #if ENABLE(APP_PRIVACY_REPORT)
     auto isAppInitiated = request.nsURLRequest(WebCore::HTTPBodyUpdatePolicy::DoNotUpdateHTTPBody).attribution == NSURLRequestAttributionDeveloper;
+    if (m_configuration->appInitiatedOverrideValueForTesting() != AttributionOverrideTesting::NoOverride)
+        isAppInitiated = m_configuration->appInitiatedOverrideValueForTesting() == AttributionOverrideTesting::AppInitiated;
+
     request.setIsAppInitiated(isAppInitiated);
     m_lastNavigationWasAppInitiated = isAppInitiated;
 #endif

Modified: trunk/Tools/ChangeLog (279873 => 279874)


--- trunk/Tools/ChangeLog	2021-07-13 16:33:26 UTC (rev 279873)
+++ trunk/Tools/ChangeLog	2021-07-13 16:40:12 UTC (rev 279874)
@@ -1,3 +1,22 @@
+2021-07-13  Kate Cheney  <katherine_che...@apple.com>
+
+        Allow layout tests to specify app initiated loads or not
+        https://bugs.webkit.org/show_bug.cgi?id=227825
+        <rdar://problem/80355582>
+
+        Reviewed by Brent Fulgham.
+
+        Add a test option that specifies whether the test should mark the
+        main page navigation as app-initiated or not.
+
+        * WebKitTestRunner/TestOptions.cpp:
+        (WTR::TestOptions::defaults):
+        (WTR::TestOptions::keyTypeMapping):
+        * WebKitTestRunner/TestOptions.h:
+        (WTR::TestOptions::isAppInitiated const):
+        * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
+        (WTR::TestController::platformCreateWebView):
+
 2021-07-13  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [GTK][WPE] Expose support for client certificate auth

Modified: trunk/Tools/WebKitTestRunner/TestOptions.cpp (279873 => 279874)


--- trunk/Tools/WebKitTestRunner/TestOptions.cpp	2021-07-13 16:33:26 UTC (rev 279873)
+++ trunk/Tools/WebKitTestRunner/TestOptions.cpp	2021-07-13 16:40:12 UTC (rev 279874)
@@ -143,6 +143,7 @@
             { "ignoreSynchronousMessagingTimeouts", false },
             { "ignoresViewportScaleLimits", false },
             { "isAppBoundWebView", false },
+            { "isAppInitiated", true },
             { "runSingly", false },
             { "shouldHandleRunOpenPanel", true },
             { "shouldPresentPopovers", true },
@@ -196,6 +197,7 @@
         { "ignoreSynchronousMessagingTimeouts", TestHeaderKeyType::BoolTestRunner },
         { "ignoresViewportScaleLimits", TestHeaderKeyType::BoolTestRunner },
         { "isAppBoundWebView", TestHeaderKeyType::BoolTestRunner },
+        { "isAppInitiated", TestHeaderKeyType::BoolTestRunner },
         { "runSingly", TestHeaderKeyType::BoolTestRunner },
         { "shouldHandleRunOpenPanel", TestHeaderKeyType::BoolTestRunner },
         { "shouldPresentPopovers", TestHeaderKeyType::BoolTestRunner },

Modified: trunk/Tools/WebKitTestRunner/TestOptions.h (279873 => 279874)


--- trunk/Tools/WebKitTestRunner/TestOptions.h	2021-07-13 16:33:26 UTC (rev 279873)
+++ trunk/Tools/WebKitTestRunner/TestOptions.h	2021-07-13 16:40:12 UTC (rev 279874)
@@ -59,6 +59,7 @@
     bool ignoreSynchronousMessagingTimeouts() const { return boolTestRunnerFeatureValue("ignoreSynchronousMessagingTimeouts"); }
     bool ignoresViewportScaleLimits() const { return boolTestRunnerFeatureValue("ignoresViewportScaleLimits"); }
     bool isAppBoundWebView() const { return boolTestRunnerFeatureValue("isAppBoundWebView"); }
+    bool isAppInitiated() const { return boolTestRunnerFeatureValue("isAppInitiated"); }
     bool runSingly() const { return boolTestRunnerFeatureValue("runSingly"); }
     bool shouldHandleRunOpenPanel() const { return boolTestRunnerFeatureValue("shouldHandleRunOpenPanel"); }
     bool shouldPresentPopovers() const { return boolTestRunnerFeatureValue("shouldPresentPopovers"); }

Modified: trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm (279873 => 279874)


--- trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm	2021-07-13 16:33:26 UTC (rev 279873)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm	2021-07-13 16:40:12 UTC (rev 279874)
@@ -169,6 +169,8 @@
         [copiedConfiguration setSelectionGranularity:WKSelectionGranularityCharacter];
     if (options.isAppBoundWebView())
         [copiedConfiguration setLimitsNavigationsToAppBoundDomains:YES];
+
+    [copiedConfiguration _setAppInitiatedOverrideValueForTesting:options.isAppInitiated() ? _WKAttributionOverrideTestingAppInitiated : _WKAttributionOverrideTestingUserInitiated];
 #endif
 
     if (options.enableAttachmentElement())
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to