Changeset 287009 in webkit
- Timestamp:
- Dec 13, 2021, 8:23:27 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 20 edited
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/inspector/ConsoleMessage.h (modified) (1 diff)
-
Source/JavaScriptCore/inspector/JSGlobalObjectConsoleClient.h (modified) (1 diff)
-
Source/JavaScriptCore/runtime/ConsoleTypes.h (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/page/PageConsoleClient.h (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/Configurations/webpushtool.xcconfig (modified) (1 diff)
-
Source/WebKit/Resources/webpushtool.entitlements (modified) (1 diff)
-
Source/WebKit/Shared/Daemon/DaemonUtilities.mm (modified) (1 diff)
-
Source/WebKit/webpushd/AppBundleRequest.mm (modified) (1 diff)
-
Source/WebKit/webpushd/PushClientConnection.h (modified) (2 diffs)
-
Source/WebKit/webpushd/PushClientConnection.mm (modified) (2 diffs)
-
Source/WebKit/webpushd/WebPushDaemon.h (modified) (1 diff)
-
Source/WebKit/webpushd/WebPushDaemon.mm (modified) (1 diff)
-
Source/WebKit/webpushd/webpushtool/WebPushToolConnection.h (modified) (2 diffs)
-
Source/WebKit/webpushd/webpushtool/WebPushToolConnection.mm (modified) (3 diffs)
-
Source/WebKit/webpushd/webpushtool/WebPushToolMain.mm (modified) (5 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r286994 r287009 1 2021-12-13 Brady Eidson <beidson@apple.com> 2 3 Teach webpushtool to register and "host" the daemon. 4 https://bugs.webkit.org/show_bug.cgi?id=234265 5 6 Reviewed by Tim Horton. 7 8 * inspector/ConsoleMessage.h: Remove `using JSC::MessageType` because it makes it hard for others 9 to also have a `MessageType` type. 10 * inspector/JSGlobalObjectConsoleClient.h: 11 * runtime/ConsoleTypes.h: 12 1 13 2021-12-13 Saam Barati <sbarati@apple.com> 2 14 -
trunk/Source/JavaScriptCore/inspector/ConsoleMessage.h
r272499 r287009 43 43 class JSGlobalObject; 44 44 } 45 46 using JSC::MessageType; 45 47 46 48 namespace Inspector { -
trunk/Source/JavaScriptCore/inspector/JSGlobalObjectConsoleClient.h
r262673 r287009 29 29 #include <wtf/Vector.h> 30 30 #include <wtf/text/WTFString.h> 31 32 using JSC::MessageType; 31 33 32 34 namespace Inspector { -
trunk/Source/JavaScriptCore/runtime/ConsoleTypes.h
r271735 r287009 116 116 117 117 using JSC::MessageSource; 118 using JSC::MessageType;119 118 using JSC::MessageLevel; -
trunk/Source/WebCore/ChangeLog
r287002 r287009 1 2021-12-13 Brady Eidson <beidson@apple.com> 2 3 Teach webpushtool to register and "host" the daemon. 4 https://bugs.webkit.org/show_bug.cgi?id=234265 5 6 Reviewed by Tim Horton. 7 8 * page/PageConsoleClient.h: 9 1 10 2021-12-13 Commit Queue <commit-queue@webkit.org> 2 11 -
trunk/Source/WebCore/page/PageConsoleClient.h
r260415 r287009 40 40 class CallFrame; 41 41 } 42 43 using JSC::MessageType; 42 44 43 45 namespace WebCore { -
trunk/Source/WebKit/ChangeLog
r287002 r287009 1 2021-12-13 Brady Eidson <beidson@apple.com> 2 3 Teach webpushtool to register and "host" the daemon. 4 https://bugs.webkit.org/show_bug.cgi?id=234265 5 6 Reviewed by Tim Horton. 7 8 Covered by API tests verifying hosting mode operation. 9 10 As various engineers work on various parts of the project, it's become apparent that it's super useful 11 to have a tool handle the "setting up" of the daemon itself, to avoid launchctl, etc. 12 13 Implement that, as well as a few other niceties found while testing. 14 15 * Configurations/webpushtool.xcconfig: 16 * Resources/webpushtool.entitlements: 17 18 * Shared/Daemon/DaemonUtilities.mm: 19 (WebKit::startListeningForMachServiceConnections): 20 21 * webpushd/AppBundleRequest.mm: 22 (WebPushD::AppBundleRequest::start): 23 24 * webpushd/PushClientConnection.h: 25 * webpushd/PushClientConnection.mm: 26 (WebPushD::ClientConnection::setHostAppAuditTokenData): 27 (WebPushD::ClientConnection::broadcastDebugMessage): 28 29 * webpushd/WebPushDaemon.h: 30 * webpushd/WebPushDaemon.mm: 31 (WebPushD::Daemon::broadcastAllConnectionIdentities): 32 33 * webpushd/webpushtool/WebPushToolConnection.h: 34 * webpushd/webpushtool/WebPushToolConnection.mm: 35 (WebPushTool::Connection::connectToService): 36 (WebPushTool::Connection::connectionDropped): 37 38 * webpushd/webpushtool/WebPushToolMain.mm: 39 (printUsageAndTerminate): 40 (registerDaemonWithLaunchD): 41 (main): 42 1 43 2021-12-13 Commit Queue <commit-queue@webkit.org> 2 44 -
trunk/Source/WebKit/Configurations/webpushtool.xcconfig
r286832 r287009 30 30 EXCLUDED_SOURCE_FILE_NAMES[sdk=watch*] = *; 31 31 32 OTHER_LDFLAGS = -framework Foundation -framework CoreFoundation -framework WebKit -framework JavaScriptCore 32 WK_APPSERVERSUPPORT_LDFLAGS = $(WK_APPSERVERSUPPORT_LDFLAGS_$(WK_PLATFORM_NAME)); 33 WK_APPSERVERSUPPORT_LDFLAGS_macosx = $(WK_APPSERVERSUPPORT_LDFLAGS$(WK_MACOS_1200)); 34 WK_APPSERVERSUPPORT_LDFLAGS_MACOS_SINCE_1200 = -framework AppServerSupport 35 WK_APPSERVERSUPPORT_LDFLAGS_iphoneos = $(WK_APPSERVERSUPPORT_LDFLAGS$(WK_IOS_15)); 36 WK_APPSERVERSUPPORT_LDFLAGS_iphonesimulator = $(WK_APPSERVERSUPPORT_LDFLAGS$(WK_IOS_15)); 37 WK_APPSERVERSUPPORT_LDFLAGS_IOS_SINCE_15 = -framework AppServerSupport 38 39 OTHER_LDFLAGS = -framework Foundation -framework CoreFoundation -framework WebKit -framework JavaScriptCore $(WK_APPSERVERSUPPORT_LDFLAGS) 33 40 LIBRARY_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR); 34 41 -
trunk/Source/WebKit/Resources/webpushtool.entitlements
r286788 r287009 7 7 <key>com.apple.private.webkit.webpush.inject</key> 8 8 <true/> 9 <key>com.apple.private.xpc.launchd.job-manager</key> 10 <string>webpushtool</string> 9 11 </dict> 10 12 </plist> -
trunk/Source/WebKit/Shared/Daemon/DaemonUtilities.mm
r284823 r287009 55 55 NSLog(@"Failed to start listening for connections to mach service %s, likely because it is not registered with launchd", serviceName); 56 56 #endif 57 NSLog(@"Removing peer connection %p", peer); 58 connectionRemoved(peer); 59 return; 57 60 } 58 61 if (event == XPC_ERROR_CONNECTION_INTERRUPTED) { -
trunk/Source/WebKit/webpushd/AppBundleRequest.mm
r286579 r287009 54 54 if (m_connection->useMockBundlesForTesting()) 55 55 m_appBundle = MockAppBundleForTesting::create(m_originString, m_connection->hostAppCodeSigningIdentifier(), *this); 56 else 56 else { 57 m_connection->broadcastDebugMessage("Client is trying to initiate app bundle request without having configured mock app bundles for testing. About to crash..."); 57 58 RELEASE_ASSERT_NOT_REACHED(); 59 } 58 60 59 61 startInternal(); -
trunk/Source/WebKit/webpushd/PushClientConnection.h
r286788 r287009 29 29 #include <wtf/Deque.h> 30 30 #include <wtf/Forward.h> 31 #include <wtf/Identified.h> 31 32 #include <wtf/OSObjectPtr.h> 32 33 #include <wtf/RefCounted.h> … … 46 47 class AppBundleRequest; 47 48 48 class ClientConnection : public RefCounted<ClientConnection>, public CanMakeWeakPtr<ClientConnection> {49 class ClientConnection : public RefCounted<ClientConnection>, public CanMakeWeakPtr<ClientConnection>, public Identified<ClientConnection> { 49 50 WTF_MAKE_FAST_ALLOCATED; 50 51 public: -
trunk/Source/WebKit/webpushd/PushClientConnection.mm
r286788 r287009 74 74 75 75 m_hostAppAuditToken = WTFMove(token); 76 Daemon::singleton().broadcastAllConnectionIdentities(); 76 77 } 77 78 … … 122 123 auto signingIdentifer = hostAppCodeSigningIdentifier(); 123 124 if (signingIdentifer.isEmpty()) 124 messageIdentifier = makeString("[(0x", hex(reinterpret_cast<uint64_t>(m_xpcConnection.get()), WTF::HexConversionMode::Lowercase), ") ] ");125 messageIdentifier = makeString("[(0x", hex(reinterpret_cast<uint64_t>(m_xpcConnection.get()), WTF::HexConversionMode::Lowercase), ") (", String::number(identifier()), " )] "); 125 126 else 126 messageIdentifier = makeString("[", signingIdentifer, " ( 0x", hex(reinterpret_cast<uint64_t>(m_xpcConnection.get()), WTF::HexConversionMode::Lowercase), ")] ");127 messageIdentifier = makeString("[", signingIdentifer, " (", String::number(identifier()), ")] "); 127 128 128 129 Daemon::singleton().broadcastDebugMessage(JSC::MessageLevel::Info, makeString(messageIdentifier, message)); -
trunk/Source/WebKit/webpushd/WebPushDaemon.h
r286878 r287009 71 71 72 72 void broadcastDebugMessage(JSC::MessageLevel, const String&); 73 void broadcastAllConnectionIdentities(); 73 74 74 75 private: -
trunk/Source/WebKit/webpushd/WebPushDaemon.mm
r286878 r287009 186 186 } 187 187 188 void Daemon::broadcastAllConnectionIdentities() 189 { 190 broadcastDebugMessage((JSC::MessageLevel)4, "===\nCurrent connections:"); 191 for (auto& iterator : m_connectionMap) 192 iterator.value->broadcastDebugMessage(""); 193 broadcastDebugMessage((JSC::MessageLevel)4, "==="); 194 } 195 188 196 void Daemon::connectionEventHandler(xpc_object_t request) 189 197 { -
trunk/Source/WebKit/webpushd/webpushtool/WebPushToolConnection.h
r286788 r287009 42 42 43 43 enum class PreferTestService : bool { 44 No, 44 45 Yes, 45 No,46 46 }; 47 47 48 48 enum class Reconnect : bool { 49 No, 49 50 Yes, 51 }; 52 53 enum class WaitForServiceToExist : bool { 50 54 No, 55 Yes, 51 56 }; 52 57 … … 57 62 Connection(Action, PreferTestService, Reconnect); 58 63 59 void connectToService( );64 void connectToService(WaitForServiceToExist); 60 65 61 66 void setPushMessage(std::unique_ptr<PushMessageForTesting>&& message) { m_pushMessage = WTFMove(message); } -
trunk/Source/WebKit/webpushd/webpushtool/WebPushToolConnection.mm
r286788 r287009 67 67 } 68 68 69 void Connection::connectToService( )69 void Connection::connectToService(WaitForServiceToExist waitForServiceToExist) 70 70 { 71 71 if (m_connection) … … 100 100 }); 101 101 102 auto result = maybeConnectToService(m_serviceName); 103 if (result == MACH_PORT_NULL) 104 printf("Waiting for service '%s' to be available\n", m_serviceName); 105 106 while (result == MACH_PORT_NULL) { 107 usleep(1000); 108 result = maybeConnectToService(m_serviceName); 102 if (waitForServiceToExist == WaitForServiceToExist::Yes) { 103 auto result = maybeConnectToService(m_serviceName); 104 if (result == MACH_PORT_NULL) 105 printf("Waiting for service '%s' to be available\n", m_serviceName); 106 107 while (result == MACH_PORT_NULL) { 108 usleep(1000); 109 result = maybeConnectToService(m_serviceName); 110 } 109 111 } 110 112 … … 185 187 callOnMainRunLoop([this, weakThis = WeakPtr { this }] { 186 188 if (weakThis) 187 connectToService( );189 connectToService(WaitForServiceToExist::Yes); 188 190 }); 189 191 return; -
trunk/Source/WebKit/webpushd/webpushtool/WebPushToolMain.mm
r286788 r287009 44 44 fprintf(stderr, " --production\n"); 45 45 fprintf(stderr, " Connects to mach service \"com.apple.webkit.webpushd.service\"\n"); 46 #if HAVE(OS_LAUNCHD_JOB) 47 fprintf(stderr, " --host\n"); 48 fprintf(stderr, " Dynamically registers the service with launchd so it is visible to other applications\n"); 49 fprintf(stderr, " The service name of the registration depends on either the --development or --production option chosen\n"); 50 #endif 46 51 fprintf(stderr, " --streamDebugMessages\n"); 47 52 fprintf(stderr, " Stream debug messages from webpushd\n"); … … 77 82 } 78 83 84 #if HAVE(OS_LAUNCHD_JOB) 85 static bool registerDaemonWithLaunchD(WebPushTool::PreferTestService preferTestService) 86 { 87 // For now webpushtool only knows how to host webpushd when they're in the same directory 88 // e.g. the build directory of a WebKit contributor. 89 NSString *currentExecutablePath = [[NSBundle mainBundle] executablePath]; 90 NSURL *currentExecutableDirectoryURL = [[NSURL fileURLWithPath:currentExecutablePath isDirectory:NO] URLByDeletingLastPathComponent]; 91 NSURL *daemonExecutablePathURL = [currentExecutableDirectoryURL URLByAppendingPathComponent:@"webpushd"]; 92 93 if (![[NSFileManager defaultManager] fileExistsAtPath:daemonExecutablePathURL.path]) { 94 NSLog(@"Daemon executable does not exist at path %@", daemonExecutablePathURL.path); 95 return false; 96 } 97 98 const char* serviceName = (preferTestService == WebPushTool::PreferTestService::Yes) ? "org.webkit.webpushtestdaemon.service" : "com.apple.webkit.webpushd.service"; 99 100 auto plist = adoptNS(xpc_dictionary_create(nullptr, nullptr, 0)); 101 xpc_dictionary_set_string(plist.get(), "_ManagedBy", "webpushtool"); 102 xpc_dictionary_set_string(plist.get(), "Label", "org.webkit.webpushtestdaemon"); 103 xpc_dictionary_set_bool(plist.get(), "LaunchOnlyOnce", true); 104 xpc_dictionary_set_bool(plist.get(), "RootedSimulatorPath", true); 105 106 { 107 auto environmentVariables = adoptNS(xpc_dictionary_create(nullptr, nullptr, 0)); 108 xpc_dictionary_set_string(environmentVariables.get(), "DYLD_FRAMEWORK_PATH", currentExecutableDirectoryURL.fileSystemRepresentation); 109 xpc_dictionary_set_value(plist.get(), "EnvironmentVariables", environmentVariables.get()); 110 } 111 { 112 auto machServices = adoptNS(xpc_dictionary_create(nullptr, nullptr, 0)); 113 xpc_dictionary_set_bool(machServices.get(), serviceName, true); 114 xpc_dictionary_set_value(plist.get(), "MachServices", machServices.get()); 115 } 116 { 117 auto programArguments = adoptNS(xpc_array_create(nullptr, 0)); 118 #if PLATFORM(MAC) 119 xpc_array_set_string(programArguments.get(), XPC_ARRAY_APPEND, daemonExecutablePathURL.fileSystemRepresentation); 120 #else 121 xpc_array_set_string(programArguments.get(), XPC_ARRAY_APPEND, daemonExecutablePathURL.path.fileSystemRepresentation); 122 #endif 123 xpc_array_set_string(programArguments.get(), XPC_ARRAY_APPEND, "--machServiceName"); 124 xpc_array_set_string(programArguments.get(), XPC_ARRAY_APPEND, serviceName); 125 xpc_dictionary_set_value(plist.get(), "ProgramArguments", programArguments.get()); 126 } 127 128 auto job = adoptNS([[OSLaunchdJob alloc] initWithPlist:plist.get()]); 129 NSError *error = nil; 130 [job submit:&error]; 131 132 if (error) { 133 NSLog(@"Error setting up service: %@", error); 134 return false; 135 } 136 137 return true; 138 } 139 #endif // #if HAVE(OS_LAUNCHD_JOB) 140 79 141 int main(int, const char **) 80 142 { … … 83 145 auto preferTestService = WebPushTool::PreferTestService::Yes; 84 146 auto reconnect = WebPushTool::Reconnect::No; 147 bool host = false; 85 148 std::optional<WebPushTool::Action> action; 86 149 std::unique_ptr<PushMessageForTesting> pushMessage; … … 102 165 else if ([argument isEqualToString:@"--reconnect"]) 103 166 reconnect = WebPushTool::Reconnect::Yes; 167 #if HAVE(OS_LAUNCHD_JOB) 168 else if ([argument isEqualToString:@"--host"]) 169 host = true; 170 #endif 104 171 else if ([argument isEqualToString:@"--push"]) { 105 172 pushMessage = pushMessageFromArguments(enumerator); … … 116 183 printUsageAndTerminate(@"No action provided"); 117 184 185 #if HAVE(OS_LAUNCHD_JOB) 186 if (host && !registerDaemonWithLaunchD(preferTestService)) 187 printUsageAndTerminate(@"Unable to install plist to host the service"); 188 #endif 189 118 190 auto connection = WebPushTool::Connection::create(*action, preferTestService, reconnect); 119 191 if (pushMessage) 120 192 connection->setPushMessage(WTFMove(pushMessage)); 121 193 122 connection->connectToService( );194 connection->connectToService(host ? WebPushTool::WaitForServiceToExist::No : WebPushTool::WaitForServiceToExist::Yes); 123 195 124 196 CFRunLoopRun(); -
trunk/Tools/ChangeLog
r287000 r287009 1 2021-12-13 Brady Eidson <beidson@apple.com> 2 3 Teach webpushtool to register and "host" the daemon. 4 https://bugs.webkit.org/show_bug.cgi?id=234265 5 6 Reviewed by Tim Horton. 7 8 * TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm: 9 (TestWebKitAPI::shouldSetupWebPushD): Add a command line argument to skip the "install the daemon" step, 10 so an engineer can handle that part themselves. 11 (TestWebKitAPI::setUpTestWebPushD): 12 (TestWebKitAPI::cleanUpTestWebPushD): 13 1 14 2021-12-13 Christopher Reid <chris.reid@sony.com> 2 15 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm
r286788 r287009 126 126 #endif // HAVE(OS_LAUNCHD_JOB) 127 127 128 static bool shouldSetupWebPushD() 129 { 130 static bool shouldSetup = true; 131 static dispatch_once_t onceToken; 132 dispatch_once(&onceToken, ^{ 133 NSArray<NSString *> *arguments = [[NSProcessInfo processInfo] arguments]; 134 if ([arguments containsObject:@"--no-webpushd"]) 135 shouldSetup = false; 136 }); 137 138 return shouldSetup; 139 } 140 128 141 static NSURL *setUpTestWebPushD() 129 142 { 143 if (!shouldSetupWebPushD()) 144 return nil; 145 130 146 NSFileManager *fileManager = [NSFileManager defaultManager]; 131 147 NSURL *tempDir = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:@"WebPushDaemonTest"] isDirectory:YES]; … … 149 165 static void cleanUpTestWebPushD(NSURL *tempDir) 150 166 { 167 if (!shouldSetupWebPushD()) 168 return; 169 151 170 killFirstInstanceOfDaemon(@"webpushd"); 152 171 … … 243 262 244 263 // FIXME: Re-enable this test on Mac once webkit.org/232857 is resolved. 245 #if PLATFORM(MAC) 264 #if PLATFORM(MAC) && !USE(APPLE_INTERNAL_SDK) 246 265 TEST(WebPushD, DISABLED_BasicCommunication) 247 266 #else … … 322 341 323 342 // FIXME: Re-enable this test on Mac once webkit.org/232857 is resolved. 324 #if PLATFORM(MAC) 343 #if PLATFORM(MAC) && !USE(APPLE_INTERNAL_SDK) 325 344 TEST(WebPushD, DISABLED_PermissionManagement) 326 345 #else … … 455 474 456 475 // FIXME: Re-enable this test on Mac once webkit.org/232857 is resolved. 457 #if PLATFORM(MAC) 476 #if PLATFORM(MAC) && !USE(APPLE_INTERNAL_SDK) 458 477 TEST(WebPushD, DISABLED_HandleInjectedPush) 459 478 #else
Note:
See TracChangeset
for help on using the changeset viewer.