Diff
Modified: trunk/Source/WebKit/ChangeLog (287373 => 287374)
--- trunk/Source/WebKit/ChangeLog 2021-12-22 22:51:41 UTC (rev 287373)
+++ trunk/Source/WebKit/ChangeLog 2021-12-22 23:16:14 UTC (rev 287374)
@@ -1,3 +1,27 @@
+2021-12-22 Alex Christensen <achristen...@webkit.org>
+
+ Re-enable CustomDisplayName and DefaultDisplayName API tests on Monterey
+ https://bugs.webkit.org/show_bug.cgi?id=234613
+
+ Reviewed by Brady Eidson.
+
+ When we introduced setting the display name from the network process,
+ we didn't update the tests to get the information from the process that can access it.
+
+ * NetworkProcess/NetworkConnectionToWebProcess.h:
+ * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
+ * NetworkProcess/mac/NetworkConnectionToWebProcessMac.mm:
+ (WebKit::NetworkConnectionToWebProcess::updateActivePages):
+ (WebKit::NetworkConnectionToWebProcess::getProcessDisplayName):
+ * WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
+ (WebKit::WebPage::getProcessDisplayName):
+ * WebProcess/WebProcess.h:
+ * WebProcess/cocoa/WebProcessCocoa.mm:
+ (WebKit::WebProcess::auditTokenForSelf):
+ (WebKit::WebProcess::updateProcessName):
+ (WebKit::WebProcess::getProcessDisplayName):
+ (WebKit::WebProcess::updateActivePages):
+
2021-12-22 Commit Queue <commit-qu...@webkit.org>
Unreviewed, reverting r287364.
Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h (287373 => 287374)
--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h 2021-12-22 22:51:41 UTC (rev 287373)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h 2021-12-22 23:16:14 UTC (rev 287374)
@@ -274,6 +274,7 @@
#if PLATFORM(MAC)
void updateActivePages(const String& name, const Vector<String>& activePagesOrigins, audit_token_t);
+ void getProcessDisplayName(audit_token_t, CompletionHandler<void(const String&)>&&);
#endif
#if USE(LIBWEBRTC)
@@ -407,6 +408,9 @@
#if ENABLE(APPLE_PAY_REMOTE_UI)
std::unique_ptr<WebPaymentCoordinatorProxy> m_paymentCoordinator;
#endif
+#if PLATFORM(MAC) && !USE(APPLE_INTERNAL_SDK)
+ String m_processDisplayName;
+#endif
const WebCore::ProcessIdentifier m_webProcessIdentifier;
HashSet<WebCore::MessagePortIdentifier> m_processEntangledPorts;
Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in (287373 => 287374)
--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in 2021-12-22 22:51:41 UTC (rev 287373)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in 2021-12-22 23:16:14 UTC (rev 287374)
@@ -105,6 +105,7 @@
RegisterURLSchemesAsCORSEnabled(Vector<String> schemes);
SetCORSDisablingPatterns(WebCore::PageIdentifier pageIdentifier, Vector<String> patterns)
#if PLATFORM(MAC)
+ GetProcessDisplayName(audit_token_t auditToken) -> (String displayName) Async
UpdateActivePages(String name, Vector<String> activePagesOrigins, audit_token_t auditToken)
#endif
SetResourceLoadSchedulingMode(WebCore::PageIdentifier webPageID, enum:uint8_t WebCore::LoadSchedulingMode mode)
Modified: trunk/Source/WebKit/NetworkProcess/mac/NetworkConnectionToWebProcessMac.mm (287373 => 287374)
--- trunk/Source/WebKit/NetworkProcess/mac/NetworkConnectionToWebProcessMac.mm 2021-12-22 22:51:41 UTC (rev 287373)
+++ trunk/Source/WebKit/NetworkProcess/mac/NetworkConnectionToWebProcessMac.mm 2021-12-22 23:16:14 UTC (rev 287374)
@@ -32,14 +32,34 @@
namespace WebKit {
#if PLATFORM(MAC)
+
void NetworkConnectionToWebProcess::updateActivePages(const String& overrideDisplayName, const Vector<String>& activePagesOrigins, audit_token_t auditToken)
{
+#if USE(APPLE_INTERNAL_SDK)
auto asn = adoptCF(_LSCopyLSASNForAuditToken(kLSDefaultSessionID, auditToken));
if (!overrideDisplayName)
_LSSetApplicationInformationItem(kLSDefaultSessionID, asn.get(), CFSTR("LSActivePageUserVisibleOriginsKey"), (__bridge CFArrayRef)createNSArray(activePagesOrigins).get(), nullptr);
else
_LSSetApplicationInformationItem(kLSDefaultSessionID, asn.get(), _kLSDisplayNameKey, overrideDisplayName.createCFString().get(), nullptr);
+#else
+ // Setting and getting the display name of another process requires a private entitlement.
+ if (!!overrideDisplayName)
+ m_processDisplayName = overrideDisplayName;
+ UNUSED_PARAM(activePagesOrigins);
+ UNUSED_PARAM(auditToken);
+#endif
}
+
+void NetworkConnectionToWebProcess::getProcessDisplayName(audit_token_t auditToken, CompletionHandler<void(const String&)>&& completionHandler)
+{
+#if USE(APPLE_INTERNAL_SDK)
+ auto asn = adoptCF(_LSCopyLSASNForAuditToken(kLSDefaultSessionID, auditToken));
+ return completionHandler(adoptCF((CFStringRef)_LSCopyApplicationInformationItem(kLSDefaultSessionID, asn.get(), _kLSDisplayNameKey)).get());
+#else
+ completionHandler(m_processDisplayName);
#endif
+}
+#endif // PLATFORM(MAC)
+
} // namespace WebKit
Modified: trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm (287373 => 287374)
--- trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm 2021-12-22 22:51:41 UTC (rev 287373)
+++ trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm 2021-12-22 23:16:14 UTC (rev 287374)
@@ -341,7 +341,11 @@
void WebPage::getProcessDisplayName(CompletionHandler<void(String&&)>&& completionHandler)
{
#if PLATFORM(MAC)
+#if ENABLE(SET_WEBCONTENT_PROCESS_INFORMATION_IN_NETWORK_PROCESS)
+ WebProcess::singleton().getProcessDisplayName(WTFMove(completionHandler));
+#else
completionHandler(adoptCF((CFStringRef)_LSCopyApplicationInformationItem(kLSDefaultSessionID, _LSGetCurrentApplicationASN(), _kLSDisplayNameKey)).get());
+#endif
#else
completionHandler({ });
#endif
Modified: trunk/Source/WebKit/WebProcess/WebProcess.h (287373 => 287374)
--- trunk/Source/WebKit/WebProcess/WebProcess.h 2021-12-22 22:51:41 UTC (rev 287373)
+++ trunk/Source/WebKit/WebProcess/WebProcess.h 2021-12-22 23:16:14 UTC (rev 287374)
@@ -294,6 +294,8 @@
#if PLATFORM(COCOA)
RetainPtr<CFDataRef> sourceApplicationAuditData() const;
void destroyRenderingResources();
+ void getProcessDisplayName(CompletionHandler<void(String&&)>&&);
+ std::optional<audit_token_t> auditTokenForSelf();
#endif
const String& uiProcessBundleIdentifier() const { return m_uiProcessBundleIdentifier; }
Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (287373 => 287374)
--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2021-12-22 22:51:41 UTC (rev 287373)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2021-12-22 23:16:14 UTC (rev 287374)
@@ -479,6 +479,18 @@
#endif
}
+std::optional<audit_token_t> WebProcess::auditTokenForSelf()
+{
+ audit_token_t auditToken = { 0 };
+ mach_msg_type_number_t info_size = TASK_AUDIT_TOKEN_COUNT;
+ kern_return_t kr = task_info(mach_task_self(), TASK_AUDIT_TOKEN, reinterpret_cast<integer_t *>(&auditToken), &info_size);
+ if (kr != KERN_SUCCESS) {
+ WEBPROCESS_RELEASE_LOG_ERROR(Process, "Unable to get audit token for self. Error: %{public}s (%x)", mach_error_string(kr), kr);
+ return std::nullopt;
+ }
+ return auditToken;
+}
+
void WebProcess::updateProcessName(IsInProcessInitialization isInProcessInitialization)
{
#if PLATFORM(MAC)
@@ -502,19 +514,24 @@
}
#if ENABLE(SET_WEBCONTENT_PROCESS_INFORMATION_IN_NETWORK_PROCESS)
+#if USE(APPLE_INTERNAL_SDK)
// During WebProcess initialization, we are still able to talk to LaunchServices to set the process name so there is no need to go
// via the NetworkProcess. Prewarmed WebProcesses also do not have a network process connection until they are actually used by
// a page.
- if (isInProcessInitialization == IsInProcessInitialization::No) {
- audit_token_t auditToken = { 0 };
- mach_msg_type_number_t info_size = TASK_AUDIT_TOKEN_COUNT;
- kern_return_t kr = task_info(mach_task_self(), TASK_AUDIT_TOKEN, reinterpret_cast<integer_t *>(&auditToken), &info_size);
- if (kr != KERN_SUCCESS) {
- WEBPROCESS_RELEASE_LOG_ERROR(Process, "updateProcessName: Unable to get audit token for self. Error: %{public}s (%x)", mach_error_string(kr), kr);
+ bool sendToNetworkProcess = isInProcessInitialization == IsInProcessInitialization::No;
+#else
+ // The web process can't read its display name from LaunchServices,
+ // and without an internal entitlement the network process can't read on behalf of the web process,
+ // so use state in memory in the network process to simulate LaunchServices state.
+ bool sendToNetworkProcess = true;
+#endif
+
+ if (sendToNetworkProcess) {
+ auto auditToken = auditTokenForSelf();
+ if (!auditToken)
return;
- }
String displayName = applicationName.get();
- ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::UpdateActivePages(displayName, Vector<String>(), auditToken), 0);
+ ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::UpdateActivePages(displayName, Vector<String>(), *auditToken), 0);
return;
}
#endif // ENABLE(SET_WEBCONTENT_PROCESS_INFORMATION_IN_NETWORK_PROCESS)
@@ -732,19 +749,26 @@
}
#endif
+void WebProcess::getProcessDisplayName(CompletionHandler<void(String&&)>&& completionHandler)
+{
+#if PLATFORM(MAC)
+ auto auditToken = auditTokenForSelf();
+ if (!auditToken)
+ return completionHandler({ });
+ ensureNetworkProcessConnection().connection().sendWithAsyncReply(Messages::NetworkConnectionToWebProcess::GetProcessDisplayName(*auditToken), WTFMove(completionHandler));
+#else
+ completionHandler({ });
+#endif
+}
+
void WebProcess::updateActivePages(const String& overrideDisplayName)
{
#if PLATFORM(MAC)
#if ENABLE(SET_WEBCONTENT_PROCESS_INFORMATION_IN_NETWORK_PROCESS)
- audit_token_t auditToken = { 0 };
- mach_msg_type_number_t info_size = TASK_AUDIT_TOKEN_COUNT;
- kern_return_t kr = task_info(mach_task_self(), TASK_AUDIT_TOKEN, reinterpret_cast<integer_t *>(&auditToken), &info_size);
- if (kr != KERN_SUCCESS) {
- WEBPROCESS_RELEASE_LOG_ERROR(Process, "updateActivePages: Unable to get audit token for self. Error: %{public}s (%x)", mach_error_string(kr), kr);
+ auto auditToken = auditTokenForSelf();
+ if (!auditToken)
return;
- }
-
- ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::UpdateActivePages(overrideDisplayName, activePagesOrigins(m_pageMap), auditToken), 0);
+ ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::UpdateActivePages(overrideDisplayName, activePagesOrigins(m_pageMap), *auditToken), 0);
#else
if (!overrideDisplayName) {
RunLoop::main().dispatch([activeOrigins = activePagesOrigins(m_pageMap)] {
Modified: trunk/Tools/ChangeLog (287373 => 287374)
--- trunk/Tools/ChangeLog 2021-12-22 22:51:41 UTC (rev 287373)
+++ trunk/Tools/ChangeLog 2021-12-22 23:16:14 UTC (rev 287374)
@@ -1,3 +1,13 @@
+2021-12-22 Alex Christensen <achristen...@webkit.org>
+
+ Re-enable CustomDisplayName and DefaultDisplayName API tests on Monterey
+ https://bugs.webkit.org/show_bug.cgi?id=234613
+
+ Reviewed by Brady Eidson.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/DisplayName.mm:
+ (TestWebKitAPI::TEST):
+
2021-12-22 Kate Cheney <katherine_che...@apple.com>
PCM tests crashing with 'unlink' errors
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/DisplayName.mm (287373 => 287374)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/DisplayName.mm 2021-12-22 22:51:41 UTC (rev 287373)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/DisplayName.mm 2021-12-22 23:16:14 UTC (rev 287374)
@@ -53,12 +53,7 @@
}];
}
-// FIXME: Re-enable this test for Monterey+ once rdar://80353834 is resolved.
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 120000
-TEST(WebKit, DISABLED_CustomDisplayName)
-#else
TEST(WebKit, CustomDisplayName)
-#endif
{
auto configuration = adoptNS([WKWebViewConfiguration new]);
NSString *displayNameToSet = @"test display name";
@@ -71,12 +66,7 @@
Util::run(&done);
}
-// FIXME: Re-enable this test for Monterey+ once rdar://80353834 is resolved.
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 120000
-TEST(WebKit, DISABLED_DefaultDisplayName)
-#else
TEST(WebKit, DefaultDisplayName)
-#endif
{
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
[webView synchronouslyLoadHTMLString:@"start web process"];