Changeset 229117 in webkit
- Timestamp:
- Feb 28, 2018, 6:12:31 PM (8 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r229115 r229117 1 2018-02-28 Brian Burg <bburg@apple.com> 2 3 [Cocoa] Web Automation: provide a way to ask clients the type of a JavaScript dialog 4 https://bugs.webkit.org/show_bug.cgi?id=182660 5 <rdar://problem/37408183> 6 7 Reviewed by Tim Horton and Carlos Garcia Campos. 8 9 Add another delegate method to ask what type of dialog is being shown. 10 This is used to implement §18.4 Step 5, where sending text to a dialog 11 without a prompt will return several different kinds of errors. 12 13 No new tests, covered by web platform tests once Safari side has landed. 14 15 * UIProcess/API/Cocoa/_WKAutomationSessionDelegate.h: Update FIXME radar numbers. 16 * UIProcess/Cocoa/AutomationSessionClient.h: 17 * UIProcess/Cocoa/AutomationSessionClient.mm: 18 (WebKit::AutomationSessionClient::AutomationSessionClient): 19 (WebKit::toImpl): 20 (WebKit::AutomationSessionClient::typeOfCurrentJavaScriptDialogOnPage): 21 If there is no current dialog to be checked, the client can return the 'None' 22 type. This gets converted into a std::nullopt and causes a command error later. 23 1 24 2018-02-28 John Wilander <wilander@apple.com> 2 25 -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKAutomationSessionDelegate.h
r228920 r229117 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016, 2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 34 34 @class _WKAutomationSession; 35 35 36 typedef NS_ENUM(NSInteger, _WKAutomationSessionJavaScriptDialogType) { 37 _WKAutomationSessionJavaScriptDialogTypeNone = 1, 38 _WKAutomationSessionJavaScriptDialogTypeAlert, 39 _WKAutomationSessionJavaScriptDialogTypeConfirm, 40 _WKAutomationSessionJavaScriptDialogTypePrompt, 41 } WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); 42 36 43 @protocol _WKAutomationSessionDelegate <NSObject> 37 44 @optional … … 45 52 - (NSString *)_automationSession:(_WKAutomationSession *)automationSession messageOfCurrentJavaScriptDialogForWebView:(WKWebView *)webView WK_API_AVAILABLE(macosx(10.13), ios(11.0)); 46 53 - (void)_automationSession:(_WKAutomationSession *)automationSession setUserInput:(NSString *)value forCurrentJavaScriptDialogForWebView:(WKWebView *)webView WK_API_AVAILABLE(macosx(10.13), ios(11.0)); 54 - (_WKAutomationSessionJavaScriptDialogType)_automationSession:(_WKAutomationSession *)automationSession typeOfCurrentJavaScriptDialogForWebView:(WKWebView *)webView WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); 47 55 48 // FIXME : Objective-C delegate methods shouldn't use C API types like WKPageRef. We need to56 // FIXME 37408718: Objective-C delegate methods shouldn't use C API types like WKPageRef. We need to 49 57 // migrate clients to use WKWebView, or expose the same behavior via a C SPI for those clients. 50 - (WKPageRef)_automationSessionDidRequestNewWindow:(_WKAutomationSession *)automationSession; 51 - (BOOL)_automationSession:(_WKAutomationSession *)automationSession isShowingJavaScriptDialogOnPage:(WKPageRef)page; 52 - (void)_automationSession:(_WKAutomationSession *)automationSession dismissCurrentJavaScriptDialogOnPage:(WKPageRef)page; 53 - (void)_automationSession:(_WKAutomationSession *)automationSession acceptCurrentJavaScriptDialogOnPage:(WKPageRef)page; 54 - (NSString *)_automationSession:(_WKAutomationSession *)automationSession messageOfCurrentJavaScriptDialogOnPage:(WKPageRef)page; 55 - (void)_automationSession:(_WKAutomationSession *)automationSession setUserInput:(NSString *)value forCurrentJavaScriptDialogOnPage:(WKPageRef)page; 58 - (WKPageRef)_automationSessionDidRequestNewWindow:(_WKAutomationSession *)automationSession WK_API_AVAILABLE(macosx(10.13), ios(11.0)); 59 - (BOOL)_automationSession:(_WKAutomationSession *)automationSession isShowingJavaScriptDialogOnPage:(WKPageRef)page WK_API_AVAILABLE(macosx(10.13), ios(11.0)); 60 - (void)_automationSession:(_WKAutomationSession *)automationSession dismissCurrentJavaScriptDialogOnPage:(WKPageRef)page WK_API_AVAILABLE(macosx(10.13), ios(11.0)); 61 - (void)_automationSession:(_WKAutomationSession *)automationSession acceptCurrentJavaScriptDialogOnPage:(WKPageRef)page WK_API_AVAILABLE(macosx(10.13), ios(11.0)); 62 - (NSString *)_automationSession:(_WKAutomationSession *)automationSession messageOfCurrentJavaScriptDialogOnPage:(WKPageRef)page WK_API_AVAILABLE(macosx(10.13), ios(11.0)); 63 - (void)_automationSession:(_WKAutomationSession *)automationSession setUserInput:(NSString *)value forCurrentJavaScriptDialogOnPage:(WKPageRef)page WK_API_AVAILABLE(macosx(10.13), ios(11.0)); 64 - (_WKAutomationSessionJavaScriptDialogType)_automationSession:(_WKAutomationSession *)automationSession typeOfCurrentJavaScriptDialogOnPage:(WKPageRef)page WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); 56 65 @end 57 66 -
trunk/Source/WebKit/UIProcess/Cocoa/AutomationSessionClient.h
r228920 r229117 65 65 bool messageOfCurrentJavaScriptDialogForWebView : 1; 66 66 bool setUserInputForCurrentJavaScriptPromptForWebView : 1; 67 bool typeOfCurrentJavaScriptDialogForWebView : 1; 67 68 68 // FIXME 28524687: these delegate methods should be removed.69 // FIXME 37408718: these delegate methods should be removed. 69 70 bool didRequestNewWindow : 1; 70 71 bool isShowingJavaScriptDialogOnPage : 1; … … 73 74 bool messageOfCurrentJavaScriptDialogOnPage : 1; 74 75 bool setUserInputForCurrentJavaScriptPromptOnPage : 1; 76 bool typeOfCurrentJavaScriptDialogOnPage : 1; 75 77 } m_delegateMethods; 76 78 }; -
trunk/Source/WebKit/UIProcess/Cocoa/AutomationSessionClient.mm
r228920 r229117 49 49 m_delegateMethods.messageOfCurrentJavaScriptDialogForWebView = [delegate respondsToSelector:@selector(_automationSession:messageOfCurrentJavaScriptDialogForWebView:)]; 50 50 m_delegateMethods.setUserInputForCurrentJavaScriptPromptForWebView = [delegate respondsToSelector:@selector(_automationSession:setUserInput:forCurrentJavaScriptDialogForWebView:)]; 51 m_delegateMethods.typeOfCurrentJavaScriptDialogForWebView = [delegate respondsToSelector:@selector(_automationSession:typeOfCurrentJavaScriptDialogForWebView:)]; 51 52 52 // FIXME 28524687: these delegate methods should be removed.53 // FIXME 37408718: these delegate methods should be removed. 53 54 m_delegateMethods.didRequestNewWindow = [delegate respondsToSelector:@selector(_automationSessionDidRequestNewWindow:)]; 54 55 m_delegateMethods.isShowingJavaScriptDialogOnPage = [delegate respondsToSelector:@selector(_automationSession:isShowingJavaScriptDialogOnPage:)]; … … 57 58 m_delegateMethods.messageOfCurrentJavaScriptDialogOnPage = [delegate respondsToSelector:@selector(_automationSession:messageOfCurrentJavaScriptDialogOnPage:)]; 58 59 m_delegateMethods.setUserInputForCurrentJavaScriptPromptOnPage = [delegate respondsToSelector:@selector(_automationSession:setUserInput:forCurrentJavaScriptDialogOnPage:)]; 60 m_delegateMethods.typeOfCurrentJavaScriptDialogOnPage = [delegate respondsToSelector:@selector(_automationSession:typeOfCurrentJavaScriptDialogOnPage:)]; 59 61 } 60 62 … … 65 67 } 66 68 67 // FIXME 28524687: support for WKPageRef-based delegate methods should be removed.69 // FIXME 37408718: support for WKPageRef-based delegate methods should be removed. 68 70 // Until these are removed, prefer to use the WKWebView delegate methods if implemented. 69 71 WebPageProxy* AutomationSessionClient::didRequestNewWindow(WebAutomationSession& session) … … 124 126 } 125 127 126 st d::optional<API::AutomationSessionClient::JavaScriptDialogType> AutomationSessionClient::typeOfCurrentJavaScriptDialogOnPage(WebAutomationSession&, WebPageProxy&)128 static std::optional<API::AutomationSessionClient::JavaScriptDialogType> toImpl(_WKAutomationSessionJavaScriptDialogType type) 127 129 { 128 // FIXME: Implement it. This is only used in WebAutomationSession::setUserInputForCurrentJavaScriptPrompt() so for now we return 129 // always Prompt type for compatibility. 130 switch (type) { 131 case _WKAutomationSessionJavaScriptDialogTypeNone: 132 return std::nullopt; 133 case _WKAutomationSessionJavaScriptDialogTypePrompt: 134 return API::AutomationSessionClient::JavaScriptDialogType::Prompt; 135 case _WKAutomationSessionJavaScriptDialogTypeConfirm: 136 return API::AutomationSessionClient::JavaScriptDialogType::Confirm; 137 case _WKAutomationSessionJavaScriptDialogTypeAlert: 138 return API::AutomationSessionClient::JavaScriptDialogType::Alert; 139 } 140 } 141 142 std::optional<API::AutomationSessionClient::JavaScriptDialogType> AutomationSessionClient::typeOfCurrentJavaScriptDialogOnPage(WebAutomationSession& session, WebPageProxy& page) 143 { 144 if (m_delegateMethods.typeOfCurrentJavaScriptDialogForWebView) 145 return toImpl([m_delegate.get() _automationSession:wrapper(session) typeOfCurrentJavaScriptDialogForWebView:fromWebPageProxy(page)]); 146 if (m_delegateMethods.typeOfCurrentJavaScriptDialogOnPage) 147 return toImpl([m_delegate.get() _automationSession:wrapper(session) typeOfCurrentJavaScriptDialogOnPage:toAPI(&page)]); 148 130 149 return API::AutomationSessionClient::JavaScriptDialogType::Prompt; 131 150 }
Note:
See TracChangeset
for help on using the changeset viewer.