Changeset 220394 in webkit
- Timestamp:
- Aug 8, 2017 1:29:19 AM (7 years ago)
- Location:
- trunk/Source
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebDriver/ChangeLog
r220388 r220394 1 2017-08-07 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 Web Automation: setUserInputForCurrentJavaScriptPrompt should fail if current dialog is not a prompt 4 https://bugs.webkit.org/show_bug.cgi?id=175261 5 6 Reviewed by Brian Burg. 7 8 * CommandResult.cpp: 9 (WebDriver::CommandResult::CommandResult): Handle ElementNotInteractable protocol error. 10 1 11 2017-08-07 Carlos Garcia Campos <cgarcia@igalia.com> 2 12 -
trunk/Source/WebDriver/CommandResult.cpp
r220388 r220394 89 89 else if (errorName == "NotImplemented") 90 90 m_errorCode = ErrorCode::UnsupportedOperation; 91 else if (errorName == "ElementNotInteractable") 92 m_errorCode = ErrorCode::ElementNotInteractable; 91 93 else if (errorName == "JavaScriptError") 92 94 m_errorCode = ErrorCode::JavascriptError; -
trunk/Source/WebKit/ChangeLog
r220393 r220394 1 2017-08-07 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 Web Automation: setUserInputForCurrentJavaScriptPrompt should fail if current dialog is not a prompt 4 https://bugs.webkit.org/show_bug.cgi?id=175261 5 6 Reviewed by Brian Burg. 7 8 According to the spec, send alert text command should fail if the current dialog is not a prompt. This patch 9 adds JavaScriptDialogType enum to API::AutomationSessionClient and a new virtual method to ask the client about 10 the type of the current dialog. WebAutomationSession::setUserInputForCurrentJavaScriptPrompt() uses the new 11 client method to check the type of the current dialog and fail in case it's not a prompt. Cocoa needs an 12 implementation, for now it always returns Prompt as the type to keep compatibility. 13 14 18.4 Send Alert Text. 15 https://w3c.github.io/webdriver/webdriver-spec.html#send-alert-text 16 17 This fixes selenium test testSettingTheValueOfAnAlertThrows. 18 19 * UIProcess/API/APIAutomationSessionClient.h: 20 (API::AutomationSessionClient::typeOfCurrentJavaScriptDialogOnPage): 21 * UIProcess/API/glib/WebKitAutomationSession.cpp: 22 * UIProcess/API/glib/WebKitWebView.cpp: 23 (webkitWebViewGetCurrentScriptDialogType): 24 * UIProcess/API/glib/WebKitWebViewPrivate.h: 25 * UIProcess/Automation/Automation.json: 26 * UIProcess/Automation/WebAutomationSession.cpp: 27 (WebKit::WebAutomationSession::setUserInputForCurrentJavaScriptPrompt): 28 * UIProcess/Cocoa/AutomationSessionClient.h: 29 * UIProcess/Cocoa/AutomationSessionClient.mm: 30 (WebKit::AutomationSessionClient::typeOfCurrentJavaScriptDialogOnPage): 31 1 32 2017-08-08 Wenson Hsieh <wenson_hsieh@apple.com> 2 33 -
trunk/Source/WebKit/UIProcess/API/APIAutomationSessionClient.h
r213304 r220394 38 38 class AutomationSessionClient { 39 39 public: 40 enum class JavaScriptDialogType { 41 Alert, 42 Confirm, 43 Prompt, 44 BeforeUnloadConfirm 45 }; 46 40 47 virtual ~AutomationSessionClient() { } 41 48 … … 48 55 virtual String messageOfCurrentJavaScriptDialogOnPage(WebKit::WebAutomationSession&, WebKit::WebPageProxy&) { return String(); } 49 56 virtual void setUserInputForCurrentJavaScriptPromptOnPage(WebKit::WebAutomationSession&, WebKit::WebPageProxy&, const String&) { } 57 virtual std::optional<JavaScriptDialogType> typeOfCurrentJavaScriptDialogOnPage(WebKit::WebAutomationSession&, WebKit::WebPageProxy&) { return std::nullopt; } 50 58 }; 51 59 -
trunk/Source/WebKit/UIProcess/API/glib/WebKitAutomationSession.cpp
r220387 r220394 131 131 return; 132 132 webkitWebViewSetCurrentScriptDialogUserInput(webView, userInput); 133 } 134 135 std::optional<API::AutomationSessionClient::JavaScriptDialogType> typeOfCurrentJavaScriptDialogOnPage(WebAutomationSession&, WebPageProxy& page) override 136 { 137 auto* webView = webkitWebContextGetWebViewForPage(m_session->priv->webContext, &page); 138 if (!webView) 139 return std::nullopt; 140 auto dialogType = webkitWebViewGetCurrentScriptDialogType(webView); 141 if (!dialogType) 142 return std::nullopt; 143 switch (dialogType.value()) { 144 case WEBKIT_SCRIPT_DIALOG_ALERT: 145 return API::AutomationSessionClient::JavaScriptDialogType::Alert; 146 case WEBKIT_SCRIPT_DIALOG_CONFIRM: 147 return API::AutomationSessionClient::JavaScriptDialogType::Confirm; 148 case WEBKIT_SCRIPT_DIALOG_PROMPT: 149 return API::AutomationSessionClient::JavaScriptDialogType::Prompt; 150 case WEBKIT_SCRIPT_DIALOG_BEFORE_UNLOAD_CONFIRM: 151 return API::AutomationSessionClient::JavaScriptDialogType::BeforeUnloadConfirm; 152 } 153 154 ASSERT_NOT_REACHED(); 155 return std::nullopt; 133 156 } 134 157 -
trunk/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp
r220387 r220394 2091 2091 } 2092 2092 2093 std::optional<WebKitScriptDialogType> webkitWebViewGetCurrentScriptDialogType(WebKitWebView* webView) 2094 { 2095 if (!webView->priv->currentScriptDialog) 2096 return std::nullopt; 2097 2098 return static_cast<WebKitScriptDialogType>(webView->priv->currentScriptDialog->type); 2099 } 2100 2093 2101 void webkitWebViewMakePolicyDecision(WebKitWebView* webView, WebKitPolicyDecisionType type, WebKitPolicyDecision* decision) 2094 2102 { -
trunk/Source/WebKit/UIProcess/API/glib/WebKitWebViewPrivate.h
r220387 r220394 60 60 void webkitWebViewAcceptCurrentScriptDialog(WebKitWebView*); 61 61 void webkitWebViewDismissCurrentScriptDialog(WebKitWebView*); 62 std::optional<WebKitScriptDialogType> webkitWebViewGetCurrentScriptDialogType(WebKitWebView*); 62 63 void webkitWebViewMakePermissionRequest(WebKitWebView*, WebKitPermissionRequest*); 63 64 void webkitWebViewMakePolicyDecision(WebKitWebView*, WebKitPolicyDecisionType, WebKitPolicyDecision*); -
trunk/Source/WebKit/UIProcess/Automation/Automation.json
r220314 r220394 59 59 "MissingParameter", 60 60 "InvalidParameter", 61 "InvalidSelector" 61 "InvalidSelector", 62 "ElementNotInteractable" 62 63 ] 63 64 }, -
trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp
r220317 r220394 920 920 FAIL_WITH_PREDEFINED_ERROR(NoJavaScriptDialog); 921 921 922 // §18.4 Send Alert Text. 923 // https://w3c.github.io/webdriver/webdriver-spec.html#send-alert-text 924 // 3. Run the substeps of the first matching current user prompt: 925 auto scriptDialogType = m_client->typeOfCurrentJavaScriptDialogOnPage(*this, *page); 926 ASSERT(scriptDialogType); 927 switch (scriptDialogType.value()) { 928 case API::AutomationSessionClient::JavaScriptDialogType::Alert: 929 case API::AutomationSessionClient::JavaScriptDialogType::Confirm: 930 // Return error with error code element not interactable. 931 FAIL_WITH_PREDEFINED_ERROR(ElementNotInteractable); 932 case API::AutomationSessionClient::JavaScriptDialogType::Prompt: 933 // Do nothing. 934 break; 935 case API::AutomationSessionClient::JavaScriptDialogType::BeforeUnloadConfirm: 936 // Return error with error code unsupported operation. 937 FAIL_WITH_PREDEFINED_ERROR(NotImplemented); 938 } 939 922 940 m_client->setUserInputForCurrentJavaScriptPromptOnPage(*this, *page, promptValue); 923 941 } -
trunk/Source/WebKit/UIProcess/Cocoa/AutomationSessionClient.h
r213304 r220394 52 52 String messageOfCurrentJavaScriptDialogOnPage(WebAutomationSession&, WebPageProxy&) override; 53 53 void setUserInputForCurrentJavaScriptPromptOnPage(WebAutomationSession&, WebPageProxy&, const String&) override; 54 std::optional<API::AutomationSessionClient::JavaScriptDialogType> typeOfCurrentJavaScriptDialogOnPage(WebAutomationSession&, WebPageProxy&) override; 54 55 55 56 WeakObjCPtr<id <_WKAutomationSessionDelegate>> m_delegate; -
trunk/Source/WebKit/UIProcess/Cocoa/AutomationSessionClient.mm
r213304 r220394 124 124 } 125 125 126 std::optional<API::AutomationSessionClient::JavaScriptDialogType> AutomationSessionClient::typeOfCurrentJavaScriptDialogOnPage(WebAutomationSession&, WebPageProxy&) 127 { 128 // FIXME: Implement it. This is only used in WebAutomationSession::setUserInputForCurrentJavaScriptPrompt() so for now we return 129 // always Prompt type for compatibility. 130 return API::AutomationSessionClient::JavaScriptDialogType::Prompt; 131 } 132 126 133 } // namespace WebKit 127 134
Note: See TracChangeset
for help on using the changeset viewer.