Changeset 285799 in webkit
- Timestamp:
- Nov 14, 2021, 11:17:34 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 14 edited
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm (modified) (2 diffs)
-
Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h (modified) (2 diffs)
-
Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h (modified) (2 diffs)
-
Source/WebKit/UIProcess/Cocoa/UIDelegate.h (modified) (4 diffs)
-
Source/WebKit/UIProcess/Cocoa/UIDelegate.mm (modified) (4 diffs)
-
Source/WebKit/WebKit.xcodeproj/project.pbxproj (modified) (2 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Configurations/TestWebKitAPI-iOS.entitlements (modified) (1 diff)
-
Tools/TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm (modified) (9 diffs)
-
Tools/TestWebKitAPI/cocoa/DaemonTestUtilities.h (modified) (3 diffs)
-
Tools/TestWebKitAPI/cocoa/DaemonTestUtilities.mm (modified) (4 diffs)
-
WebKitLibraries/ChangeLog (modified) (1 diff)
-
WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/15/AppServerSupport.framework (added)
-
WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/15/AppServerSupport.framework/AppServerSupport.tbd (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r285798 r285799 1 2021-11-14 Brady Eidson <beidson@apple.com> 2 3 Get daemon API ready to work in the iOS simulator (starting with WebPushD) 4 https://bugs.webkit.org/show_bug.cgi?id=232982 5 6 Reviewed by Geoff Garen. 7 8 Move all the "enable Notifications" SPI from Mac-only to cross platform: 9 * UIProcess/API/Cocoa/WKPreferences.mm: 10 (-[WKPreferences _setNotificationsEnabled:]): 11 (-[WKPreferences _notificationsEnabled]): 12 * UIProcess/API/Cocoa/WKPreferencesPrivate.h: 13 * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: 14 * UIProcess/Cocoa/UIDelegate.h: 15 * UIProcess/Cocoa/UIDelegate.mm: 16 (WebKit::UIDelegate::setDelegate): 17 (WebKit::UIDelegate::UIClient::decidePolicyForNotificationPermissionRequest): 18 19 * WebKit.xcodeproj/project.pbxproj: Add a build phase script to install the daemon executables 20 inside a Daemons directory within the built WebKit.framework for engineering builds. 21 * webpushd/WebPushDaemon.mm: 22 1 23 2021-11-14 Fujii Hironori <Hironori.Fujii@sony.com> 2 24 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm
r285741 r285799 1164 1164 } 1165 1165 1166 - (void)_setNotificationsEnabled:(BOOL)enabled1167 {1168 _preferences->setNotificationsEnabled(enabled);1169 }1170 1171 - (BOOL)_notificationsEnabled1172 {1173 return _preferences->notificationsEnabled();1174 }1175 1176 1166 - (void)_setBackspaceKeyNavigationEnabled:(BOOL)enabled 1177 1167 { … … 1565 1555 } 1566 1556 1557 - (void)_setNotificationsEnabled:(BOOL)enabled 1558 { 1559 _preferences->setNotificationsEnabled(enabled); 1560 } 1561 1562 - (BOOL)_notificationsEnabled 1563 { 1564 return _preferences->notificationsEnabled(); 1565 } 1566 1567 1567 @end 1568 1568 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h
r284214 r285799 177 177 @property (nonatomic, setter=_setStorageAPIEnabled:) BOOL _storageAPIEnabled WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 178 178 @property (nonatomic, setter=_setAccessHandleEnabled:) BOOL _accessHandleEnabled WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 179 @property (nonatomic, setter=_setNotificationsEnabled:) BOOL _notificationsEnabled WK_API_AVAILABLE(macos(10.13.4), ios(WK_IOS_TBA)); 179 180 180 181 #if !TARGET_OS_IPHONE … … 201 202 @property (nonatomic, setter=_setViewGestureDebuggingEnabled:) BOOL _viewGestureDebuggingEnabled WK_API_AVAILABLE(macos(10.13.4)); 202 203 @property (nonatomic, setter=_setStandardFontFamily:) NSString *_standardFontFamily WK_API_AVAILABLE(macos(10.13.4)); 203 @property (nonatomic, setter=_setNotificationsEnabled:) BOOL _notificationsEnabled WK_API_AVAILABLE(macos(10.13.4));204 204 @property (nonatomic, setter=_setBackspaceKeyNavigationEnabled:) BOOL _backspaceKeyNavigationEnabled WK_API_AVAILABLE(macos(10.13.4)); 205 205 @property (nonatomic, setter=_setAllowsInlineMediaPlayback:) BOOL _allowsInlineMediaPlayback WK_API_AVAILABLE(macos(10.14)); -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h
r285444 r285799 160 160 161 161 - (void)_webView:(WKWebView *)webView startXRSessionWithCompletionHandler:(void (^)(id))completionHandler WK_API_AVAILABLE(macos(12.0), ios(15.0)); 162 - (void)_webView:(WKWebView *)webView requestNotificationPermissionForSecurityOrigin:(WKSecurityOrigin *)securityOrigin decisionHandler:(void (^)(BOOL))decisionHandler WK_API_AVAILABLE(macos(10.13.4)); 162 163 163 164 #if TARGET_OS_IPHONE … … 245 246 - (void)_webView:(WKWebView *)webView drawHeaderInRect:(CGRect)rect forPageWithTitle:(NSString *)title URL:(NSURL *)url WK_API_AVAILABLE(macos(10.13.4)); 246 247 - (void)_webView:(WKWebView *)webView drawFooterInRect:(CGRect)rect forPageWithTitle:(NSString *)title URL:(NSURL *)url WK_API_AVAILABLE(macos(10.13.4)); 247 - (void)_webView:(WKWebView *)webView requestNotificationPermissionForSecurityOrigin:(WKSecurityOrigin *)securityOrigin decisionHandler:(void (^)(BOOL))decisionHandler WK_API_AVAILABLE(macos(10.13.4));248 248 - (void)_webView:(WKWebView *)webview mouseDidMoveOverElement:(_WKHitTestResult *)hitTestResult withFlags:(NSEventModifierFlags)flags userInfo:(id <NSSecureCoding>)userInfo; 249 249 - (void)_webView:(WKWebView *)webView didExceedBackgroundResourceLimitWhileInForeground:(_WKResourceLimit)limit WK_API_AVAILABLE(macos(10.13.4)); -
trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h
r285444 r285799 106 106 bool takeFocus(WebPageProxy*, WKFocusDirection) final; 107 107 void handleAutoplayEvent(WebPageProxy&, WebCore::AutoplayEvent, OptionSet<WebCore::AutoplayEventFlags>) final; 108 void decidePolicyForNotificationPermissionRequest(WebPageProxy&, API::SecurityOrigin&, CompletionHandler<void(bool allowed)>&&) final; 109 108 110 #if PLATFORM(MAC) 109 111 void showPage(WebPageProxy*) final; … … 124 126 void drawFooter(WebPageProxy&, WebFrameProxy&, WebCore::FloatRect&&) final; 125 127 126 void decidePolicyForNotificationPermissionRequest(WebPageProxy&, API::SecurityOrigin&, CompletionHandler<void(bool allowed)>&&) final;127 128 void mouseDidMoveOverElement(WebPageProxy&, const WebHitTestResultData&, OptionSet<WebEvent::Modifier>, API::Object*); 128 129 void didClickAutoFillButton(WebPageProxy&, API::Object*) final; … … 216 217 bool webViewSaveDataToFileSuggestedFilenameMimeTypeOriginatingURL : 1; 217 218 bool webViewRunOpenPanelWithParametersInitiatedByFrameCompletionHandler : 1; 218 bool webViewRequestNotificationPermissionForSecurityOriginDecisionHandler : 1;219 219 bool webViewConfigurationForLocalInspector : 1; 220 220 bool webViewDidAttachLocalInspector : 1; … … 268 268 bool webViewStartXRSessionWithCompletionHandler : 1; 269 269 #endif 270 bool webViewRequestNotificationPermissionForSecurityOriginDecisionHandler : 1; 270 271 } m_delegateMethods; 271 272 }; -
trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm
r285444 r285799 139 139 m_delegateMethods.webViewSaveDataToFileSuggestedFilenameMimeTypeOriginatingURL = [delegate respondsToSelector:@selector(_webView:saveDataToFile:suggestedFilename:mimeType:originatingURL:)]; 140 140 m_delegateMethods.webViewRunOpenPanelWithParametersInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runOpenPanelWithParameters:initiatedByFrame:completionHandler:)]; 141 m_delegateMethods.webViewRequestNotificationPermissionForSecurityOriginDecisionHandler = [delegate respondsToSelector:@selector(_webView:requestNotificationPermissionForSecurityOrigin:decisionHandler:)];142 141 m_delegateMethods.webViewConfigurationForLocalInspector = [delegate respondsToSelector:@selector(_webView:configurationForLocalInspector:)]; 143 142 m_delegateMethods.webViewDidAttachLocalInspector = [delegate respondsToSelector:@selector(_webView:didAttachLocalInspector:)]; … … 197 196 m_delegateMethods.webViewStartXRSessionWithCompletionHandler = [delegate respondsToSelector:@selector(_webView:startXRSessionWithCompletionHandler:)]; 198 197 #endif 198 m_delegateMethods.webViewRequestNotificationPermissionForSecurityOriginDecisionHandler = [delegate respondsToSelector:@selector(_webView:requestNotificationPermissionForSecurityOrigin:decisionHandler:)]; 199 199 } 200 200 … … 620 620 } 621 621 622 void UIDelegate::UIClient::decidePolicyForNotificationPermissionRequest(WebKit::WebPageProxy&, API::SecurityOrigin& securityOrigin, CompletionHandler<void(bool allowed)>&& completionHandler) 623 { 624 if (!m_uiDelegate) 625 return completionHandler(false); 626 627 if (!m_uiDelegate->m_delegateMethods.webViewRequestNotificationPermissionForSecurityOriginDecisionHandler) 628 return completionHandler(false); 629 630 auto delegate = m_uiDelegate->m_delegate.get(); 631 if (!delegate) 632 return completionHandler(false); 633 634 auto checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(_webView:requestNotificationPermissionForSecurityOrigin:decisionHandler:)); 635 [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate->m_webView.get().get() requestNotificationPermissionForSecurityOrigin:wrapper(securityOrigin) decisionHandler:makeBlockPtr([completionHandler = WTFMove(completionHandler), checker = WTFMove(checker)] (BOOL result) mutable { 636 if (checker->completionHandlerHasBeenCalled()) 637 return; 638 checker->didCallCompletionHandler(); 639 completionHandler(result); 640 }).get()]; 641 } 642 622 643 #if PLATFORM(MAC) 623 644 bool UIDelegate::UIClient::canRunModal() const … … 920 941 921 942 [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate->m_webView.get().get() saveDataToFile:wrapper(data) suggestedFilename:suggestedFilename mimeType:mimeType originatingURL:originatingURL]; 922 }923 924 void UIDelegate::UIClient::decidePolicyForNotificationPermissionRequest(WebKit::WebPageProxy&, API::SecurityOrigin& securityOrigin, CompletionHandler<void(bool allowed)>&& completionHandler)925 {926 if (!m_uiDelegate)927 return completionHandler(false);928 929 if (!m_uiDelegate->m_delegateMethods.webViewRequestNotificationPermissionForSecurityOriginDecisionHandler)930 return completionHandler(false);931 932 auto delegate = m_uiDelegate->m_delegate.get();933 if (!delegate)934 return completionHandler(false);935 936 auto checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(_webView:requestNotificationPermissionForSecurityOrigin:decisionHandler:));937 [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate->m_webView.get().get() requestNotificationPermissionForSecurityOrigin:wrapper(securityOrigin) decisionHandler:makeBlockPtr([completionHandler = WTFMove(completionHandler), checker = WTFMove(checker)] (BOOL result) mutable {938 if (checker->completionHandlerHasBeenCalled())939 return;940 checker->didCallCompletionHandler();941 completionHandler(result);942 }).get()];943 943 } 944 944 -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r285770 r285799 13239 13239 5379C7AC21E5288500E4A8F6 /* Check .xcfilelists */, 13240 13240 933170072234674500B32554 /* Create symlinks to XPC services for engineering builds */, 13241 512B81CA273CAFBE00D87D49 /* Create symlinks to Daemons for engineering builds */, 13241 13242 0FB94836239F31B700926A8F /* Copy Testing Headers */, 13242 13243 DFD03A29270D5F57001A996E /* Copy Daemon Plists */, … … 13731 13732 shellPath = /bin/sh; 13732 13733 shellScript = "Scripts/process-entitlements.sh\n"; 13734 }; 13735 512B81CA273CAFBE00D87D49 /* Create symlinks to Daemons for engineering builds */ = { 13736 isa = PBXShellScriptBuildPhase; 13737 buildActionMask = 2147483647; 13738 files = ( 13739 ); 13740 inputFileListPaths = ( 13741 ); 13742 inputPaths = ( 13743 ); 13744 name = "Create symlinks to Daemons for engineering builds"; 13745 outputFileListPaths = ( 13746 ); 13747 outputPaths = ( 13748 ); 13749 runOnlyForDeploymentPostprocessing = 0; 13750 shellPath = /bin/sh; 13751 shellScript = "if [[ \"${DEPLOYMENT_LOCATION}\" == \"YES\" ]]; then\n exit\nfi\n\n# If we move the Mac Daemons path to WebKit.framework/Versions/A/Daemons,\n# in addition to a Mac-specific plists, the Mac paths below have to be updated as well.\nif [[ ${WK_PLATFORM_NAME} != \"macosx\" ]]; then\n DAEMONS_PATH=\"${BUILT_PRODUCTS_DIR}/WebKit.framework/Daemons\"\n BUILT_PRODUCTS_DIR_RELATIVE_PATH_FROM_DAEMONS=\"../..\"\nelse\n DAEMONS_PATH=\"${BUILT_PRODUCTS_DIR}/WebKit.framework/Daemons\"\n BUILT_PRODUCTS_DIR_RELATIVE_PATH_FROM_DAEMONS=\"../..\"\nfi\n\nmkdir -p \"${DAEMONS_PATH}\"\nln -sFh \"${BUILT_PRODUCTS_DIR_RELATIVE_PATH_FROM_DAEMONS}/webpushd\" \"${DAEMONS_PATH}/webpushd\"\nln -sFh \"${BUILT_PRODUCTS_DIR_RELATIVE_PATH_FROM_DAEMONS}/adattributiond\" \"${DAEMONS_PATH}/adattributiond\"\n"; 13733 13752 }; 13734 13753 5325BDD221DFF47C00A0DEE1 /* ShellScript */ = { -
trunk/Tools/ChangeLog
r285781 r285799 1 2021-11-14 Brady Eidson <beidson@apple.com> 2 3 Get daemon API ready to work in the iOS simulator (starting with WebPushD) 4 https://bugs.webkit.org/show_bug.cgi?id=232982 5 6 Reviewed by Geoff Garen. 7 8 To get this working we needed to: 9 - Have the Daemons installed in a simulator-runtime-root-visible path 10 - Point the OSLaunchDJob plist to the simulator-relative path, not Mac-relative 11 - Solve the "How do I kill existing instances to run a clean test?" problem within the simulator. 12 13 This patch does those things. 14 15 * TestWebKitAPI/Configurations/TestWebKitAPI-iOS.entitlements: 16 * TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig: 17 18 * TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm: 19 (TestWebKitAPI::testWebPushDaemonPList): 20 (TestWebKitAPI::setUpTestWebPushD): 21 (TestWebKitAPI::cleanUpTestWebPushD): 22 23 * TestWebKitAPI/cocoa/DaemonTestUtilities.h: 24 * TestWebKitAPI/cocoa/DaemonTestUtilities.mm: 25 (TestWebKitAPI::registerPlistWithLaunchD): 26 (TestWebKitAPI::pidOfFirstDaemonInstance): 27 (TestWebKitAPI::killFirstInstanceOfDaemon): 28 1 29 2021-11-13 Simon Fraser <simon.fraser@apple.com> 2 30 -
trunk/Tools/TestWebKitAPI/Configurations/TestWebKitAPI-iOS.entitlements
r285672 r285799 11 11 <key>com.apple.Pasteboard.paste-unchecked</key> 12 12 <true/> 13 <key>com.apple.private.xpc.launchd.job-manager</key> 14 <string>TestWebKitAPI</string> 13 15 </dict> 14 16 </plist> -
trunk/Tools/TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig
r284669 r285799 47 47 WK_APPSERVERSUPPORT_LDFLAGS_macosx = $(WK_APPSERVERSUPPORT_LDFLAGS$(WK_MACOS_1200)); 48 48 WK_APPSERVERSUPPORT_LDFLAGS_MACOS_SINCE_1200 = -framework AppServerSupport 49 WK_APPSERVERSUPPORT_LDFLAGS_iphoneos = $(WK_APPSERVERSUPPORT_LDFLAGS$(WK_IOS_15)); 50 WK_APPSERVERSUPPORT_LDFLAGS_iphonesimulator = $(WK_APPSERVERSUPPORT_LDFLAGS$(WK_IOS_15)); 51 WK_APPSERVERSUPPORT_LDFLAGS_IOS_SINCE_15 = -framework AppServerSupport 49 52 50 53 WK_AUTHKIT_LDFLAGS = $(WK_AUTHKIT_LDFLAGS_$(WK_PLATFORM_NAME)); -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm
r285547 r285799 33 33 #import <WebKit/_WKExperimentalFeature.h> 34 34 35 // FIXME: These tests are still currently disabled on iOS while tooling issues with `run-api-tests` are resolved. 36 #if PLATFORM(MAC) 37 35 38 static bool alertReceived = false; 36 39 @interface NotificationPermissionDelegate : NSObject<WKUIDelegatePrivate> … … 53 56 54 57 namespace TestWebKitAPI { 55 56 // FIXME: Get this working in the iOS simulator.57 #if PLATFORM(MAC)58 58 59 59 static RetainPtr<NSURL> testWebPushDaemonLocation() … … 85 85 auto programArguments = adoptNS(xpc_array_create(nullptr, 0)); 86 86 auto executableLocation = testWebPushDaemonLocation(); 87 #if PLATFORM(MAC) 87 88 xpc_array_set_string(programArguments.get(), XPC_ARRAY_APPEND, executableLocation.get().fileSystemRepresentation); 89 #else 90 // FIXME: These tests are still currently disabled on iOS while tooling issues with `run-api-tests` are resolved. 91 // Once enabled, this patch must point to the webpushd executable at a path that exists within 92 // the simulator runtime root. 93 xpc_array_set_string(programArguments.get(), XPC_ARRAY_APPEND, "/usr/local/bin/webkit-testing/webpushd"); 94 #endif 88 95 xpc_array_set_string(programArguments.get(), XPC_ARRAY_APPEND, "--machServiceName"); 89 96 xpc_array_set_string(programArguments.get(), XPC_ARRAY_APPEND, "org.webkit.webpushtestdaemon.service"); … … 122 129 EXPECT_NULL(error); 123 130 124 system("killall webpushd -9 2> /dev/null");131 killFirstInstanceOfDaemon(@"webpushd"); 125 132 126 133 auto plist = testWebPushDaemonPList(tempDir); … … 136 143 static void cleanUpTestWebPushD(NSURL *tempDir) 137 144 { 138 system("killall webpushd -9");145 killFirstInstanceOfDaemon(@"webpushd"); 139 146 140 147 EXPECT_TRUE([[NSFileManager defaultManager] fileExistsAtPath:tempDir.path]); … … 160 167 __block bool done = false; 161 168 xpc_connection_send_message_with_reply(connection.get(), dictionary.get(), dispatch_get_main_queue(), ^(xpc_object_t reply) { 169 if (xpc_get_type(reply) != XPC_TYPE_DICTIONARY) { 170 NSLog(@"Unexpected non-dictionary: %@", reply); 171 done = true; 172 EXPECT_TRUE(FALSE); 173 return; 174 } 175 162 176 size_t dataSize = 0; 163 177 const void* data = xpc_dictionary_get_data(reply, "encoded message", &dataSize); … … 188 202 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 189 203 configuration.get().websiteDataStore = dataStore.get(); 204 [configuration.get().preferences _setNotificationsEnabled:YES]; 190 205 for (_WKExperimentalFeature *feature in [WKPreferences _experimentalFeatures]) { 191 206 if ([feature.key isEqualToString:@"BuiltInNotificationsEnabled"]) … … 223 238 EXPECT_TRUE([origin.get().host isEqualToString:@"main"]); 224 239 240 // If we failed to retrieve an expected origin, we will have failed the above checks 241 if (!origin) { 242 cleanUpTestWebPushD(tempDirectory); 243 return; 244 } 245 225 246 originOperationDone = false; 226 247 [dataStore _deletePushAndNotificationRegistration:origin.get() completionHandler:^(NSError *error) { … … 241 262 } 242 263 264 } // namespace TestWebKitAPI 265 243 266 #endif // PLATFORM(MAC) 244 245 } // namespace TestWebKitAPI -
trunk/Tools/TestWebKitAPI/cocoa/DaemonTestUtilities.h
r284218 r285799 26 26 #pragma once 27 27 28 #if PLATFORM(MAC) || PLATFORM(IOS) 29 28 30 #import <wtf/RetainPtr.h> 29 31 #import <wtf/spi/darwin/XPCSPI.h> … … 36 38 RetainPtr<NSURL> currentExecutableDirectory(); 37 39 38 // FIXME: Get this working in the iOS simulator. 39 #if PLATFORM(MAC) 40 void killFirstInstanceOfDaemon(NSString *daemonExecutableName); 41 40 42 #if HAVE(OS_LAUNCHD_JOB) 41 43 void registerPlistWithLaunchD(RetainPtr<xpc_object_t>&&); … … 43 45 void registerPlistWithLaunchD(RetainPtr<NSDictionary>&&, NSURL *tempDir); 44 46 #endif 45 #endif46 47 47 48 } // namespace TestWebKitAPI 49 50 #endif // PLATFORM(MAC) || PLATFORM(IOS) 51 -
trunk/Tools/TestWebKitAPI/cocoa/DaemonTestUtilities.mm
r284218 r285799 27 27 #import "DaemonTestUtilities.h" 28 28 29 #if PLATFORM(MAC) || PLATFORM(IOS) 30 29 31 #import <mach-o/dyld.h> 30 32 #import <wtf/Vector.h> 33 34 NS_ASSUME_NONNULL_BEGIN 35 36 #if PLATFORM(IOS) 37 @interface NSTask : NSObject 38 - (instancetype)init; 39 - (void)launch; 40 - (void)waitUntilExit; 41 42 @property (nullable, copy) NSString *launchPath; 43 @property (nullable, copy) NSArray<NSString *> *arguments; 44 @property (nullable, retain) id standardOutput; 45 @property (readonly, getter=isRunning) BOOL running; 46 @end 47 #endif 31 48 32 49 namespace TestWebKitAPI { … … 49 66 } 50 67 51 // FIXME: Get this working in the iOS simulator.52 #if PLATFORM(MAC)53 68 #if HAVE(OS_LAUNCHD_JOB) 54 69 … … 58 73 auto launchDJob = adoptNS([[OSLaunchdJob alloc] initWithPlist:plist.get()]); 59 74 [launchDJob submit:&error]; 75 76 // In the iOS Simulator we often see the following error here: 77 // Error Domain=OSLaunchdErrorDomain Code=17 "File exists" 78 // Tests still behave as expected. 79 #if PLATFORM(MAC) 60 80 EXPECT_FALSE(error); 81 #endif 61 82 } 62 83 … … 78 99 79 100 #endif // HAVE(OS_LAUNCHD_JOB) 80 #endif // PLATFORM(MAC) 101 102 static int pidOfFirstDaemonInstance(NSString *daemonExecutableName) 103 { 104 auto task = adoptNS([[NSTask alloc] init]); 105 task.get().launchPath = @"/bin/ps"; 106 task.get().arguments = @[ 107 @"-ax", 108 @"-o", 109 @"pid,comm" 110 ]; 111 112 auto taskPipe = adoptNS([[NSPipe alloc] init]); 113 [task setStandardOutput:taskPipe.get()]; 114 [task launch]; 115 116 auto data = adoptNS([[NSMutableData alloc] init]); 117 while ([task isRunning]) 118 [data appendData:[[taskPipe fileHandleForReading] readDataToEndOfFile]]; 119 [data appendData:[[taskPipe fileHandleForReading] readDataToEndOfFile]]; 120 121 auto psString = adoptNS([[NSString alloc] initWithData:data.get() encoding:NSUTF8StringEncoding]); 122 NSArray<NSString *> *psEntries = [psString componentsSeparatedByString:@"\n"]; 123 124 for (NSString* entry in psEntries) { 125 if (![entry hasSuffix:daemonExecutableName]) 126 continue; 127 NSArray<NSString *> *components = [entry componentsSeparatedByString:@" "]; 128 EXPECT_GE([components count], 2u); 129 return [[components firstObject] integerValue]; 130 } 131 132 return 0; 133 } 134 135 void killFirstInstanceOfDaemon(NSString *daemonExecutableName) 136 { 137 auto pid = pidOfFirstDaemonInstance(daemonExecutableName); 138 if (!pid) 139 return; 140 141 auto task = adoptNS([[NSTask alloc] init]); 142 task.get().launchPath = @"/bin/kill"; 143 task.get().arguments = @[ 144 @"-9", 145 [@(pid) stringValue] 146 ]; 147 148 [task launch]; 149 [task waitUntilExit]; 150 } 81 151 82 152 } // namespace TestWebKitAPI 153 154 NS_ASSUME_NONNULL_END 155 156 #endif // PLATFORM(MAC) || PLATFORM(IOS) -
trunk/WebKitLibraries/ChangeLog
r283039 r285799 1 2021-11-14 Brady Eidson <beidson@apple.com> 2 3 Get daemon API ready to work in the iOS simulator (starting with WebPushD) 4 https://bugs.webkit.org/show_bug.cgi?id=232982 5 6 Reviewed by Geoff Garen. 7 8 * WebKitPrivateFrameworkStubs/iOS/15/AppServerSupport.framework/AppServerSupport.tbd: Added. 9 1 10 2021-09-24 Jonathan Bedard <jbedard@apple.com> 2 11
Note:
See TracChangeset
for help on using the changeset viewer.