Diff
Modified: trunk/Tools/ChangeLog (287233 => 287234)
--- trunk/Tools/ChangeLog 2021-12-19 00:21:24 UTC (rev 287233)
+++ trunk/Tools/ChangeLog 2021-12-19 03:38:04 UTC (rev 287234)
@@ -1,3 +1,28 @@
+2021-12-18 Alex Christensen <[email protected]>
+
+ [Monterey] TestWebKitAPI.PrivateClickMeasurement.Daemon* tests timing out: Failed to connect to mach service org.webkit.pcmtestdaemon.service
+ https://bugs.webkit.org/show_bug.cgi?id=232890
+
+ Reviewed by Brady Eidson.
+
+ Using OSLaunchdJob on macOS works, but it requires a private entitlement which the public SDK can't sign with.
+ Just continue using launchctl instead. Also, do the NSDictionary -> xpc dictionary conversion at runtime to reduce duplicate code.
+
+ * TestWebKitAPI/Configurations/TestWebKitAPI-macOS-internal.entitlements:
+ * TestWebKitAPI/Configurations/TestWebKitAPI-macOS.entitlements:
+ * TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig:
+ * TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm:
+ (TestWebKitAPI::testDaemonPList):
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm:
+ (TestWebKitAPI::testWebPushDaemonPList):
+ (TestWebKitAPI::setUpTestWebPushD):
+ * TestWebKitAPI/cocoa/DaemonTestUtilities.h:
+ * TestWebKitAPI/cocoa/DaemonTestUtilities.mm:
+ (TestWebKitAPI::convertArrayToXPC):
+ (TestWebKitAPI::convertDictionaryToXPC):
+ (TestWebKitAPI::registerPlistWithLaunchD):
+
2021-12-17 Simon Fraser <[email protected]>
Read the default value of the ScrollAnimatorEnabled setting from NSUserDefaults
Modified: trunk/Tools/TestWebKitAPI/Configurations/TestWebKitAPI-macOS-internal.entitlements (287233 => 287234)
--- trunk/Tools/TestWebKitAPI/Configurations/TestWebKitAPI-macOS-internal.entitlements 2021-12-19 00:21:24 UTC (rev 287233)
+++ trunk/Tools/TestWebKitAPI/Configurations/TestWebKitAPI-macOS-internal.entitlements 2021-12-19 03:38:04 UTC (rev 287234)
@@ -2,8 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
- <key>com.apple.private.xpc.launchd.job-manager</key>
- <string>TestWebKitAPI</string>
<key>com.apple.private.webkit.webpush</key>
<true/>
<key>com.apple.private.webkit.webpush.inject</key>
Modified: trunk/Tools/TestWebKitAPI/Configurations/TestWebKitAPI-macOS.entitlements (287233 => 287234)
--- trunk/Tools/TestWebKitAPI/Configurations/TestWebKitAPI-macOS.entitlements 2021-12-19 00:21:24 UTC (rev 287233)
+++ trunk/Tools/TestWebKitAPI/Configurations/TestWebKitAPI-macOS.entitlements 2021-12-19 03:38:04 UTC (rev 287234)
@@ -2,8 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
- <key>com.apple.private.xpc.launchd.job-manager</key>
- <string>TestWebKitAPI</string>
<key>keychain-access-groups</key>
<array>
<string>com.apple.TestWebKitAPI</string>
Modified: trunk/Tools/TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig (287233 => 287234)
--- trunk/Tools/TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig 2021-12-19 00:21:24 UTC (rev 287233)
+++ trunk/Tools/TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig 2021-12-19 03:38:04 UTC (rev 287234)
@@ -43,12 +43,7 @@
FRAMEWORK_SEARCH_PATHS_ = $(inherited) $(WK_PRIVATE_FRAMEWORKS_DIR) $(SYSTEM_LIBRARY_DIR)/PrivateFrameworks $(SYSTEM_LIBRARY_DIR)/Frameworks/WebKit.framework/Versions/A/Frameworks;
FRAMEWORK_SEARCH_PATHS_cocoatouch = $(inherited) $(WK_PRIVATE_FRAMEWORKS_DIR);
-WK_APPSERVERSUPPORT_LDFLAGS = $(WK_APPSERVERSUPPORT_LDFLAGS_$(WK_PLATFORM_NAME));
-WK_APPSERVERSUPPORT_LDFLAGS_macosx = $(WK_APPSERVERSUPPORT_LDFLAGS$(WK_MACOS_1200));
-WK_APPSERVERSUPPORT_LDFLAGS_MACOS_SINCE_1200 = -framework AppServerSupport
-WK_APPSERVERSUPPORT_LDFLAGS_iphoneos = $(WK_APPSERVERSUPPORT_LDFLAGS$(WK_IOS_15));
-WK_APPSERVERSUPPORT_LDFLAGS_iphonesimulator = $(WK_APPSERVERSUPPORT_LDFLAGS$(WK_IOS_15));
-WK_APPSERVERSUPPORT_LDFLAGS_IOS_SINCE_15 = -framework AppServerSupport
+WK_APPSERVERSUPPORT_LDFLAGS[sdk=iphone*] = -framework AppServerSupport
WK_AUTHKIT_LDFLAGS = $(WK_AUTHKIT_LDFLAGS_$(WK_PLATFORM_NAME));
WK_AUTHKIT_LDFLAGS_iphoneos = $(WK_AUTHKIT_LDFLAGS$(WK_IOS_13));
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm (287233 => 287234)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm 2021-12-19 00:21:24 UTC (rev 287233)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm 2021-12-19 03:38:04 UTC (rev 287234)
@@ -448,44 +448,8 @@
return [currentExecutableDirectory() URLByAppendingPathComponent:@"adattributiond" isDirectory:NO];
}
-#if HAVE(OS_LAUNCHD_JOB)
-
-static RetainPtr<xpc_object_t> testDaemonPList(NSURL *storageLocation)
+static NSDictionary<NSString *, id> *testDaemonPList(NSURL *storageLocation)
{
- auto plist = adoptNS(xpc_dictionary_create(nullptr, nullptr, 0));
- xpc_dictionary_set_string(plist.get(), "_ManagedBy", "TestWebKitAPI");
- xpc_dictionary_set_string(plist.get(), "Label", "org.webkit.pcmtestdaemon");
- xpc_dictionary_set_bool(plist.get(), "RootedSimulatorPath", true);
- xpc_dictionary_set_bool(plist.get(), "LaunchOnlyOnce", true);
- xpc_dictionary_set_string(plist.get(), "StandardErrorPath", [storageLocation URLByAppendingPathComponent:@"daemon_stderr"].path.fileSystemRepresentation);
-
- {
- auto environmentVariables = adoptNS(xpc_dictionary_create(nullptr, nullptr, 0));
- xpc_dictionary_set_string(environmentVariables.get(), "DYLD_FRAMEWORK_PATH", currentExecutableDirectory().get().fileSystemRepresentation);
- xpc_dictionary_set_value(plist.get(), "EnvironmentVariables", environmentVariables.get());
- }
- {
- auto machServices = adoptNS(xpc_dictionary_create(nullptr, nullptr, 0));
- xpc_dictionary_set_bool(machServices.get(), "org.webkit.pcmtestdaemon.service", true);
- xpc_dictionary_set_value(plist.get(), "MachServices", machServices.get());
- }
- {
- auto programArguments = adoptNS(xpc_array_create(nullptr, 0));
- auto executableLocation = testPCMDaemonLocation();
- xpc_array_set_string(programArguments.get(), XPC_ARRAY_APPEND, executableLocation.get().fileSystemRepresentation);
- xpc_array_set_string(programArguments.get(), XPC_ARRAY_APPEND, "--machServiceName");
- xpc_array_set_string(programArguments.get(), XPC_ARRAY_APPEND, "org.webkit.pcmtestdaemon.service");
- xpc_array_set_string(programArguments.get(), XPC_ARRAY_APPEND, "--storageLocation");
- xpc_array_set_string(programArguments.get(), XPC_ARRAY_APPEND, storageLocation.fileSystemRepresentation);
- xpc_dictionary_set_value(plist.get(), "ProgramArguments", programArguments.get());
- }
- return plist;
-}
-
-#else // HAVE(OS_LAUNCHD_JOB)
-
-static RetainPtr<NSDictionary> testDaemonPList(NSURL *storageLocation)
-{
return @{
@"Label" : @"org.webkit.pcmtestdaemon",
@"LaunchOnlyOnce" : @YES,
@@ -502,8 +466,6 @@
};
}
-#endif // HAVE(OS_LAUNCHD_JOB)
-
static std::pair<NSURL *, WKWebViewConfiguration *> setUpDaemon(WKWebViewConfiguration *viewConfiguration)
{
NSFileManager *fileManager = [NSFileManager defaultManager];
@@ -515,12 +477,8 @@
killFirstInstanceOfDaemon(@"adattributiond");
- auto plist = testDaemonPList(tempDir);
-#if HAVE(OS_LAUNCHD_JOB)
- registerPlistWithLaunchD(WTFMove(plist));
-#else
- registerPlistWithLaunchD(WTFMove(plist), tempDir);
-#endif
+ registerPlistWithLaunchD(testDaemonPList(tempDir), tempDir);
+
auto dataStoreConfiguration = adoptNS([_WKWebsiteDataStoreConfiguration new]);
dataStoreConfiguration.get().pcmMachServiceName = @"org.webkit.pcmtestdaemon.service";
viewConfiguration.websiteDataStore = adoptNS([[WKWebsiteDataStore alloc] _initWithConfiguration:dataStoreConfiguration.get()]).get();
@@ -554,12 +512,7 @@
#endif
}
-// FIXME: Re-enable this test for Monterey+ once webkit.org/232890 is resolved.
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 120000
-TEST(PrivateClickMeasurement, DISABLED_DaemonBasicFunctionality)
-#else
TEST(PrivateClickMeasurement, DaemonBasicFunctionality)
-#endif
{
auto [tempDir, configuration] = setUpDaemon(configurationWithoutUsingDaemon().autorelease());
attemptConnectionInProcessWithoutEntitlement();
@@ -594,12 +547,7 @@
return webView;
}
-// FIXME: Re-enable this test for Monterey+ once webkit.org/232890 is resolved.
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 120000
-TEST(PrivateClickMeasurement, DISABLED_DaemonDebugMode)
-#else
TEST(PrivateClickMeasurement, DaemonDebugMode)
-#endif
{
auto [tempDir, configuration] = setUpDaemon([WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"BundlePageConsoleMessage"]);
Vector<String> consoleMessages;
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm (287233 => 287234)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm 2021-12-19 00:21:24 UTC (rev 287233)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm 2021-12-19 03:38:04 UTC (rev 287234)
@@ -67,50 +67,10 @@
return [currentExecutableDirectory() URLByAppendingPathComponent:@"webpushd" isDirectory:NO];
}
-#if HAVE(OS_LAUNCHD_JOB)
-
-static RetainPtr<xpc_object_t> testWebPushDaemonPList(NSURL *storageLocation)
+static NSDictionary<NSString *, id> *testWebPushDaemonPList(NSURL *storageLocation)
{
- auto currentDirectory = currentExecutableDirectory();
-
- auto plist = adoptNS(xpc_dictionary_create(nullptr, nullptr, 0));
- xpc_dictionary_set_string(plist.get(), "_ManagedBy", "TestWebKitAPI");
- xpc_dictionary_set_string(plist.get(), "Label", "org.webkit.webpushtestdaemon");
- xpc_dictionary_set_bool(plist.get(), "LaunchOnlyOnce", true);
- xpc_dictionary_set_bool(plist.get(), "RootedSimulatorPath", true);
- xpc_dictionary_set_string(plist.get(), "StandardErrorPath", [storageLocation URLByAppendingPathComponent:@"daemon_stderr"].path.fileSystemRepresentation);
-
- {
- auto environmentVariables = adoptNS(xpc_dictionary_create(nullptr, nullptr, 0));
- xpc_dictionary_set_string(environmentVariables.get(), "DYLD_FRAMEWORK_PATH", currentDirectory.get().fileSystemRepresentation);
- xpc_dictionary_set_value(plist.get(), "EnvironmentVariables", environmentVariables.get());
- }
- {
- auto machServices = adoptNS(xpc_dictionary_create(nullptr, nullptr, 0));
- xpc_dictionary_set_bool(machServices.get(), "org.webkit.webpushtestdaemon.service", true);
- xpc_dictionary_set_value(plist.get(), "MachServices", machServices.get());
- }
- {
- auto programArguments = adoptNS(xpc_array_create(nullptr, 0));
- auto executableLocation = testWebPushDaemonLocation();
-#if PLATFORM(MAC)
- xpc_array_set_string(programArguments.get(), XPC_ARRAY_APPEND, executableLocation.get().fileSystemRepresentation);
-#else
- xpc_array_set_string(programArguments.get(), XPC_ARRAY_APPEND, [currentDirectory URLByAppendingPathComponent:@"webpushd"].path.fileSystemRepresentation);
-#endif
- xpc_array_set_string(programArguments.get(), XPC_ARRAY_APPEND, "--machServiceName");
- xpc_array_set_string(programArguments.get(), XPC_ARRAY_APPEND, "org.webkit.webpushtestdaemon.service");
- xpc_dictionary_set_value(plist.get(), "ProgramArguments", programArguments.get());
- }
- return plist;
-}
-
-#else // HAVE(OS_LAUNCHD_JOB)
-
-static RetainPtr<NSDictionary> testWebPushDaemonPList(NSURL *storageLocation)
-{
return @{
- @"Label" : @"org.webkit.pcmtestdaemon",
+ @"Label" : @"org.webkit.webpushtestdaemon",
@"LaunchOnlyOnce" : @YES,
@"StandardErrorPath" : [storageLocation URLByAppendingPathComponent:@"daemon_stderr"].path,
@"EnvironmentVariables" : @{ @"DYLD_FRAMEWORK_PATH" : currentExecutableDirectory().get().path },
@@ -123,8 +83,6 @@
};
}
-#endif // HAVE(OS_LAUNCHD_JOB)
-
static bool shouldSetupWebPushD()
{
static bool shouldSetup = true;
@@ -152,12 +110,7 @@
killFirstInstanceOfDaemon(@"webpushd");
- auto plist = testWebPushDaemonPList(tempDir);
-#if HAVE(OS_LAUNCHD_JOB)
- registerPlistWithLaunchD(WTFMove(plist));
-#else
- registerPlistWithLaunchD(WTFMove(plist), tempDir);
-#endif
+ registerPlistWithLaunchD(testWebPushDaemonPList(tempDir), tempDir);
return tempDir;
}
Modified: trunk/Tools/TestWebKitAPI/cocoa/DaemonTestUtilities.h (287233 => 287234)
--- trunk/Tools/TestWebKitAPI/cocoa/DaemonTestUtilities.h 2021-12-19 00:21:24 UTC (rev 287233)
+++ trunk/Tools/TestWebKitAPI/cocoa/DaemonTestUtilities.h 2021-12-19 03:38:04 UTC (rev 287234)
@@ -39,11 +39,7 @@
void killFirstInstanceOfDaemon(NSString *daemonExecutableName);
-#if HAVE(OS_LAUNCHD_JOB)
-void registerPlistWithLaunchD(RetainPtr<xpc_object_t>&&);
-#else
-void registerPlistWithLaunchD(RetainPtr<NSDictionary>&&, NSURL *tempDir);
-#endif
+void registerPlistWithLaunchD(NSDictionary<NSString *, id> *plist, NSURL *tempDir);
} // namespace TestWebKitAPI
Modified: trunk/Tools/TestWebKitAPI/cocoa/DaemonTestUtilities.mm (287233 => 287234)
--- trunk/Tools/TestWebKitAPI/cocoa/DaemonTestUtilities.mm 2021-12-19 00:21:24 UTC (rev 287233)
+++ trunk/Tools/TestWebKitAPI/cocoa/DaemonTestUtilities.mm 2021-12-19 03:38:04 UTC (rev 287234)
@@ -65,27 +65,57 @@
return [currentExecutableLocation() URLByDeletingLastPathComponent];
}
-#if HAVE(OS_LAUNCHD_JOB)
+#if PLATFORM(IOS)
+static RetainPtr<xpc_object_t> convertArrayToXPC(NSArray *array)
+{
+ auto xpc = adoptNS(xpc_array_create(nullptr, 0));
+ for (id value in array) {
+ if ([value isKindOfClass:NSString.class])
+ xpc_array_set_string(xpc.get(), XPC_ARRAY_APPEND, [value UTF8String]);
+ else
+ ASSERT_NOT_REACHED();
+ }
+ return xpc;
+}
-void registerPlistWithLaunchD(RetainPtr<xpc_object_t>&& plist)
+static RetainPtr<xpc_object_t> convertDictionaryToXPC(NSDictionary<NSString *, id> *dictionary)
{
- NSError *error = nil;
- auto launchDJob = adoptNS([[OSLaunchdJob alloc] initWithPlist:plist.get()]);
- [launchDJob submit:&error];
-
- // In the iOS Simulator we often see the following error here:
- // Error Domain=OSLaunchdErrorDomain Code=17 "File exists"
- // Tests still behave as expected.
-#if PLATFORM(MAC)
- EXPECT_FALSE(error);
+ auto xpc = adoptNS(xpc_dictionary_create(nullptr, nullptr, 0));
+ for (NSString *key in dictionary) {
+ ASSERT([key isKindOfClass:NSString.class]);
+ const char* keyUTF8 = key.UTF8String;
+ id value = dictionary[key];
+ if ([value isKindOfClass:NSString.class])
+ xpc_dictionary_set_string(xpc.get(), keyUTF8, [value UTF8String]);
+ else if ([value isKindOfClass:NSNumber.class]) {
+ uint64_t uint64Value = [value unsignedLongLongValue];
+ if (uint64Value == 1)
+ xpc_dictionary_set_bool(xpc.get(), keyUTF8, uint64Value);
+ else {
+ ASSERT([value doubleValue] == uint64Value);
+ xpc_dictionary_set_uint64(xpc.get(), keyUTF8, uint64Value);
+ }
+ } else if ([value isKindOfClass:NSArray.class])
+ xpc_dictionary_set_value(xpc.get(), keyUTF8, convertArrayToXPC(value).get());
+ else if ([value isKindOfClass:NSDictionary.class])
+ xpc_dictionary_set_value(xpc.get(), keyUTF8, convertDictionaryToXPC(value).get());
+ else
+ ASSERT_NOT_REACHED();
+ }
+ return xpc;
+}
#endif
-}
-#else // HAVE(OS_LAUNCHD_JOB)
-
-void registerPlistWithLaunchD(RetainPtr<NSDictionary>&& plist, NSURL *tempDir)
+void registerPlistWithLaunchD(NSDictionary<NSString *, id> *plist, NSURL *tempDir)
{
NSError *error = nil;
+#if PLATFORM(IOS)
+ auto xpcPlist = convertDictionaryToXPC(plist);
+ xpc_dictionary_set_string(xpcPlist.get(), "_ManagedBy", "TestWebKitAPI");
+ xpc_dictionary_set_bool(xpcPlist.get(), "RootedSimulatorPath", true);
+ auto launchDJob = adoptNS([[OSLaunchdJob alloc] initWithPlist:xpcPlist.get()]);
+ [launchDJob submit:&error];
+#else
NSURL *plistLocation = [tempDir URLByAppendingPathComponent:@"DaemonInfo.plist"];
BOOL success = [[NSFileManager defaultManager] createDirectoryAtURL:tempDir withIntermediateDirectories:YES attributes:nil error:&error];
EXPECT_TRUE(success);
@@ -95,10 +125,9 @@
system([NSString stringWithFormat:@"launchctl unload %@ 2> /dev/null", plistLocation.path].fileSystemRepresentation);
system([NSString stringWithFormat:@"launchctl load %@", plistLocation.path].fileSystemRepresentation);
EXPECT_FALSE(error);
+#endif
}
-#endif // HAVE(OS_LAUNCHD_JOB)
-
static int pidOfFirstDaemonInstance(NSString *daemonExecutableName)
{
auto task = adoptNS([[NSTask alloc] init]);