<!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>[283767] branches/safari-612-branch</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/283767">283767</a></dd>
<dt>Author</dt> <dd>repstein@apple.com</dd>
<dt>Date</dt> <dd>2021-10-07 19:01:12 -0700 (Thu, 07 Oct 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Cherry-pick <a href="http://trac.webkit.org/projects/webkit/changeset/281349">r281349</a>. rdar://problem/83957360

    Make UIEventAttribution tests less platform dependent
    https://bugs.webkit.org/show_bug.cgi?id=229323

    Reviewed by John Wilander.

    Source/WebKit:

    This allows me to run the UIEventAttribution tests on macOS.
    It also makes them not time out, which they were doing since <a href="http://trac.webkit.org/projects/webkit/changeset/277447">r277447</a>.
    To accomplish this, I added more test SPI to prevent the network process
    suspension message, which was causing the test to time out on the iOS simulator.

    * UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h:
    * UIProcess/API/Cocoa/WKWebViewTesting.mm:
    (-[WKWebView _addEventAttributionWithSourceID:destinationURL:sourceDescription:purchaser:reportEndpoint:optionalNonce:]):
    * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
    (+[WKWebsiteDataStore _preventNetworkProcessSuspensionForTesting]):
    * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
    * UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h:
    * UIProcess/API/ios/WKWebViewTestingIOS.mm:
    (-[WKWebView _setUIEventAttributionForTesting:withNonce:]): Deleted.
    * UIProcess/Network/NetworkProcessProxy.cpp:
    (WebKit::NetworkProcessProxy::preventSuspensionForTesting):
    (WebKit::NetworkProcessProxy::sendPrepareToSuspend):
    * UIProcess/Network/NetworkProcessProxy.h:

    Tools:

    * TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm:
    (TestWebKitAPI::exampleURL):
    (TestWebKitAPI::runBasicEventAttributionTest):
    (TestWebKitAPI::TEST):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281349 268f45cc-cd09-0410-ab3c-d52691b4dbfc</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari612branchSourceWebKitChangeLog">branches/safari-612-branch/Source/WebKit/ChangeLog</a></li>
<li><a href="#branchessafari612branchSourceWebKitUIProcessAPICocoaWKWebViewPrivateForTestingh">branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h</a></li>
<li><a href="#branchessafari612branchSourceWebKitUIProcessAPICocoaWKWebViewTestingmm">branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebViewTesting.mm</a></li>
<li><a href="#branchessafari612branchSourceWebKitUIProcessAPICocoaWKWebsiteDataStoremm">branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm</a></li>
<li><a href="#branchessafari612branchSourceWebKitUIProcessAPICocoaWKWebsiteDataStorePrivateh">branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h</a></li>
<li><a href="#branchessafari612branchSourceWebKitUIProcessAPIiosWKWebViewPrivateForTestingIOSh">branches/safari-612-branch/Source/WebKit/UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h</a></li>
<li><a href="#branchessafari612branchSourceWebKitUIProcessAPIiosWKWebViewTestingIOSmm">branches/safari-612-branch/Source/WebKit/UIProcess/API/ios/WKWebViewTestingIOS.mm</a></li>
<li><a href="#branchessafari612branchSourceWebKitUIProcessNetworkNetworkProcessProxycpp">branches/safari-612-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp</a></li>
<li><a href="#branchessafari612branchSourceWebKitUIProcessNetworkNetworkProcessProxyh">branches/safari-612-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h</a></li>
<li><a href="#branchessafari612branchToolsChangeLog">branches/safari-612-branch/Tools/ChangeLog</a></li>
<li><a href="#branchessafari612branchToolsTestWebKitAPITestsWebKitCocoaEventAttributionmm">branches/safari-612-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari612branchSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebKit/ChangeLog (283766 => 283767)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebKit/ChangeLog       2021-10-08 01:43:55 UTC (rev 283766)
+++ branches/safari-612-branch/Source/WebKit/ChangeLog  2021-10-08 02:01:12 UTC (rev 283767)
</span><span class="lines">@@ -1,3 +1,70 @@
</span><ins>+2021-10-07  Alan Coon  <alancoon@apple.com>
+
+        Cherry-pick r281349. rdar://problem/83957360
+
+    Make UIEventAttribution tests less platform dependent
+    https://bugs.webkit.org/show_bug.cgi?id=229323
+    
+    Reviewed by John Wilander.
+    
+    Source/WebKit:
+    
+    This allows me to run the UIEventAttribution tests on macOS.
+    It also makes them not time out, which they were doing since r277447.
+    To accomplish this, I added more test SPI to prevent the network process
+    suspension message, which was causing the test to time out on the iOS simulator.
+    
+    * UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h:
+    * UIProcess/API/Cocoa/WKWebViewTesting.mm:
+    (-[WKWebView _addEventAttributionWithSourceID:destinationURL:sourceDescription:purchaser:reportEndpoint:optionalNonce:]):
+    * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
+    (+[WKWebsiteDataStore _preventNetworkProcessSuspensionForTesting]):
+    * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
+    * UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h:
+    * UIProcess/API/ios/WKWebViewTestingIOS.mm:
+    (-[WKWebView _setUIEventAttributionForTesting:withNonce:]): Deleted.
+    * UIProcess/Network/NetworkProcessProxy.cpp:
+    (WebKit::NetworkProcessProxy::preventSuspensionForTesting):
+    (WebKit::NetworkProcessProxy::sendPrepareToSuspend):
+    * UIProcess/Network/NetworkProcessProxy.h:
+    
+    Tools:
+    
+    * TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm:
+    (TestWebKitAPI::exampleURL):
+    (TestWebKitAPI::runBasicEventAttributionTest):
+    (TestWebKitAPI::TEST):
+    
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281349 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-08-20  Alex Christensen  <achristensen@webkit.org>
+
+            Make UIEventAttribution tests less platform dependent
+            https://bugs.webkit.org/show_bug.cgi?id=229323
+
+            Reviewed by John Wilander.
+
+            This allows me to run the UIEventAttribution tests on macOS.
+            It also makes them not time out, which they were doing since r277447.
+            To accomplish this, I added more test SPI to prevent the network process
+            suspension message, which was causing the test to time out on the iOS simulator.
+
+            * UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h:
+            * UIProcess/API/Cocoa/WKWebViewTesting.mm:
+            (-[WKWebView _addEventAttributionWithSourceID:destinationURL:sourceDescription:purchaser:reportEndpoint:optionalNonce:]):
+            * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
+            (+[WKWebsiteDataStore _preventNetworkProcessSuspensionForTesting]):
+            * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
+            * UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h:
+            * UIProcess/API/ios/WKWebViewTestingIOS.mm:
+            (-[WKWebView _setUIEventAttributionForTesting:withNonce:]): Deleted.
+            * UIProcess/Network/NetworkProcessProxy.cpp:
+            (WebKit::NetworkProcessProxy::preventSuspensionForTesting):
+            (WebKit::NetworkProcessProxy::sendPrepareToSuspend):
+            * UIProcess/Network/NetworkProcessProxy.h:
+
</ins><span class="cx"> 2021-10-06  Russell Epstein  <repstein@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Cherry-pick r283490. rdar://problem/83954408
</span></span></pre></div>
<a id="branchessafari612branchSourceWebKitUIProcessAPICocoaWKWebViewPrivateForTestingh"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h (283766 => 283767)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h        2021-10-08 01:43:55 UTC (rev 283766)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h   2021-10-08 02:01:12 UTC (rev 283767)
</span><span class="lines">@@ -44,6 +44,8 @@
</span><span class="cx"> 
</span><span class="cx"> @interface WKWebView (WKTesting)
</span><span class="cx"> 
</span><ins>+- (void)_addEventAttributionWithSourceID:(uint8_t)sourceID destinationURL:(NSURL *)destination sourceDescription:(NSString *)sourceDescription purchaser:(NSString *)purchaser reportEndpoint:(NSURL *)reportEndpoint optionalNonce:(nullable NSString *)nonce WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+
</ins><span class="cx"> - (void)_setPageScale:(CGFloat)scale withOrigin:(CGPoint)origin;
</span><span class="cx"> - (CGFloat)_pageScale;
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari612branchSourceWebKitUIProcessAPICocoaWKWebViewTestingmm"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebViewTesting.mm (283766 => 283767)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebViewTesting.mm 2021-10-08 01:43:55 UTC (rev 283766)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebViewTesting.mm    2021-10-08 02:01:12 UTC (rev 283767)
</span><span class="lines">@@ -55,6 +55,21 @@
</span><span class="cx"> 
</span><span class="cx"> @implementation WKWebView (WKTesting)
</span><span class="cx"> 
</span><ins>+- (void)_addEventAttributionWithSourceID:(uint8_t)sourceID destinationURL:(NSURL *)destination sourceDescription:(NSString *)sourceDescription purchaser:(NSString *)purchaser reportEndpoint:(NSURL *)reportEndpoint optionalNonce:(NSString *)nonce
+{
+    WebCore::PrivateClickMeasurement measurement(
+        WebCore::PrivateClickMeasurement::SourceID(sourceID),
+        WebCore::PrivateClickMeasurement::SourceSite(reportEndpoint),
+        WebCore::PrivateClickMeasurement::AttributionDestinationSite(destination),
+        sourceDescription,
+        purchaser
+    );
+    if (nonce)
+        measurement.setEphemeralSourceNonce({ nonce });
+
+    _page->setPrivateClickMeasurement(WTFMove(measurement));
+}
+
</ins><span class="cx"> - (void)_setPageScale:(CGFloat)scale withOrigin:(CGPoint)origin
</span><span class="cx"> {
</span><span class="cx">     _page->scalePage(scale, WebCore::roundedIntPoint(origin));
</span></span></pre></div>
<a id="branchessafari612branchSourceWebKitUIProcessAPICocoaWKWebsiteDataStoremm"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm (283766 => 283767)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm       2021-10-08 01:43:55 UTC (rev 283766)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm  2021-10-08 02:01:12 UTC (rev 283767)
</span><span class="lines">@@ -736,6 +736,11 @@
</span><span class="cx">     WebKit::WebsiteDataStore::makeNextNetworkProcessLaunchFailForTesting();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>++ (void)_preventNetworkProcessSuspensionForTesting
+{
+    WebKit::NetworkProcessProxy::preventSuspensionForTesting();
+}
+
</ins><span class="cx"> - (BOOL)_networkProcessExists
</span><span class="cx"> {
</span><span class="cx">     return !!_websiteDataStore->networkProcessIfExists();
</span></span></pre></div>
<a id="branchessafari612branchSourceWebKitUIProcessAPICocoaWKWebsiteDataStorePrivateh"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h (283766 => 283767)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h 2021-10-08 01:43:55 UTC (rev 283766)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h    2021-10-08 02:01:12 UTC (rev 283767)
</span><span class="lines">@@ -97,6 +97,7 @@
</span><span class="cx"> - (void)_sendNetworkProcessPrepareToSuspend:(void(^)(void))completionHandler WK_API_AVAILABLE(macos(12.0), ios(15.0));
</span><span class="cx"> - (void)_sendNetworkProcessWillSuspendImminently WK_API_AVAILABLE(macos(12.0), ios(15.0));
</span><span class="cx"> - (void)_sendNetworkProcessDidResume WK_API_AVAILABLE(macos(12.0), ios(15.0));
</span><ins>++ (void)_preventNetworkProcessSuspensionForTesting WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
</ins><span class="cx"> - (void)_synthesizeAppIsBackground:(BOOL)background WK_API_AVAILABLE(macos(12.0), ios(15.0));
</span><span class="cx"> - (pid_t)_networkProcessIdentifier WK_API_AVAILABLE(macos(12.0), ios(15.0));
</span><span class="cx"> + (void)_makeNextNetworkProcessLaunchFailForTesting WK_API_AVAILABLE(macos(12.0), ios(15.0));
</span></span></pre></div>
<a id="branchessafari612branchSourceWebKitUIProcessAPIiosWKWebViewPrivateForTestingIOSh"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebKit/UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h (283766 => 283767)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebKit/UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h       2021-10-08 01:43:55 UTC (rev 283766)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h  2021-10-08 02:01:12 UTC (rev 283767)
</span><span class="lines">@@ -89,10 +89,6 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_setDeviceHasAGXCompilerServiceForTesting;
</span><span class="cx"> 
</span><del>-#if !TARGET_OS_TV && !TARGET_OS_WATCH
-- (void)_setUIEventAttributionForTesting:(UIEventAttribution *)attribution withNonce:(NSString *)nonce;
-#endif
-
</del><span class="cx"> - (NSString *)_serializedSelectionCaretBackgroundColorForTesting;
</span><span class="cx"> 
</span><span class="cx"> @end
</span></span></pre></div>
<a id="branchessafari612branchSourceWebKitUIProcessAPIiosWKWebViewTestingIOSmm"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebKit/UIProcess/API/ios/WKWebViewTestingIOS.mm (283766 => 283767)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebKit/UIProcess/API/ios/WKWebViewTestingIOS.mm        2021-10-08 01:43:55 UTC (rev 283766)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/API/ios/WKWebViewTestingIOS.mm   2021-10-08 02:01:12 UTC (rev 283767)
</span><span class="lines">@@ -470,27 +470,6 @@
</span><span class="cx">         _page->setDeviceHasAGXCompilerServiceForTesting();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
-- (void)_setUIEventAttributionForTesting:(UIEventAttribution *)attribution withNonce:(NSString *)nonce
-{
-#if HAVE(UI_EVENT_ATTRIBUTION)
-    if (attribution) {
-        WebCore::PrivateClickMeasurement measurement(
-            WebCore::PrivateClickMeasurement::SourceID(attribution.sourceIdentifier),
-            WebCore::PrivateClickMeasurement::SourceSite(attribution.reportEndpoint),
-            WebCore::PrivateClickMeasurement::AttributionDestinationSite(attribution.destinationURL),
-            attribution.sourceDescription,
-            attribution.purchaser
-        );
-        measurement.setEphemeralSourceNonce({ nonce });
-
-        _page->setPrivateClickMeasurement(WTFMove(measurement));
-    } else
-        _page->setPrivateClickMeasurement(std::nullopt);
-#endif
-}
-#endif
-
</del><span class="cx"> - (NSString *)_serializedSelectionCaretBackgroundColorForTesting
</span><span class="cx"> {
</span><span class="cx">     UIColor *backgroundColor = [[_contentView textInteractionAssistant].selectionView valueForKeyPath:@"caretView.backgroundColor"];
</span></span></pre></div>
<a id="branchessafari612branchSourceWebKitUIProcessNetworkNetworkProcessProxycpp"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (283766 => 283767)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp       2021-10-08 01:43:55 UTC (rev 283766)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp  2021-10-08 02:01:12 UTC (rev 283767)
</span><span class="lines">@@ -1251,9 +1251,17 @@
</span><span class="cx">     if (canSendMessage())
</span><span class="cx">         sendSync(Messages::NetworkProcess::ProcessWillSuspendImminentlyForTestingSync(), Messages::NetworkProcess::ProcessWillSuspendImminentlyForTestingSync::Reply(), 0);
</span><span class="cx"> }
</span><del>-    
</del><ins>+
+static bool s_suspensionPreventedForTesting { false };
+void NetworkProcessProxy::preventSuspensionForTesting()
+{
+    s_suspensionPreventedForTesting = true;
+}
+
</ins><span class="cx"> void NetworkProcessProxy::sendPrepareToSuspend(IsSuspensionImminent isSuspensionImminent, CompletionHandler<void()>&& completionHandler)
</span><span class="cx"> {
</span><ins>+    if (s_suspensionPreventedForTesting)
+        return completionHandler();
</ins><span class="cx">     sendWithAsyncReply(Messages::NetworkProcess::PrepareToSuspend(isSuspensionImminent == IsSuspensionImminent::Yes), WTFMove(completionHandler), 0, { }, ShouldStartProcessThrottlerActivity::No);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari612branchSourceWebKitUIProcessNetworkNetworkProcessProxyh"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h (283766 => 283767)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h 2021-10-08 01:43:55 UTC (rev 283766)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h    2021-10-08 02:01:12 UTC (rev 283767)
</span><span class="lines">@@ -231,6 +231,7 @@
</span><span class="cx">     void sendProcessDidResume() final;
</span><span class="cx">     ASCIILiteral clientName() const final { return "NetworkProcess"_s; }
</span><span class="cx">     
</span><ins>+    static void preventSuspensionForTesting();
</ins><span class="cx">     void sendProcessWillSuspendImminentlyForTesting();
</span><span class="cx"> 
</span><span class="cx">     void registerSchemeForLegacyCustomProtocol(const String&);
</span></span></pre></div>
<a id="branchessafari612branchToolsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Tools/ChangeLog (283766 => 283767)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Tools/ChangeLog       2021-10-08 01:43:55 UTC (rev 283766)
+++ branches/safari-612-branch/Tools/ChangeLog  2021-10-08 02:01:12 UTC (rev 283767)
</span><span class="lines">@@ -1,3 +1,56 @@
</span><ins>+2021-10-07  Alan Coon  <alancoon@apple.com>
+
+        Cherry-pick r281349. rdar://problem/83957360
+
+    Make UIEventAttribution tests less platform dependent
+    https://bugs.webkit.org/show_bug.cgi?id=229323
+    
+    Reviewed by John Wilander.
+    
+    Source/WebKit:
+    
+    This allows me to run the UIEventAttribution tests on macOS.
+    It also makes them not time out, which they were doing since r277447.
+    To accomplish this, I added more test SPI to prevent the network process
+    suspension message, which was causing the test to time out on the iOS simulator.
+    
+    * UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h:
+    * UIProcess/API/Cocoa/WKWebViewTesting.mm:
+    (-[WKWebView _addEventAttributionWithSourceID:destinationURL:sourceDescription:purchaser:reportEndpoint:optionalNonce:]):
+    * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
+    (+[WKWebsiteDataStore _preventNetworkProcessSuspensionForTesting]):
+    * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
+    * UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h:
+    * UIProcess/API/ios/WKWebViewTestingIOS.mm:
+    (-[WKWebView _setUIEventAttributionForTesting:withNonce:]): Deleted.
+    * UIProcess/Network/NetworkProcessProxy.cpp:
+    (WebKit::NetworkProcessProxy::preventSuspensionForTesting):
+    (WebKit::NetworkProcessProxy::sendPrepareToSuspend):
+    * UIProcess/Network/NetworkProcessProxy.h:
+    
+    Tools:
+    
+    * TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm:
+    (TestWebKitAPI::exampleURL):
+    (TestWebKitAPI::runBasicEventAttributionTest):
+    (TestWebKitAPI::TEST):
+    
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281349 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-08-20  Alex Christensen  <achristensen@webkit.org>
+
+            Make UIEventAttribution tests less platform dependent
+            https://bugs.webkit.org/show_bug.cgi?id=229323
+
+            Reviewed by John Wilander.
+
+            * TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm:
+            (TestWebKitAPI::exampleURL):
+            (TestWebKitAPI::runBasicEventAttributionTest):
+            (TestWebKitAPI::TEST):
+
</ins><span class="cx"> 2021-09-27  Alan Coon  <alancoon@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Cherry-pick r283035. rdar://problem/83584492
</span></span></pre></div>
<a id="branchessafari612branchToolsTestWebKitAPITestsWebKitCocoaEventAttributionmm"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm (283766 => 283767)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm     2021-10-08 01:43:55 UTC (rev 283766)
+++ branches/safari-612-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm        2021-10-08 02:01:12 UTC (rev 283767)
</span><span class="lines">@@ -25,8 +25,6 @@
</span><span class="cx"> 
</span><span class="cx"> #import "config.h"
</span><span class="cx"> 
</span><del>-#if HAVE(UI_EVENT_ATTRIBUTION)
-
</del><span class="cx"> #import "HTTPServer.h"
</span><span class="cx"> #import "PlatformUtilities.h"
</span><span class="cx"> #import "TestNavigationDelegate.h"
</span><span class="lines">@@ -75,8 +73,14 @@
</span><span class="cx"> 
</span><span class="cx"> namespace TestWebKitAPI {
</span><span class="cx"> 
</span><del>-TEST(EventAttribution, Basic)
</del><ins>+static NSURL *exampleURL()
</ins><span class="cx"> {
</span><ins>+    return [NSURL URLWithString:@"https://example.com/"];
+}
+
+void runBasicEventAttributionTest(Function<void(WKWebView *, const HTTPServer&)>&& addAttributionToWebView)
+{
+    [WKWebsiteDataStore _preventNetworkProcessSuspensionForTesting];
</ins><span class="cx">     bool done = false;
</span><span class="cx">     HTTPServer server([&done, connectionCount = 0] (Connection connection) mutable {
</span><span class="cx">         switch (++connectionCount) {
</span><span class="lines">@@ -109,16 +113,14 @@
</span><span class="cx">     }, HTTPServer::Protocol::Https);
</span><span class="cx">     NSURL *serverURL = server.request().URL;
</span><span class="cx"> 
</span><del>-    auto exampleURL = [NSURL URLWithString:@"https://example.com/"];
-    auto attribution = adoptNS([[MockEventAttribution alloc] initWithReportEndpoint:server.request().URL destinationURL:exampleURL]);
</del><span class="cx">     auto webView = adoptNS([WKWebView new]);
</span><del>-    webView.get()._uiEventAttribution = (UIEventAttribution *)attribution.get();
</del><ins>+    addAttributionToWebView(webView.get(), server);
</ins><span class="cx">     [[webView configuration].websiteDataStore _setResourceLoadStatisticsEnabled:YES];
</span><span class="cx">     [[webView configuration].websiteDataStore _allowTLSCertificateChain:@[(id)testCertificate().get()] forHost:serverURL.host];
</span><del>-    [webView _setPrivateClickMeasurementAttributionReportURLsForTesting:serverURL destinationURL:exampleURL completionHandler:^{
</del><ins>+    [webView _setPrivateClickMeasurementAttributionReportURLsForTesting:serverURL destinationURL:exampleURL() completionHandler:^{
</ins><span class="cx">         [webView _setPrivateClickMeasurementOverrideTimerForTesting:YES completionHandler:^{
</span><span class="cx">             NSString *html = [NSString stringWithFormat:@"<script>fetch('%@conversionRequestBeforeRedirect',{mode:'no-cors'})</script>", serverURL];
</span><del>-            [webView loadHTMLString:html baseURL:exampleURL];
</del><ins>+            [webView loadHTMLString:html baseURL:exampleURL()];
</ins><span class="cx">         }];
</span><span class="cx">     }];
</span><span class="cx">     Util::run(&done);
</span><span class="lines">@@ -127,6 +129,7 @@
</span><span class="cx"> #if HAVE(RSA_BSSA)
</span><span class="cx"> TEST(EventAttribution, FraudPrevention)
</span><span class="cx"> {
</span><ins>+    [WKWebsiteDataStore _preventNetworkProcessSuspensionForTesting];
</ins><span class="cx">     bool done = false;
</span><span class="cx"> 
</span><span class="cx">     // Generate the server key pair.
</span><span class="lines">@@ -258,19 +261,17 @@
</span><span class="cx">     }, HTTPServer::Protocol::Https);
</span><span class="cx">     NSURL *serverURL = server.request().URL;
</span><span class="cx"> 
</span><del>-    auto exampleURL = [NSURL URLWithString:@"https://example.com/"];
-    auto attribution = adoptNS([[MockEventAttribution alloc] initWithReportEndpoint:serverURL destinationURL:exampleURL]);
</del><span class="cx">     auto webView = adoptNS([WKWebView new]);
</span><del>-    [webView _setUIEventAttributionForTesting:(UIEventAttribution *)attribution.get() withNonce:@"ABCDEFabcdef0123456789"];
</del><ins>+    [webView _addEventAttributionWithSourceID:42 destinationURL:exampleURL() sourceDescription:@"test source description" purchaser:@"test purchaser" reportEndpoint:serverURL optionalNonce:@"ABCDEFabcdef0123456789"];
</ins><span class="cx">     [[webView configuration].websiteDataStore _setResourceLoadStatisticsEnabled:YES];
</span><span class="cx">     [[webView configuration].websiteDataStore _allowTLSCertificateChain:@[(id)testCertificate().get()] forHost:serverURL.host];
</span><span class="cx"> 
</span><del>-    [webView _setPrivateClickMeasurementAttributionReportURLsForTesting:serverURL destinationURL:exampleURL completionHandler:^{
</del><ins>+    [webView _setPrivateClickMeasurementAttributionReportURLsForTesting:serverURL destinationURL:exampleURL() completionHandler:^{
</ins><span class="cx">         [webView _setPrivateClickMeasurementOverrideTimerForTesting:YES completionHandler:^{
</span><span class="cx">             [webView _setPrivateClickMeasurementAttributionTokenPublicKeyURLForTesting:serverURL completionHandler:^{
</span><span class="cx">                 [webView _setPrivateClickMeasurementAttributionTokenSignatureURLForTesting:serverURL completionHandler:^{
</span><span class="cx">                     NSString *html = [NSString stringWithFormat:@"<script>setTimeout(function(){ fetch('%@conversionRequestBeforeRedirect',{mode:'no-cors'}); }, 100);</script>", serverURL];
</span><del>-                    [webView loadHTMLString:html baseURL:exampleURL];
</del><ins>+                    [webView loadHTMLString:html baseURL:exampleURL()];
</ins><span class="cx">                 }];
</span><span class="cx">             }];
</span><span class="cx">         }];
</span><span class="lines">@@ -279,6 +280,23 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+TEST(EventAttribution, Basic)
+{
+    runBasicEventAttributionTest([](WKWebView *webView, const HTTPServer& server) {
+        [webView _addEventAttributionWithSourceID:42 destinationURL:exampleURL() sourceDescription:@"test source description" purchaser:@"test purchaser" reportEndpoint:server.request().URL optionalNonce:nil];
+    });
+}
+
+#if HAVE(UI_EVENT_ATTRIBUTION)
+
+TEST(EventAttribution, BasicWithIOSSPI)
+{
+    runBasicEventAttributionTest([](WKWebView *webView, const HTTPServer& server) {
+        auto attribution = adoptNS([[MockEventAttribution alloc] initWithReportEndpoint:server.request().URL destinationURL:exampleURL()]);
+        webView._uiEventAttribution = (UIEventAttribution *)attribution.get();
+    });
+}
+
+#endif // HAVE(UI_EVENT_ATTRIBUTION)
+
</ins><span class="cx"> } // namespace TestWebKitAPI
</span><del>-
-#endif // PLATFORM(IOS_FAMILY)
</del></span></pre>
</div>
</div>

</body>
</html>