Changeset 198914 in webkit
- Timestamp:
- Mar 31, 2016, 1:52:44 PM (9 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r198913 r198914 1 2016-03-31 Timothy Hatcher <timothy@apple.com> 2 3 Web Automation: Navigation commands should not return until page loads or fails 4 5 https://bugs.webkit.org/show_bug.cgi?id=156063 6 rdar://problem/25464373 7 8 Reviewed by Brian Burg. 9 10 * UIProcess/Automation/Automation.json: Make navigation commands async. 11 * UIProcess/Automation/WebAutomationSession.cpp: 12 (WebKit::WebAutomationSession::navigateBrowsingContext): Save callback and timeout previous. 13 (WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto. 14 (WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto. 15 (WebKit::WebAutomationSession::reloadBrowsingContext): Ditto. 16 (WebKit::WebAutomationSession::navigationOccuredForPage): Added. Fire callback for page. 17 * UIProcess/Automation/WebAutomationSession.h: 18 19 * UIProcess/WebPageProxy.cpp: 20 (WebKit::WebPageProxy::didFinishLoadForFrame): Call WebAutomationSession::navigationOccuredForPage. 21 (WebKit::WebPageProxy::didFailLoadForFrame): Ditto. 22 (WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto. 23 24 * UIProcess/WebProcessPool.h: Added automationSession() getter. 25 1 26 2016-03-30 Timothy Hatcher <timothy@apple.com> 2 27 -
trunk/Source/WebKit2/UIProcess/Automation/Automation.json
r198913 r198914 48 48 "enum": [ 49 49 "InternalError", 50 "Timeout", 50 51 "JavaScriptError", 51 52 "JavaScriptTimeout", … … 251 252 { "name": "handle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context that should be navigated." }, 252 253 { "name": "url", "type": "string", "description": "The URL to load in the browsing context." } 253 ] 254 ], 255 "async": true 254 256 }, 255 257 { … … 258 260 "parameters": [ 259 261 { "name": "handle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context that should be navigated." } 260 ] 262 ], 263 "async": true 261 264 }, 262 265 { … … 265 268 "parameters": [ 266 269 { "name": "handle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context that should be navigated." } 267 ] 270 ], 271 "async": true 268 272 }, 269 273 { … … 272 276 "parameters": [ 273 277 { "name": "handle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context that should be reloaded." } 274 ] 278 ], 279 "async": true 275 280 }, 276 281 { -
trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp
r198913 r198914 358 358 } 359 359 360 void WebAutomationSession::navigateBrowsingContext(Inspector::ErrorString& errorString, const String& handle, const String& url) 361 { 362 WebPageProxy* page = webPageProxyForHandle(handle); 363 if (!page) 364 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound); 360 void WebAutomationSession::navigateBrowsingContext(Inspector::ErrorString& errorString, const String& handle, const String& url, Ref<NavigateBrowsingContextCallback>&& callback) 361 { 362 WebPageProxy* page = webPageProxyForHandle(handle); 363 if (!page) 364 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound); 365 366 if (auto callback = m_pendingNavigationInBrowsingContextCallbacksPerPage.take(page->pageID())) 367 callback->sendFailure(Inspector::Protocol::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::Timeout)); 368 m_pendingNavigationInBrowsingContextCallbacksPerPage.set(page->pageID(), WTFMove(callback)); 365 369 366 370 page->loadRequest(WebCore::URL(WebCore::URL(), url)); 367 371 } 368 372 369 void WebAutomationSession::goBackInBrowsingContext(Inspector::ErrorString& errorString, const String& handle) 370 { 371 WebPageProxy* page = webPageProxyForHandle(handle); 372 if (!page) 373 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound); 373 void WebAutomationSession::goBackInBrowsingContext(Inspector::ErrorString& errorString, const String& handle, Ref<GoBackInBrowsingContextCallback>&& callback) 374 { 375 WebPageProxy* page = webPageProxyForHandle(handle); 376 if (!page) 377 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound); 378 379 if (auto callback = m_pendingNavigationInBrowsingContextCallbacksPerPage.take(page->pageID())) 380 callback->sendFailure(Inspector::Protocol::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::Timeout)); 381 m_pendingNavigationInBrowsingContextCallbacksPerPage.set(page->pageID(), WTFMove(callback)); 374 382 375 383 page->goBack(); 376 384 } 377 385 378 void WebAutomationSession::goForwardInBrowsingContext(Inspector::ErrorString& errorString, const String& handle) 379 { 380 WebPageProxy* page = webPageProxyForHandle(handle); 381 if (!page) 382 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound); 386 void WebAutomationSession::goForwardInBrowsingContext(Inspector::ErrorString& errorString, const String& handle, Ref<GoForwardInBrowsingContextCallback>&& callback) 387 { 388 WebPageProxy* page = webPageProxyForHandle(handle); 389 if (!page) 390 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound); 391 392 if (auto callback = m_pendingNavigationInBrowsingContextCallbacksPerPage.take(page->pageID())) 393 callback->sendFailure(Inspector::Protocol::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::Timeout)); 394 m_pendingNavigationInBrowsingContextCallbacksPerPage.set(page->pageID(), WTFMove(callback)); 383 395 384 396 page->goForward(); 385 397 } 386 398 387 void WebAutomationSession::reloadBrowsingContext(Inspector::ErrorString& errorString, const String& handle) 388 { 389 WebPageProxy* page = webPageProxyForHandle(handle); 390 if (!page) 391 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound); 399 void WebAutomationSession::reloadBrowsingContext(Inspector::ErrorString& errorString, const String& handle, Ref<ReloadBrowsingContextCallback>&& callback) 400 { 401 WebPageProxy* page = webPageProxyForHandle(handle); 402 if (!page) 403 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound); 404 405 if (auto callback = m_pendingNavigationInBrowsingContextCallbacksPerPage.take(page->pageID())) 406 callback->sendFailure(Inspector::Protocol::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::Timeout)); 407 m_pendingNavigationInBrowsingContextCallbacksPerPage.set(page->pageID(), WTFMove(callback)); 392 408 393 409 const bool reloadFromOrigin = false; 394 410 const bool contentBlockersEnabled = true; 395 411 page->reload(reloadFromOrigin, contentBlockersEnabled); 412 } 413 414 void WebAutomationSession::navigationOccurredForPage(const WebPageProxy& page) 415 { 416 if (auto callback = m_pendingNavigationInBrowsingContextCallbacksPerPage.take(page.pageID())) 417 callback->sendSuccess(InspectorObject::create()); 396 418 } 397 419 -
trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h
r198913 r198914 84 84 void setProcessPool(WebProcessPool*); 85 85 86 void navigationOccurredForPage(const WebPageProxy&); 87 86 88 #if ENABLE(REMOTE_INSPECTOR) 87 89 // Inspector::RemoteAutomationTarget API … … 100 102 void resizeWindowOfBrowsingContext(Inspector::ErrorString&, const String& handle, const Inspector::InspectorObject& size) override; 101 103 void moveWindowOfBrowsingContext(Inspector::ErrorString&, const String& handle, const Inspector::InspectorObject& position) override; 102 void navigateBrowsingContext(Inspector::ErrorString&, const String& handle, const String& url ) override;103 void goBackInBrowsingContext(Inspector::ErrorString&, const String& ) override;104 void goForwardInBrowsingContext(Inspector::ErrorString&, const String& ) override;105 void reloadBrowsingContext(Inspector::ErrorString&, const String& ) override;104 void navigateBrowsingContext(Inspector::ErrorString&, const String& handle, const String& url, Ref<NavigateBrowsingContextCallback>&&) override; 105 void goBackInBrowsingContext(Inspector::ErrorString&, const String&, Ref<GoBackInBrowsingContextCallback>&&) override; 106 void goForwardInBrowsingContext(Inspector::ErrorString&, const String&, Ref<GoForwardInBrowsingContextCallback>&&) override; 107 void reloadBrowsingContext(Inspector::ErrorString&, const String&, Ref<ReloadBrowsingContextCallback>&&) override; 106 108 void evaluateJavaScriptFunction(Inspector::ErrorString&, const String& browsingContextHandle, const String* optionalFrameHandle, const String& function, const Inspector::InspectorArray& arguments, const bool* optionalExpectsImplicitCallbackArgument, const int* optionalCallbackTimeout, Ref<Inspector::AutomationBackendDispatcherHandler::EvaluateJavaScriptFunctionCallback>&&) override; 107 109 void performMouseInteraction(Inspector::ErrorString&, const String& handle, const Inspector::InspectorObject& requestedPosition, const String& mouseButton, const String& mouseInteraction, const Inspector::InspectorArray& keyModifiers, RefPtr<Inspector::Protocol::Automation::Point>& updatedPosition) override; … … 168 170 HashMap<String, uint64_t> m_handleWebFrameMap; 169 171 172 HashMap<uint64_t, RefPtr<Inspector::BackendDispatcher::CallbackBase>> m_pendingNavigationInBrowsingContextCallbacksPerPage; 173 170 174 uint64_t m_nextEvaluateJavaScriptCallbackID { 1 }; 171 175 HashMap<uint64_t, RefPtr<Inspector::AutomationBackendDispatcherHandler::EvaluateJavaScriptFunctionCallback>> m_evaluateJavaScriptFunctionCallbacks; -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r198901 r198914 72 72 #include "UserMediaPermissionRequestProxy.h" 73 73 #include "WKContextPrivate.h" 74 #include "WebAutomationSession.h" 74 75 #include "WebBackForwardList.h" 75 76 #include "WebBackForwardListItem.h" … … 3127 3128 m_pageLoadState.didFinishLoad(transaction); 3128 3129 3130 if (isMainFrame && m_controlledByAutomation) { 3131 if (auto* automationSession = process().processPool().automationSession()) 3132 automationSession->navigationOccurredForPage(*this); 3133 } 3134 3129 3135 frame->didFinishLoad(); 3130 3136 … … 3161 3167 m_pageLoadState.didFailLoad(transaction); 3162 3168 3169 if (isMainFrame && m_controlledByAutomation) { 3170 if (auto* automationSession = process().processPool().automationSession()) 3171 automationSession->navigationOccurredForPage(*this); 3172 } 3173 3163 3174 frame->didFailLoad(); 3164 3175 … … 3192 3203 if (isMainFrame) 3193 3204 m_pageLoadState.didSameDocumentNavigation(transaction, url); 3205 3206 if (isMainFrame && m_controlledByAutomation) { 3207 if (auto* automationSession = process().processPool().automationSession()) 3208 automationSession->navigationOccurredForPage(*this); 3209 } 3194 3210 3195 3211 m_pageLoadState.clearPendingAPIRequestURL(transaction); -
trunk/Source/WebKit2/UIProcess/WebProcessPool.h
r198736 r198914 260 260 void updateAutomationCapabilities() const; 261 261 void setAutomationSession(RefPtr<WebAutomationSession>&&); 262 WebAutomationSession* automationSession() const { return m_automationSession.get(); } 262 263 263 264 // Defaults to false.
Note:
See TracChangeset
for help on using the changeset viewer.