Changeset 200702 in webkit
- Timestamp:
- May 11, 2016 1:57:08 PM (8 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r200696 r200702 1 2016-05-10 Brian Burg <bburg@apple.com> 2 3 Web Automation: add command to asynchronously load the Web Inspector frontend in the background 4 https://bugs.webkit.org/show_bug.cgi?id=157509 5 6 Reviewed by Timothy Hatcher and Joseph Pecoraro. 7 8 In order to make it easier to debug code that executes as a result of an automation 9 command, this patch adds a new Automation command to asynchronously load the debugger 10 and Inspector frontend. It is designed for use by automation clients to implement an 11 auto-inspection feature to aid in debugging automation scripts. 12 13 * UIProcess/Automation/Automation.json: Add new command. 14 * UIProcess/Automation/WebAutomationSession.cpp: 15 (WebKit::WebAutomationSession::inspectBrowsingContext): Added. 16 (WebKit::WebAutomationSession::inspectorFrontendLoaded): Added. 17 This message is forwarded by WebInspectorProxy to the inspected page's session. 18 19 * UIProcess/Automation/WebAutomationSession.h: 20 * UIProcess/Cocoa/WebAutomationSessionCocoa.mm: 21 (WebKit::WebAutomationSession::sendSynthesizedEventsToPage): 22 Force the active automation window to become key and bring to front prior to 23 sending each NSEvent. This way, if the Inspector pauses while a command executes, 24 the automation window will get back focus when the Inspector unpauses just before 25 the next synthesized mouse or keyboard NSEvent is sent to its NSWindow. 26 27 * UIProcess/WebInspectorProxy.cpp: 28 (WebKit::WebInspectorProxy::frontendLoaded): 29 Forward to the inspected page's session. 30 31 * UIProcess/WebInspectorProxy.h: 32 * UIProcess/WebInspectorProxy.messages.in: Add notification of the frontend's load. 33 34 * WebProcess/WebPage/WebInspectorUI.cpp: 35 (WebKit::WebInspectorUI::frontendLoaded): 36 Kick off notifying the automation session in UIProcess that the inspector loaded. 37 38 (WebKit::WebInspectorUI::closeWindow): 39 In some circumstances, the Web Inspector can be loaded without showing 40 the window. If this hidden page closes, make sure the frontend host gets 41 a chance to disconnect its InspectorFrontendClient. Normally this happens 42 when the window closes, but unshown Inspectors do not get window instances. 43 1 44 2016-05-11 Chris Dumez <cdumez@apple.com> 2 45 -
trunk/Source/WebKit2/UIProcess/Automation/Automation.json
r199197 r200702 295 295 }, 296 296 { 297 "name": "inspectBrowsingContext", 298 "description": "Inspect the specified browsing context using Web Inspector.", 299 "parameters": [ 300 { "name": "handle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context that should be inspected." } 301 ], 302 "async": true 303 }, 304 { 297 305 "name": "evaluateJavaScriptFunction", 298 306 "description": "Evaluates a script function in a browsing context and calls it with the supplied arguments.", -
trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp
r200274 r200702 32 32 #include "WebAutomationSessionProxyMessages.h" 33 33 #include "WebCookieManagerProxy.h" 34 #include "WebInspectorProxy.h" 34 35 #include "WebProcessPool.h" 35 36 #include <JavaScriptCore/InspectorBackendDispatcher.h> … … 433 434 } 434 435 436 void WebAutomationSession::inspectBrowsingContext(Inspector::ErrorString& errorString, const String& handle, Ref<InspectBrowsingContextCallback>&& callback) 437 { 438 WebPageProxy* page = webPageProxyForHandle(handle); 439 if (!page) 440 FAIL_WITH_PREDEFINED_ERROR(WindowNotFound); 441 442 if (auto callback = m_pendingInspectorCallbacksPerPage.take(page->pageID())) 443 callback->sendFailure(STRING_FOR_PREDEFINED_ERROR_NAME(Timeout)); 444 m_pendingInspectorCallbacksPerPage.set(page->pageID(), WTFMove(callback)); 445 446 // Don't bring the inspector to front since this may be done automatically. 447 // We just want it loaded so it can pause if a breakpoint is hit during a command. 448 if (page->inspector()) 449 page->inspector()->connect(); 450 } 451 435 452 void WebAutomationSession::navigationOccurredForPage(const WebPageProxy& page) 436 453 { 437 454 if (auto callback = m_pendingNavigationInBrowsingContextCallbacksPerPage.take(page.pageID())) 455 callback->sendSuccess(InspectorObject::create()); 456 } 457 458 void WebAutomationSession::inspectorFrontendLoaded(const WebPageProxy& page) 459 { 460 if (auto callback = m_pendingInspectorCallbacksPerPage.take(page.pageID())) 438 461 callback->sendSuccess(InspectorObject::create()); 439 462 } -
trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h
r200280 r200702 84 84 85 85 void navigationOccurredForPage(const WebPageProxy&); 86 void inspectorFrontendLoaded(const WebPageProxy&); 86 87 87 88 #if ENABLE(REMOTE_INSPECTOR) … … 105 106 void goForwardInBrowsingContext(Inspector::ErrorString&, const String&, Ref<GoForwardInBrowsingContextCallback>&&) override; 106 107 void reloadBrowsingContext(Inspector::ErrorString&, const String&, Ref<ReloadBrowsingContextCallback>&&) override; 108 void inspectBrowsingContext(Inspector::ErrorString&, const String&, Ref<InspectBrowsingContextCallback>&&) override; 107 109 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; 108 110 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; … … 177 179 HashMap<uint64_t, RefPtr<Inspector::BackendDispatcher::CallbackBase>> m_pendingNavigationInBrowsingContextCallbacksPerPage; 178 180 181 HashMap<uint64_t, RefPtr<Inspector::BackendDispatcher::CallbackBase>> m_pendingInspectorCallbacksPerPage; 182 179 183 uint64_t m_nextEvaluateJavaScriptCallbackID { 1 }; 180 184 HashMap<uint64_t, RefPtr<Inspector::AutomationBackendDispatcherHandler::EvaluateJavaScriptFunctionCallback>> m_evaluateJavaScriptFunctionCallbacks; -
trunk/Source/WebKit2/UIProcess/Cocoa/WebAutomationSessionCocoa.mm
r200280 r200702 52 52 53 53 for (NSEvent *event in eventsToSend) { 54 // Take focus back in case the Inspector became focused while the prior command or 55 // NSEvent was delivered to the window. 56 [window makeKeyAndOrderFront:nil]; 57 54 58 markEventAsSynthesizedForAutomation(event); 55 59 [window sendEvent:event]; -
trunk/Source/WebKit2/UIProcess/WebInspectorProxy.cpp
r199380 r200702 33 33 #include "WKContextMenuItem.h" 34 34 #include "WKMutableArray.h" 35 #include "WebAutomationSession.h" 35 36 #include "WebFramePolicyListenerProxy.h" 36 37 #include "WebFrameProxy.h" … … 602 603 } 603 604 605 void WebInspectorProxy::frontendLoaded() 606 { 607 if (auto* automationSession = m_inspectedPage->process().processPool().automationSession()) 608 automationSession->inspectorFrontendLoaded(*m_inspectedPage); 609 } 610 604 611 void WebInspectorProxy::bringToFront() 605 612 { -
trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h
r199380 r200702 191 191 // Called by WebInspectorProxy messages 192 192 void createInspectorPage(IPC::Attachment, bool canAttach, bool underTest); 193 void frontendLoaded(); 193 194 void didClose(); 194 195 void bringToFront(); -
trunk/Source/WebKit2/UIProcess/WebInspectorProxy.messages.in
r199380 r200702 24 24 CreateInspectorPage(IPC::Attachment connectionIdentifier, bool canAttach, bool underTest) 25 25 26 FrontendLoaded() 26 27 DidClose() 27 28 BringToFront() -
trunk/Source/WebKit2/WebProcess/WebPage/WebInspectorUI.cpp
r200276 r200702 97 97 setDockSide(m_dockSide); 98 98 99 WebProcess::singleton().parentProcessConnection()->send(Messages::WebInspectorProxy::FrontendLoaded(), m_inspectedPageIdentifier); 100 99 101 bringToFront(); 100 102 } … … 128 130 m_frontendController->setInspectorFrontendClient(nullptr); 129 131 m_frontendController = nullptr; 132 133 if (m_frontendHost) 134 m_frontendHost->disconnectClient(); 130 135 131 136 m_inspectedPageIdentifier = 0;
Note: See TracChangeset
for help on using the changeset viewer.