<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[277301] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/277301">277301</a></dd>
<dt>Author</dt> <dd>katherine_cheney@apple.com</dd>
<dt>Date</dt> <dd>2021-05-10 15:41:30 -0700 (Mon, 10 May 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Preflight requests not properly attributed as app-bound
https://bugs.webkit.org/show_bug.cgi?id=225596
<rdar://problem/77664272>

Reviewed by Brent Fulgham.

Source/WebCore:

Tests: http/tests/in-app-browser-privacy/app-bound-attribution-preflight-async.html
       http/tests/in-app-browser-privacy/app-bound-attribution-preflight-sync.html

A preflight request initiated by a main navigation that was app-bound
should also be app-bound. Testing sync preflight requests revealed
that we also need to mark this when loading a synchronous resource.

* loader/CrossOriginAccessControl.cpp:
(WebCore::createAccessControlPreflightRequest):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadResourceSynchronously):

Source/WebKit:

Testing SPI to request load data to check if preflight requests
were properly marked.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _didLoadAppBoundRequest:]):
(-[WKWebView _didLoadNonAppBoundRequest:]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:

Tools:

Add test infrastructure.

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::didLoadAppBoundRequest):
(WTR::TestRunner::didLoadNonAppBoundRequest):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::didLoadAppBoundRequest):
(WTR::TestController::didLoadNonAppBoundRequest):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::TestController::didLoadAppBoundRequest):
(WTR::TestController::didLoadNonAppBoundRequest):
* WebKitTestRunner/cocoa/TestRunnerWKWebView.h:
* WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
(-[TestRunnerWKWebView _didLoadAppBoundRequest:]):
(-[TestRunnerWKWebView _didLoadNonAppBoundRequest:]):

LayoutTests:

Add two tests for sync and async preflight requests.

* http/tests/in-app-browser-privacy/app-bound-attribution-preflight-async-expected.txt: Added.
* http/tests/in-app-browser-privacy/app-bound-attribution-preflight-async.html: Added.
* http/tests/in-app-browser-privacy/app-bound-attribution-preflight-sync-expected.txt: Added.
* http/tests/in-app-browser-privacy/app-bound-attribution-preflight-sync.html: Added.
* platform/ios-wk2/TestExpectations:
These tests rely on internal additions, we should skip them in open
source expectations.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformioswk2TestExpectations">trunk/LayoutTests/platform/ios-wk2/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreloaderCrossOriginAccessControlcpp">trunk/Source/WebCore/loader/CrossOriginAccessControl.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderFrameLoadercpp">trunk/Source/WebCore/loader/FrameLoader.cpp</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoaWKWebViewPrivateh">trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundleBindingsTestRunneridl">trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundleTestRunnercpp">trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundleTestRunnerh">trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h</a></li>
<li><a href="#trunkToolsWebKitTestRunnerTestControllercpp">trunk/Tools/WebKitTestRunner/TestController.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnerTestControllerh">trunk/Tools/WebKitTestRunner/TestController.h</a></li>
<li><a href="#trunkToolsWebKitTestRunnerTestInvocationcpp">trunk/Tools/WebKitTestRunner/TestInvocation.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnercocoaTestControllerCocoamm">trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm</a></li>
<li><a href="#trunkToolsWebKitTestRunnercocoaTestRunnerWKWebViewh">trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h</a></li>
<li><a href="#trunkToolsWebKitTestRunnercocoaTestRunnerWKWebViewmm">trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestshttptestsinappbrowserprivacyappboundattributionpreflightasyncexpectedtxt">trunk/LayoutTests/http/tests/in-app-browser-privacy/app-bound-attribution-preflight-async-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestsinappbrowserprivacyappboundattributionpreflightasynchtml">trunk/LayoutTests/http/tests/in-app-browser-privacy/app-bound-attribution-preflight-async.html</a></li>
<li><a href="#trunkLayoutTestshttptestsinappbrowserprivacyappboundattributionpreflightsyncexpectedtxt">trunk/LayoutTests/http/tests/in-app-browser-privacy/app-bound-attribution-preflight-sync-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestsinappbrowserprivacyappboundattributionpreflightsynchtml">trunk/LayoutTests/http/tests/in-app-browser-privacy/app-bound-attribution-preflight-sync.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (277300 => 277301)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2021-05-10 22:34:09 UTC (rev 277300)
+++ trunk/LayoutTests/ChangeLog 2021-05-10 22:41:30 UTC (rev 277301)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2021-05-10  Kate Cheney  <katherine_cheney@apple.com>
+
+        Preflight requests not properly attributed as app-bound
+        https://bugs.webkit.org/show_bug.cgi?id=225596
+        <rdar://problem/77664272>
+
+        Reviewed by Brent Fulgham.
+
+        Add two tests for sync and async preflight requests.
+
+        * http/tests/in-app-browser-privacy/app-bound-attribution-preflight-async-expected.txt: Added.
+        * http/tests/in-app-browser-privacy/app-bound-attribution-preflight-async.html: Added.
+        * http/tests/in-app-browser-privacy/app-bound-attribution-preflight-sync-expected.txt: Added.
+        * http/tests/in-app-browser-privacy/app-bound-attribution-preflight-sync.html: Added.
+        * platform/ios-wk2/TestExpectations:
+        These tests rely on internal additions, we should skip them in open
+        source expectations.
+
</ins><span class="cx"> 2021-05-10  Robert Jenner  <jenner@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [ BigSur ARM64] http/wpt/fetch/fetch-response-body-stop-in-worker.html is a flaky crash
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsinappbrowserprivacyappboundattributionpreflightasyncexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/in-app-browser-privacy/app-bound-attribution-preflight-async-expected.txt (0 => 277301)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/in-app-browser-privacy/app-bound-attribution-preflight-async-expected.txt                           (rev 0)
+++ trunk/LayoutTests/http/tests/in-app-browser-privacy/app-bound-attribution-preflight-async-expected.txt      2021-05-10 22:41:30 UTC (rev 277301)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+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 bound requests get marked for async preflights
+
+PASS successfully loaded only app-bound requests
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsinappbrowserprivacyappboundattributionpreflightasynchtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/in-app-browser-privacy/app-bound-attribution-preflight-async.html (0 => 277301)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/in-app-browser-privacy/app-bound-attribution-preflight-async.html                           (rev 0)
+++ trunk/LayoutTests/http/tests/in-app-browser-privacy/app-bound-attribution-preflight-async.html      2021-05-10 22:41:30 UTC (rev 277301)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+<p>Tests app bound 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 = "http://localhost:8000/xmlhttprequest/resources/status-404-without-body.py"
+
+function runTest()
+{
+    var req = new XMLHttpRequest();
+    req.open("GET", url, true);
+    req.setRequestHeader("x-webkit", "foo");
+
+    req.onerror = function() {
+        var didLoadAppBoundRequest = testRunner.didLoadAppBoundRequest();
+        var didLoadNonAppBoundRequest = testRunner.didLoadNonAppBoundRequest();
+
+        if (didLoadNonAppBoundRequest) {
+            log("FAIL did load non app-bound request");
+            testRunner.notifyDone();
+        }
+
+        if (!didLoadAppBoundRequest) {
+            log("FAIL did not load app-bound request");
+            testRunner.notifyDone();
+        }
+
+        log("PASS successfully loaded only app-bound requests");
+        testRunner.notifyDone();
+    }
+    req.send(null);
+}
+
+runTest();
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsinappbrowserprivacyappboundattributionpreflightsyncexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/in-app-browser-privacy/app-bound-attribution-preflight-sync-expected.txt (0 => 277301)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/in-app-browser-privacy/app-bound-attribution-preflight-sync-expected.txt                            (rev 0)
+++ trunk/LayoutTests/http/tests/in-app-browser-privacy/app-bound-attribution-preflight-sync-expected.txt       2021-05-10 22:41:30 UTC (rev 277301)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+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 bound requests get marked for sync preflights
+
+PASS: NetworkError:  A network error occurred.
+PASS successfully loaded only app-bound requests
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsinappbrowserprivacyappboundattributionpreflightsynchtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/in-app-browser-privacy/app-bound-attribution-preflight-sync.html (0 => 277301)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/in-app-browser-privacy/app-bound-attribution-preflight-sync.html                            (rev 0)
+++ trunk/LayoutTests/http/tests/in-app-browser-privacy/app-bound-attribution-preflight-sync.html       2021-05-10 22:41:30 UTC (rev 277301)
</span><span class="lines">@@ -0,0 +1,49 @@
</span><ins>+<p>Tests app bound 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 = "http://localhost:8000/xmlhttprequest/resources/status-404-without-body.py"
+
+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 didLoadAppBoundRequest = testRunner.didLoadAppBoundRequest();
+        var didLoadNonAppBoundRequest = testRunner.didLoadNonAppBoundRequest();
+
+        if (didLoadNonAppBoundRequest) {
+            log("FAIL did load non app-bound request");
+            testRunner.notifyDone();
+        }
+
+        if (!didLoadAppBoundRequest) {
+            log("FAIL did not load app-bound request");
+            testRunner.notifyDone();
+        }
+
+        log("PASS successfully loaded only app-bound requests");
+        testRunner.notifyDone();
+    }
+}
+
+runTest();
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformioswk2TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios-wk2/TestExpectations (277300 => 277301)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-wk2/TestExpectations      2021-05-10 22:34:09 UTC (rev 277300)
+++ trunk/LayoutTests/platform/ios-wk2/TestExpectations 2021-05-10 22:41:30 UTC (rev 277301)
</span><span class="lines">@@ -1791,6 +1791,8 @@
</span><span class="cx"> http/tests/in-app-browser-privacy/context-string-for-subframe.html [ Skip ]
</span><span class="cx"> http/tests/in-app-browser-privacy/context-string-preconnect.html [ Skip ]
</span><span class="cx"> http/tests/in-app-browser-privacy/context-string-preflight.html [ Skip ]
</span><ins>+http/tests/in-app-browser-privacy/app-bound-attribution-preflight-async.html [ Skip ]
+http/tests/in-app-browser-privacy/app-bound-attribution-preflight-sync.html [ Skip ]
</ins><span class="cx"> 
</span><span class="cx"> webkit.org/b/175193 fast/images/async-image-body-background-image.html [ Pass Timeout ]
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (277300 => 277301)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-05-10 22:34:09 UTC (rev 277300)
+++ trunk/Source/WebCore/ChangeLog      2021-05-10 22:41:30 UTC (rev 277301)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2021-05-10  Kate Cheney  <katherine_cheney@apple.com>
+
+        Preflight requests not properly attributed as app-bound
+        https://bugs.webkit.org/show_bug.cgi?id=225596
+        <rdar://problem/77664272>
+
+        Reviewed by Brent Fulgham.
+
+        Tests: http/tests/in-app-browser-privacy/app-bound-attribution-preflight-async.html
+               http/tests/in-app-browser-privacy/app-bound-attribution-preflight-sync.html
+
+        A preflight request initiated by a main navigation that was app-bound
+        should also be app-bound. Testing sync preflight requests revealed
+        that we also need to mark this when loading a synchronous resource.
+
+        * loader/CrossOriginAccessControl.cpp:
+        (WebCore::createAccessControlPreflightRequest):
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::loadResourceSynchronously):
+
</ins><span class="cx"> 2021-05-10  Commit Queue  <commit-queue@webkit.org>
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, reverting r277222.
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderCrossOriginAccessControlcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/CrossOriginAccessControl.cpp (277300 => 277301)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/CrossOriginAccessControl.cpp 2021-05-10 22:34:09 UTC (rev 277300)
+++ trunk/Source/WebCore/loader/CrossOriginAccessControl.cpp    2021-05-10 22:41:30 UTC (rev 277301)
</span><span class="lines">@@ -89,6 +89,7 @@
</span><span class="cx">     preflightRequest.setHTTPHeaderField(HTTPHeaderName::AccessControlRequestMethod, request.httpMethod());
</span><span class="cx">     preflightRequest.setPriority(request.priority());
</span><span class="cx">     preflightRequest.setFirstPartyForCookies(request.firstPartyForCookies());
</span><ins>+    preflightRequest.setIsAppBound(request.isAppBound());
</ins><span class="cx">     if (!referrer.isNull())
</span><span class="cx">         preflightRequest.setHTTPReferrer(referrer);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderFrameLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (277300 => 277301)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/FrameLoader.cpp      2021-05-10 22:34:09 UTC (rev 277300)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2021-05-10 22:41:30 UTC (rev 277301)
</span><span class="lines">@@ -3110,7 +3110,10 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     m_frame.document()->contentSecurityPolicy()->upgradeInsecureRequestIfNeeded(newRequest, ContentSecurityPolicy::InsecureRequestType::Load);
</span><del>-    
</del><ins>+
+    if (m_documentLoader)
+        newRequest.setIsAppBound(m_documentLoader->lastNavigationWasAppBound());
+
</ins><span class="cx">     if (error.isNull()) {
</span><span class="cx">         ASSERT(!newRequest.isNull());
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (277300 => 277301)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2021-05-10 22:34:09 UTC (rev 277300)
+++ trunk/Source/WebKit/ChangeLog       2021-05-10 22:41:30 UTC (rev 277301)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2021-05-10  Kate Cheney  <katherine_cheney@apple.com>
+
+        Preflight requests not properly attributed as app-bound
+        https://bugs.webkit.org/show_bug.cgi?id=225596
+        <rdar://problem/77664272>
+
+        Reviewed by Brent Fulgham.
+
+        Testing SPI to request load data to check if preflight requests
+        were properly marked.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _didLoadAppBoundRequest:]):
+        (-[WKWebView _didLoadNonAppBoundRequest:]):
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+
</ins><span class="cx"> 2021-05-10  Wenson Hsieh  <wenson_hsieh@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Make WebCore::HitTestRequest::RequestType an enum class
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (277300 => 277301)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm     2021-05-10 22:34:09 UTC (rev 277300)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm        2021-05-10 22:41:30 UTC (rev 277301)
</span><span class="lines">@@ -2285,6 +2285,20 @@
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)_didLoadAppBoundRequest:(void (^)(BOOL result))completionHandler
+{
+    _page->appBoundNavigationData([completionHandler = makeBlockPtr(completionHandler)] (auto&& appBoundData) mutable {
+        completionHandler(appBoundData.hasLoadedAppBoundRequestTesting);
+    });
+}
+
+- (void)_didLoadNonAppBoundRequest:(void (^)(BOOL result))completionHandler
+{
+    _page->appBoundNavigationData([completionHandler = makeBlockPtr(completionHandler)] (auto&& appBoundData) mutable {
+        completionHandler(appBoundData.hasLoadedNonAppBoundRequestTesting);
+    });
+}
+
</ins><span class="cx"> - (NSArray *)_certificateChain
</span><span class="cx"> {
</span><span class="cx">     if (WebKit::WebFrameProxy* mainFrame = _page->mainFrame())
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoaWKWebViewPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h (277300 => 277301)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h       2021-05-10 22:34:09 UTC (rev 277300)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h  2021-05-10 22:41:30 UTC (rev 277301)
</span><span class="lines">@@ -407,6 +407,8 @@
</span><span class="cx"> - (void)_switchFromStaticFontRegistryToUserFontRegistry WK_API_AVAILABLE(macos(WK_MAC_TBA));
</span><span class="cx"> 
</span><span class="cx"> - (void)_appBoundNavigationDataForDomain:(NSString *)domain completionHandler:(void (^)(NSString * context))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
</span><ins>+- (void)_didLoadAppBoundRequest:(void (^)(BOOL result))completionHandler;
+- (void)_didLoadNonAppBoundRequest:(void (^)(BOOL result))completionHandler;
</ins><span class="cx"> 
</span><span class="cx"> @end
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (277300 => 277301)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2021-05-10 22:34:09 UTC (rev 277300)
+++ trunk/Tools/ChangeLog       2021-05-10 22:41:30 UTC (rev 277301)
</span><span class="lines">@@ -1,3 +1,32 @@
</span><ins>+2021-05-10  Kate Cheney  <katherine_cheney@apple.com>
+
+        Preflight requests not properly attributed as app-bound
+        https://bugs.webkit.org/show_bug.cgi?id=225596
+        <rdar://problem/77664272>
+
+        Reviewed by Brent Fulgham.
+
+        Add test infrastructure.
+
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::didLoadAppBoundRequest):
+        (WTR::TestRunner::didLoadNonAppBoundRequest):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::didLoadAppBoundRequest):
+        (WTR::TestController::didLoadNonAppBoundRequest):
+        * WebKitTestRunner/TestController.h:
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+        * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
+        (WTR::TestController::didLoadAppBoundRequest):
+        (WTR::TestController::didLoadNonAppBoundRequest):
+        * WebKitTestRunner/cocoa/TestRunnerWKWebView.h:
+        * WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
+        (-[TestRunnerWKWebView _didLoadAppBoundRequest:]):
+        (-[TestRunnerWKWebView _didLoadNonAppBoundRequest:]):
+
</ins><span class="cx"> 2021-05-10  Chris Dumez  <cdumez@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [iOS] Pages with service workers do not suspend promptly
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleBindingsTestRunneridl"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (277300 => 277301)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl      2021-05-10 22:34:09 UTC (rev 277300)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl 2021-05-10 22:41:30 UTC (rev 277301)
</span><span class="lines">@@ -389,6 +389,8 @@
</span><span class="cx">     undefined clearAppBoundSession();
</span><span class="cx">     undefined setAppBoundDomains(object originsArray, object callback);
</span><span class="cx">     undefined appBoundRequestContextDataForDomain(DOMString domain, object callback);
</span><ins>+    boolean didLoadAppBoundRequest();
+    boolean didLoadNonAppBoundRequest();
</ins><span class="cx"> 
</span><span class="cx">     undefined injectUserScript(DOMString string);
</span><span class="cx">     readonly attribute unsigned long userScriptInjectedCount;
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleTestRunnercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (277300 => 277301)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp       2021-05-10 22:34:09 UTC (rev 277300)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp  2021-05-10 22:41:30 UTC (rev 277301)
</span><span class="lines">@@ -2128,6 +2128,16 @@
</span><span class="cx">     callTestRunnerCallback(AppBoundRequestContextDataForDomainCallbackID, 1, &resultValue);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool TestRunner::didLoadAppBoundRequest()
+{
+    return postSynchronousPageMessageReturningBoolean("DidLoadAppBoundRequest");
+}
+
+bool TestRunner::didLoadNonAppBoundRequest()
+{
+    return postSynchronousPageMessageReturningBoolean("DidLoadNonAppBoundRequest");
+}
+
</ins><span class="cx"> void TestRunner::setIsSpeechRecognitionPermissionGranted(bool granted)
</span><span class="cx"> {
</span><span class="cx">     postSynchronousPageMessage("SetIsSpeechRecognitionPermissionGranted", granted);
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleTestRunnerh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (277300 => 277301)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h 2021-05-10 22:34:09 UTC (rev 277300)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h    2021-05-10 22:41:30 UTC (rev 277301)
</span><span class="lines">@@ -499,6 +499,8 @@
</span><span class="cx">     void didSetAppBoundDomainsCallback();
</span><span class="cx">     void appBoundRequestContextDataForDomain(JSStringRef, JSValueRef);
</span><span class="cx">     void callDidReceiveAppBoundRequestContextDataForDomainCallback(String&&);
</span><ins>+    bool didLoadAppBoundRequest();
+    bool didLoadNonAppBoundRequest();
</ins><span class="cx"> 
</span><span class="cx">     size_t userScriptInjectedCount() const;
</span><span class="cx">     void injectUserScript(JSStringRef);
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerTestControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (277300 => 277301)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/TestController.cpp  2021-05-10 22:34:09 UTC (rev 277300)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp     2021-05-10 22:41:30 UTC (rev 277301)
</span><span class="lines">@@ -2684,6 +2684,16 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool TestController::didLoadAppBoundRequest()
+{
+    return false;
+}
+
+bool TestController::didLoadNonAppBoundRequest()
+{
+    return false;
+}
+
</ins><span class="cx"> void TestController::clearAppBoundNavigationData()
</span><span class="cx"> {
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerTestControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/TestController.h (277300 => 277301)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/TestController.h    2021-05-10 22:34:09 UTC (rev 277300)
+++ trunk/Tools/WebKitTestRunner/TestController.h       2021-05-10 22:41:30 UTC (rev 277301)
</span><span class="lines">@@ -264,6 +264,8 @@
</span><span class="cx">     void reinitializeAppBoundDomains();
</span><span class="cx">     void appBoundRequestContextDataForDomain(WKStringRef);
</span><span class="cx">     void clearAppBoundNavigationData();
</span><ins>+    bool didLoadAppBoundRequest();
+    bool didLoadNonAppBoundRequest();
</ins><span class="cx"> 
</span><span class="cx">     void updateBundleIdentifierInNetworkProcess(const std::string& bundleIdentifier);
</span><span class="cx">     void clearBundleIdentifierInNetworkProcess();
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerTestInvocationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (277300 => 277301)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp  2021-05-10 22:34:09 UTC (rev 277300)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp     2021-05-10 22:41:30 UTC (rev 277301)
</span><span class="lines">@@ -1070,7 +1070,13 @@
</span><span class="cx">         bool statisticInDatabaseOnce = TestController::singleton().isStatisticsOnlyInDatabaseOnce(subHost, topHost);
</span><span class="cx">         return adoptWK(WKBooleanCreate(statisticInDatabaseOnce));
</span><span class="cx">     }
</span><del>-    
</del><ins>+
+    if (WKStringIsEqualToUTF8CString(messageName, "DidLoadAppBoundRequest"))
+        return adoptWK(WKBooleanCreate(TestController::singleton().didLoadAppBoundRequest()));
+
+    if (WKStringIsEqualToUTF8CString(messageName, "DidLoadNonAppBoundRequest"))
+        return adoptWK(WKBooleanCreate(TestController::singleton().didLoadNonAppBoundRequest()));
+
</ins><span class="cx">     if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsGrandfathered")) {
</span><span class="cx">         auto messageBodyDictionary = dictionaryValue(messageBody);
</span><span class="cx">         auto hostName = stringValue(messageBodyDictionary, "HostName");
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnercocoaTestControllerCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm (277300 => 277301)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm        2021-05-10 22:34:09 UTC (rev 277300)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm   2021-05-10 22:41:30 UTC (rev 277301)
</span><span class="lines">@@ -400,6 +400,38 @@
</span><span class="cx">     }];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool TestController::didLoadAppBoundRequest()
+{
+    auto* parentView = mainWebView();
+    if (!parentView)
+        return false;
+
+    __block bool isDone = false;
+    __block bool didLoadResult = false;
+    [m_mainWebView->platformView() _didLoadAppBoundRequest:^(BOOL result) {
+        didLoadResult = result;
+        isDone = true;
+    }];
+    platformRunUntil(isDone, noTimeout);
+    return didLoadResult;
+}
+
+bool TestController::didLoadNonAppBoundRequest()
+{
+    auto* parentView = mainWebView();
+    if (!parentView)
+        return false;
+
+    __block bool isDone = false;
+    __block bool didLoadResult = false;
+    [m_mainWebView->platformView() _didLoadNonAppBoundRequest:^(BOOL result) {
+        didLoadResult = result;
+        isDone = true;
+    }];
+    platformRunUntil(isDone, noTimeout);
+    return didLoadResult;
+}
+
</ins><span class="cx"> void TestController::clearAppBoundNavigationData()
</span><span class="cx"> {
</span><span class="cx">     auto* parentView = mainWebView();
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnercocoaTestRunnerWKWebViewh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h (277300 => 277301)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h 2021-05-10 22:34:09 UTC (rev 277300)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h    2021-05-10 22:41:30 UTC (rev 277301)
</span><span class="lines">@@ -83,5 +83,7 @@
</span><span class="cx"> - (void)dismissActiveMenu;
</span><span class="cx"> - (void)resetInteractionCallbacks;
</span><span class="cx"> - (void)_appBoundNavigationDataForDomain:(NSString *)domain completionHandler:(void (^)(NSString * context))completionHandler;
</span><ins>+- (void)_didLoadAppBoundRequest:(void (^)(BOOL result))completionHandler;
+- (void)_didLoadNonAppBoundRequest:(void (^)(BOOL result))completionHandler;
</ins><span class="cx"> 
</span><span class="cx"> @end
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnercocoaTestRunnerWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm (277300 => 277301)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm        2021-05-10 22:34:09 UTC (rev 277300)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm   2021-05-10 22:41:30 UTC (rev 277301)
</span><span class="lines">@@ -602,4 +602,14 @@
</span><span class="cx">     [super _appBoundNavigationDataForDomain:domain completionHandler:completionHandler];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)_didLoadAppBoundRequest:(void (^)(BOOL result))completionHandler
+{
+    [super _didLoadAppBoundRequest:completionHandler];
+}
+
+- (void)_didLoadNonAppBoundRequest:(void (^)(BOOL result))completionHandler
+{
+    [super _didLoadNonAppBoundRequest:completionHandler];
+}
+
</ins><span class="cx"> @end
</span></span></pre>
</div>
</div>

</body>
</html>