Diff
Modified: trunk/Source/WebKit/ChangeLog (288539 => 288540)
--- trunk/Source/WebKit/ChangeLog 2022-01-25 05:48:06 UTC (rev 288539)
+++ trunk/Source/WebKit/ChangeLog 2022-01-25 06:09:31 UTC (rev 288540)
@@ -1,3 +1,27 @@
+2022-01-24 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):
+
2022-01-24 Sihui Liu <sihui_...@apple.com>
Regression (r286936): SessionStorage data is not cleared when deleting website data by modification time
Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h (288539 => 288540)
--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h 2022-01-25 05:48:06 UTC (rev 288539)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h 2022-01-25 06:09:31 UTC (rev 288540)
@@ -278,6 +278,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)
Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in (288539 => 288540)
--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in 2022-01-25 05:48:06 UTC (rev 288539)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in 2022-01-25 06:09:31 UTC (rev 288540)
@@ -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 (288539 => 288540)
--- trunk/Source/WebKit/NetworkProcess/mac/NetworkConnectionToWebProcessMac.mm 2022-01-25 05:48:06 UTC (rev 288539)
+++ trunk/Source/WebKit/NetworkProcess/mac/NetworkConnectionToWebProcessMac.mm 2022-01-25 06:09:31 UTC (rev 288540)
@@ -32,14 +32,33 @@
namespace WebKit {
#if PLATFORM(MAC)
+
void NetworkConnectionToWebProcess::updateActivePages(const String& overrideDisplayName, const Vector<String>& activePagesOrigins, audit_token_t auditToken)
{
+ // Setting and getting the display name of another process requires a private entitlement.
+#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
+ UNUSED_PARAM(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({ });
#endif
+}
+#endif // PLATFORM(MAC)
+
} // namespace WebKit
Modified: trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm (288539 => 288540)
--- trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm 2022-01-25 05:48:06 UTC (rev 288539)
+++ trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm 2022-01-25 06:09:31 UTC (rev 288540)
@@ -335,7 +335,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 (288539 => 288540)
--- trunk/Source/WebKit/WebProcess/WebProcess.h 2022-01-25 05:48:06 UTC (rev 288539)
+++ trunk/Source/WebKit/WebProcess/WebProcess.h 2022-01-25 06:09:31 UTC (rev 288540)
@@ -289,6 +289,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 (288539 => 288540)
--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2022-01-25 05:48:06 UTC (rev 288539)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2022-01-25 06:09:31 UTC (rev 288540)
@@ -488,6 +488,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)
@@ -514,16 +526,13 @@
// 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);
+ 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)
@@ -741,19 +750,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 (288539 => 288540)
--- trunk/Tools/ChangeLog 2022-01-25 05:48:06 UTC (rev 288539)
+++ trunk/Tools/ChangeLog 2022-01-25 06:09:31 UTC (rev 288540)
@@ -1,3 +1,13 @@
+2022-01-24 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):
+
2022-01-20 Jonathan Bedard <jbed...@apple.com>
[EWS] Support pull request in AnaylzePatch
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/DisplayName.mm (288539 => 288540)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/DisplayName.mm 2022-01-25 05:48:06 UTC (rev 288539)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/DisplayName.mm 2022-01-25 06:09:31 UTC (rev 288540)
@@ -53,12 +53,9 @@
}];
}
-// 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
+// The network process requires a private entitlement to get and set the process name for the web process.
+#if !ENABLE(SET_WEBCONTENT_PROCESS_INFORMATION_IN_NETWORK_PROCESS) || USE(APPLE_INTERNAL_SDK)
TEST(WebKit, CustomDisplayName)
-#endif
{
auto configuration = adoptNS([WKWebViewConfiguration new]);
NSString *displayNameToSet = @"test display name";
@@ -71,12 +68,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"];
@@ -85,6 +77,7 @@
checkUntilDisplayNameIs(webView.get(), @"TestWebKitAPI Web Content", &done);
Util::run(&done);
}
+#endif // !ENABLE(SET_WEBCONTENT_PROCESS_INFORMATION_IN_NETWORK_PROCESS) || USE(APPLE_INTERNAL_SDK)
#endif // PLATFORM(MAC)
}