Changeset 198740 in webkit
- Timestamp:
- Mar 28, 2016 8:57:49 AM (8 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r198739 r198740 1 2016-03-25 Timothy Hatcher <timothy@apple.com> 2 3 Web Automation: Add Automation protocol commands to handle JavaScript dialogs 4 5 https://bugs.webkit.org/show_bug.cgi?id=155888 6 rdar://problem/25360218 7 8 Reviewed by Brian Burg. 9 10 * UIProcess/API/APIAutomationSessionClient.h: 11 (API::AutomationSessionClient::isShowingJavaScriptDialogOnPage): Added. 12 (API::AutomationSessionClient::dismissCurrentJavaScriptDialogOnPage): Added. 13 (API::AutomationSessionClient::acceptCurrentJavaScriptDialogOnPage): Added. 14 (API::AutomationSessionClient::messageOfCurrentJavaScriptDialogOnPage): Added. 15 (API::AutomationSessionClient::setUserInputForCurrentJavaScriptPromptOnPage): Added. 16 17 * UIProcess/API/Cocoa/_WKAutomationSessionDelegate.h: 18 19 * UIProcess/Automation/Automation.json: Added new commands. 20 21 * UIProcess/Automation/WebAutomationSession.cpp: 22 (WebKit::WebAutomationSession::isShowingJavaScriptDialog): Added. 23 (WebKit::WebAutomationSession::dismissCurrentJavaScriptDialog): Added. 24 (WebKit::WebAutomationSession::acceptCurrentJavaScriptDialog): Added. 25 (WebKit::WebAutomationSession::messageOfCurrentJavaScriptDialog): Added. 26 (WebKit::WebAutomationSession::setUserInputForCurrentJavaScriptPrompt): Added. 27 * UIProcess/Automation/WebAutomationSession.h: 28 29 * UIProcess/Cocoa/AutomationSessionClient.h: 30 * UIProcess/Cocoa/AutomationSessionClient.mm: 31 (WebKit::AutomationSessionClient::AutomationSessionClient): Added. 32 (WebKit::AutomationSessionClient::isShowingJavaScriptDialogOnPage): Added. 33 (WebKit::AutomationSessionClient::dismissCurrentJavaScriptDialogOnPage): Added. 34 (WebKit::AutomationSessionClient::acceptCurrentJavaScriptDialogOnPage): Added. 35 (WebKit::AutomationSessionClient::messageOfCurrentJavaScriptDialogOnPage): Added. 36 (WebKit::AutomationSessionClient::setUserInputForCurrentJavaScriptPromptOnPage): Added. 37 1 38 2016-03-24 Timothy Hatcher <timothy@apple.com> 2 39 -
trunk/Source/WebKit2/UIProcess/API/APIAutomationSessionClient.h
r197621 r198740 43 43 virtual void didDisconnectFromRemote(WebKit::WebAutomationSession*) { } 44 44 virtual WebKit::WebPageProxy* didRequestNewWindow(WebKit::WebAutomationSession*) { return nullptr; } 45 virtual bool isShowingJavaScriptDialogOnPage(WebKit::WebAutomationSession*, WebKit::WebPageProxy*) { return false; } 46 virtual void dismissCurrentJavaScriptDialogOnPage(WebKit::WebAutomationSession*, WebKit::WebPageProxy*) { } 47 virtual void acceptCurrentJavaScriptDialogOnPage(WebKit::WebAutomationSession*, WebKit::WebPageProxy*) { } 48 virtual String messageOfCurrentJavaScriptDialogOnPage(WebKit::WebAutomationSession*, WebKit::WebPageProxy*) { return String(); } 49 virtual void setUserInputForCurrentJavaScriptPromptOnPage(WebKit::WebAutomationSession*, WebKit::WebPageProxy*, const String&) { } 45 50 }; 46 51 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKAutomationSessionDelegate.h
r197621 r198740 37 37 - (WKPageRef)_automationSessionDidRequestNewWindow:(_WKAutomationSession *)automationSession; 38 38 - (void)_automationSessionDidDisconnectFromRemote:(_WKAutomationSession *)automationSession; 39 40 - (BOOL)_automationSession:(_WKAutomationSession *)automationSession isShowingJavaScriptDialogOnPage:(WKPageRef)page; 41 - (void)_automationSession:(_WKAutomationSession *)automationSession dismissCurrentJavaScriptDialogOnPage:(WKPageRef)page; 42 - (void)_automationSession:(_WKAutomationSession *)automationSession acceptCurrentJavaScriptDialogOnPage:(WKPageRef)page; 43 - (NSString *)_automationSession:(_WKAutomationSession *)automationSession messageOfCurrentJavaScriptDialogOnPage:(WKPageRef)page; 44 - (void)_automationSession:(_WKAutomationSession *)automationSession setUserInput:(NSString *)value forCurrentJavaScriptDialogOnPage:(WKPageRef)page; 39 45 @end 40 46 -
trunk/Source/WebKit2/UIProcess/Automation/Automation.json
r198739 r198740 52 52 "FrameNotFound", 53 53 "NodeNotFound", 54 "NoJavaScriptDialog", 54 55 "NotImplemented", 55 56 "MissingParameter" … … 192 193 ], 193 194 "async": true 195 }, 196 { 197 "name": "isShowingJavaScriptDialog", 198 "description": "Checks if a browsing context is showing a JavaScript alert, confirm, or prompt dialog.", 199 "parameters": [ 200 { "name": "browsingContextHandle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context." } 201 ], 202 "returns": [ 203 { "name": "result", "type": "boolean", "description": "If the browsing context is showing a JavaScript dialog or not." } 204 ] 205 }, 206 { 207 "name": "dismissCurrentJavaScriptDialog", 208 "description": "Dismisses a JavaScript alert, confirm, or prompt dialog currently showing in a browsing context. Equivalent to clicking the 'Cancel' button.", 209 "parameters": [ 210 { "name": "browsingContextHandle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context." } 211 ] 212 }, 213 { 214 "name": "acceptCurrentJavaScriptDialog", 215 "description": "Accepts a JavaScript alert, confirm, or prompt dialog currently showing in a browsing context. Equivalent to clicking the 'OK' button.", 216 "parameters": [ 217 { "name": "browsingContextHandle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context." } 218 ] 219 }, 220 { 221 "name": "messageOfCurrentJavaScriptDialog", 222 "description": "Returns the text displayed in a JavaScript alert, confirm, or prompt dialog currently showing in a browsing context.", 223 "parameters": [ 224 { "name": "browsingContextHandle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context." } 225 ], 226 "returns": [ 227 { "name": "message", "type": "string", "description": "Text being displayed in the current JavaScript dialog." } 228 ] 229 }, 230 { 231 "name": "setUserInputForCurrentJavaScriptPrompt", 232 "description": "Sets the user entered value in a JavaScript prompt dialog currently showing in a browsing context.", 233 "parameters": [ 234 { "name": "browsingContextHandle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context." }, 235 { "name": "userInput", "type": "string", "description": "The text to enter in the prompt." } 236 ] 194 237 } 195 238 ] -
trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp
r198739 r198740 466 466 } 467 467 468 void WebAutomationSession::isShowingJavaScriptDialog(Inspector::ErrorString& errorString, const String& browsingContextHandle, bool* result) 469 { 470 ASSERT(m_client); 471 if (!m_client) 472 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(InternalError); 473 474 WebPageProxy* page = webPageProxyForHandle(browsingContextHandle); 475 if (!page) 476 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound); 477 478 *result = m_client->isShowingJavaScriptDialogOnPage(this, page); 479 } 480 481 void WebAutomationSession::dismissCurrentJavaScriptDialog(Inspector::ErrorString& errorString, const String& browsingContextHandle) 482 { 483 ASSERT(m_client); 484 if (!m_client) 485 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(InternalError); 486 487 WebPageProxy* page = webPageProxyForHandle(browsingContextHandle); 488 if (!page) 489 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound); 490 491 if (!m_client->isShowingJavaScriptDialogOnPage(this, page)) 492 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(NoJavaScriptDialog); 493 494 m_client->dismissCurrentJavaScriptDialogOnPage(this, page); 495 } 496 497 void WebAutomationSession::acceptCurrentJavaScriptDialog(Inspector::ErrorString& errorString, const String& browsingContextHandle) 498 { 499 ASSERT(m_client); 500 if (!m_client) 501 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(InternalError); 502 503 WebPageProxy* page = webPageProxyForHandle(browsingContextHandle); 504 if (!page) 505 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound); 506 507 if (!m_client->isShowingJavaScriptDialogOnPage(this, page)) 508 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(NoJavaScriptDialog); 509 510 m_client->acceptCurrentJavaScriptDialogOnPage(this, page); 511 } 512 513 void WebAutomationSession::messageOfCurrentJavaScriptDialog(Inspector::ErrorString& errorString, const String& browsingContextHandle, String* text) 514 { 515 ASSERT(m_client); 516 if (!m_client) 517 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(InternalError); 518 519 WebPageProxy* page = webPageProxyForHandle(browsingContextHandle); 520 if (!page) 521 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound); 522 523 if (!m_client->isShowingJavaScriptDialogOnPage(this, page)) 524 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(NoJavaScriptDialog); 525 526 *text = m_client->messageOfCurrentJavaScriptDialogOnPage(this, page); 527 } 528 529 void WebAutomationSession::setUserInputForCurrentJavaScriptPrompt(Inspector::ErrorString& errorString, const String& browsingContextHandle, const String& promptValue) 530 { 531 ASSERT(m_client); 532 if (!m_client) 533 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(InternalError); 534 535 WebPageProxy* page = webPageProxyForHandle(browsingContextHandle); 536 if (!page) 537 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound); 538 539 if (!m_client->isShowingJavaScriptDialogOnPage(this, page)) 540 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(NoJavaScriptDialog); 541 542 m_client->setUserInputForCurrentJavaScriptPromptOnPage(this, page, promptValue); 543 } 544 468 545 } // namespace WebKit -
trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h
r198739 r198740 96 96 void resolveParentFrameHandle(Inspector::ErrorString&, const String& browsingContextHandle, const String& frameHandle, Ref<ResolveParentFrameHandleCallback>&&) override; 97 97 void computeElementLayout(Inspector::ErrorString&, const String& browsingContextHandle, const String& frameHandle, const String& nodeHandle, const bool* optionalScrollIntoViewIfNeeded, const bool* useViewportCoordinates, Ref<Inspector::AutomationBackendDispatcherHandler::ComputeElementLayoutCallback>&&) override; 98 void isShowingJavaScriptDialog(Inspector::ErrorString&, const String& browsingContextHandle, bool* result) override; 99 void dismissCurrentJavaScriptDialog(Inspector::ErrorString&, const String& browsingContextHandle) override; 100 void acceptCurrentJavaScriptDialog(Inspector::ErrorString&, const String& browsingContextHandle) override; 101 void messageOfCurrentJavaScriptDialog(Inspector::ErrorString&, const String& browsingContextHandle, String* text) override; 102 void setUserInputForCurrentJavaScriptPrompt(Inspector::ErrorString&, const String& browsingContextHandle, const String& text) override; 98 103 99 104 private: -
trunk/Source/WebKit2/UIProcess/Cocoa/AutomationSessionClient.h
r197621 r198740 44 44 private: 45 45 // From API::AutomationSessionClient 46 WebPageProxy* didRequestNewWindow(WebKit::WebAutomationSession*) override; 47 void didDisconnectFromRemote(WebKit::WebAutomationSession *) override; 46 WebPageProxy* didRequestNewWindow(WebAutomationSession*) override; 47 void didDisconnectFromRemote(WebAutomationSession *) override; 48 49 bool isShowingJavaScriptDialogOnPage(WebAutomationSession*, WebPageProxy*) override; 50 void dismissCurrentJavaScriptDialogOnPage(WebAutomationSession*, WebPageProxy*) override; 51 void acceptCurrentJavaScriptDialogOnPage(WebAutomationSession*, WebPageProxy*) override; 52 String messageOfCurrentJavaScriptDialogOnPage(WebAutomationSession*, WebPageProxy*) override; 53 void setUserInputForCurrentJavaScriptPromptOnPage(WebAutomationSession*, WebPageProxy*, const String&) override; 48 54 49 55 WeakObjCPtr<id <_WKAutomationSessionDelegate>> m_delegate; … … 52 58 bool didRequestNewWindow : 1; 53 59 bool didDisconnectFromRemote : 1; 60 bool isShowingJavaScriptDialogOnPage : 1; 61 bool dismissCurrentJavaScriptDialogOnPage : 1; 62 bool acceptCurrentJavaScriptDialogOnPage : 1; 63 bool messageOfCurrentJavaScriptDialogOnPage : 1; 64 bool setUserInputForCurrentJavaScriptPromptOnPage : 1; 54 65 } m_delegateMethods; 55 66 }; -
trunk/Source/WebKit2/UIProcess/Cocoa/AutomationSessionClient.mm
r197621 r198740 42 42 m_delegateMethods.didRequestNewWindow = [delegate respondsToSelector:@selector(_automationSessionDidRequestNewWindow:)]; 43 43 m_delegateMethods.didDisconnectFromRemote = [delegate respondsToSelector:@selector(_automationSessionDidDisconnectFromRemote:)]; 44 m_delegateMethods.isShowingJavaScriptDialogOnPage = [delegate respondsToSelector:@selector(_automationSession:isShowingJavaScriptDialogOnPage:)]; 45 m_delegateMethods.dismissCurrentJavaScriptDialogOnPage = [delegate respondsToSelector:@selector(_automationSession:dismissCurrentJavaScriptDialogOnPage:)]; 46 m_delegateMethods.acceptCurrentJavaScriptDialogOnPage = [delegate respondsToSelector:@selector(_automationSession:acceptCurrentJavaScriptDialogOnPage:)]; 47 m_delegateMethods.messageOfCurrentJavaScriptDialogOnPage = [delegate respondsToSelector:@selector(_automationSession:messageOfCurrentJavaScriptDialogOnPage:)]; 48 m_delegateMethods.setUserInputForCurrentJavaScriptPromptOnPage = [delegate respondsToSelector:@selector(_automationSession:setUserInput:forCurrentJavaScriptDialogOnPage:)]; 44 49 } 45 50 … … 57 62 } 58 63 64 bool AutomationSessionClient::isShowingJavaScriptDialogOnPage(WebAutomationSession* session, WebPageProxy* page) 65 { 66 if (m_delegateMethods.isShowingJavaScriptDialogOnPage) 67 return [m_delegate.get() _automationSession:wrapper(*session) isShowingJavaScriptDialogOnPage:toAPI(page)]; 68 return false; 69 } 70 71 void AutomationSessionClient::dismissCurrentJavaScriptDialogOnPage(WebAutomationSession* session, WebPageProxy* page) 72 { 73 if (m_delegateMethods.dismissCurrentJavaScriptDialogOnPage) 74 [m_delegate.get() _automationSession:wrapper(*session) dismissCurrentJavaScriptDialogOnPage:toAPI(page)]; 75 } 76 77 void AutomationSessionClient::acceptCurrentJavaScriptDialogOnPage(WebAutomationSession* session, WebPageProxy* page) 78 { 79 if (m_delegateMethods.acceptCurrentJavaScriptDialogOnPage) 80 [m_delegate.get() _automationSession:wrapper(*session) acceptCurrentJavaScriptDialogOnPage:toAPI(page)]; 81 } 82 83 String AutomationSessionClient::messageOfCurrentJavaScriptDialogOnPage(WebAutomationSession* session, WebPageProxy* page) 84 { 85 if (m_delegateMethods.messageOfCurrentJavaScriptDialogOnPage) 86 return [m_delegate.get() _automationSession:wrapper(*session) messageOfCurrentJavaScriptDialogOnPage:toAPI(page)]; 87 return String(); 88 } 89 90 void AutomationSessionClient::setUserInputForCurrentJavaScriptPromptOnPage(WebAutomationSession* session, WebPageProxy* page, const String& value) 91 { 92 if (m_delegateMethods.setUserInputForCurrentJavaScriptPromptOnPage) 93 [m_delegate.get() _automationSession:wrapper(*session) setUserInput:value forCurrentJavaScriptDialogOnPage:toAPI(page)]; 94 } 95 59 96 } // namespace WebKit 60 97
Note: See TracChangeset
for help on using the changeset viewer.