Changeset 141555 in webkit
- Timestamp:
- Feb 1, 2013 12:50:19 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r141552 r141555 1 2013-02-01 Ken Kania <kkania@chromium.org> 2 3 Web Inspector: Add support for handling modal dialogs 4 https://bugs.webkit.org/show_bug.cgi?id=107883 5 6 Reviewed by Pavel Feldman. 7 8 Introduce support for being notified when a JavaScript modal dialog 9 is opening and closing, as well as a new command for accepting or 10 dismissing the dialog. 11 12 * inspector-protocol/page/javascriptDialogEvents-expected.txt: Added. 13 * inspector-protocol/page/javascriptDialogEvents.html: Added. 14 1 15 2013-02-01 Hajime Morrita <morrita@google.com> 2 16 -
trunk/Source/WebCore/ChangeLog
r141554 r141555 1 2013-02-01 Ken Kania <kkania@chromium.org> 2 3 Web Inspector: Add support for handling modal dialogs 4 https://bugs.webkit.org/show_bug.cgi?id=107883 5 6 Reviewed by Pavel Feldman. 7 8 Introduce support for being notified when a JavaScript modal dialog 9 is opening and closing, as well as a new command for accepting or 10 dismissing the dialog. 11 12 Test: inspector-protocol/page/willRunJavaScriptDialog.html 13 14 * inspector/Inspector.json: 15 * inspector/InspectorClient.h: 16 (WebCore::InspectorClient::handleJavaScriptDialog): 17 (InspectorClient): 18 * inspector/InspectorInstrumentation.cpp: 19 (WebCore): 20 (WebCore::InspectorInstrumentation::willRunJavaScriptDialogImpl): 21 (WebCore::InspectorInstrumentation::didRunJavaScriptDialogImpl): 22 * inspector/InspectorInstrumentation.h: 23 (InspectorInstrumentation): 24 (WebCore::InspectorInstrumentation::willRunJavaScriptDialog): 25 (WebCore): 26 (WebCore::InspectorInstrumentation::didRunJavaScriptDialog): 27 * inspector/InspectorPageAgent.cpp: 28 (WebCore::InspectorPageAgent::willRunJavaScriptDialog): 29 (WebCore): 30 (WebCore::InspectorPageAgent::didRunJavaScriptDialog): 31 (WebCore::InspectorPageAgent::handleJavaScriptDialog): 32 * inspector/InspectorPageAgent.h: 33 * inspector/front-end/ResourceTreeModel.js: 34 (WebInspector.PageDispatcher.prototype.frameStartedLoading): 35 (WebInspector.PageDispatcher.prototype.frameStoppedLoading): 36 (WebInspector.PageDispatcher.prototype.frameScheduledNavigation): 37 (WebInspector.PageDispatcher.prototype.frameClearedScheduledNavigation): 38 (WebInspector.PageDispatcher.prototype.javascriptDialogOpening): 39 (WebInspector.PageDispatcher.prototype.javascriptDialogClosed): 40 * page/Chrome.cpp: 41 (WebCore::Chrome::runBeforeUnloadConfirmPanel): 42 (WebCore::Chrome::runJavaScriptAlert): 43 (WebCore::Chrome::runJavaScriptConfirm): 44 (WebCore::Chrome::runJavaScriptPrompt): 45 1 46 2013-02-01 Dan Alcantara <dfalcantara@chromium.org> 2 47 -
trunk/Source/WebCore/inspector/Inspector.json
r141403 r141555 481 481 ], 482 482 "hidden": true 483 }, 484 { 485 "name": "handleJavaScriptDialog", 486 "description": "Accepts or dismisses a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload).", 487 "parameters": [ 488 { "name": "accept", "type": "boolean", "description": "Whether to accept or dismiss the dialog." } 489 ], 490 "hidden": true 483 491 } 484 492 ], … … 543 551 { "name": "frameId", "$ref": "Network.FrameId", "description": "Id of the frame that has cleared its scheduled navigation." } 544 552 ], 553 "hidden": true 554 }, 555 { 556 "name": "javascriptDialogOpening", 557 "description": "Fired when a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload) is about to open.", 558 "parameters": [ 559 { "name": "message", "type": "string", "description": "Message that will be displayed by the dialog." } 560 ], 561 "hidden": true 562 }, 563 { 564 "name": "javascriptDialogClosed", 565 "description": "Fired when a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload) has been closed.", 545 566 "hidden": true 546 567 } -
trunk/Source/WebCore/inspector/InspectorClient.h
r140798 r141555 87 87 virtual bool captureScreenshot(String*) { return false; } 88 88 89 virtual bool handleJavaScriptDialog(bool) { return false; } 90 89 91 static bool doDispatchMessageOnFrontendPage(Page* frontendPage, const String& message); 90 92 }; -
trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp
r141098 r141555 978 978 } 979 979 980 InspectorInstrumentationCookie InspectorInstrumentation::willRunJavaScriptDialogImpl(InstrumentingAgents* instrumentingAgents, const String& message) 981 { 982 if (InspectorPageAgent* inspectorPageAgent = instrumentingAgents->inspectorPageAgent()) 983 inspectorPageAgent->willRunJavaScriptDialog(message); 984 return InspectorInstrumentationCookie(instrumentingAgents, 0); 985 } 986 987 void InspectorInstrumentation::didRunJavaScriptDialogImpl(const InspectorInstrumentationCookie& cookie) 988 { 989 if (InspectorPageAgent* inspectorPageAgent = cookie.instrumentingAgents()->inspectorPageAgent()) 990 inspectorPageAgent->didRunJavaScriptDialog(); 991 } 992 980 993 void InspectorInstrumentation::willDestroyCachedResourceImpl(CachedResource* cachedResource) 981 994 { -
trunk/Source/WebCore/inspector/InspectorInstrumentation.h
r140649 r141555 216 216 static void frameScheduledNavigation(Frame*, double delay); 217 217 static void frameClearedScheduledNavigation(Frame*); 218 static InspectorInstrumentationCookie willRunJavaScriptDialog(Page*, const String& message); 219 static void didRunJavaScriptDialog(const InspectorInstrumentationCookie&); 218 220 static void willDestroyCachedResource(CachedResource*); 219 221 … … 419 421 static void frameScheduledNavigationImpl(InstrumentingAgents*, Frame*, double delay); 420 422 static void frameClearedScheduledNavigationImpl(InstrumentingAgents*, Frame*); 423 static InspectorInstrumentationCookie willRunJavaScriptDialogImpl(InstrumentingAgents*, const String& message); 424 static void didRunJavaScriptDialogImpl(const InspectorInstrumentationCookie&); 421 425 static void willDestroyCachedResourceImpl(CachedResource*); 422 426 … … 1713 1717 } 1714 1718 1719 inline InspectorInstrumentationCookie InspectorInstrumentation::willRunJavaScriptDialog(Page* page, const String& message) 1720 { 1721 #if ENABLE(INSPECTOR) 1722 FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie()); 1723 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page)) 1724 return willRunJavaScriptDialogImpl(instrumentingAgents, message); 1725 #else 1726 UNUSED_PARAM(page); 1727 UNUSED_PARAM(message); 1728 #endif 1729 return InspectorInstrumentationCookie(); 1730 } 1731 1732 inline void InspectorInstrumentation::didRunJavaScriptDialog(const InspectorInstrumentationCookie& cookie) 1733 { 1734 #if ENABLE(INSPECTOR) 1735 FAST_RETURN_IF_NO_FRONTENDS(void()); 1736 if (cookie.isValid()) 1737 didRunJavaScriptDialogImpl(cookie); 1738 #else 1739 UNUSED_PARAM(cookie); 1740 #endif 1741 } 1742 1715 1743 inline void InspectorInstrumentation::willDestroyCachedResource(CachedResource* cachedResource) 1716 1744 { -
trunk/Source/WebCore/inspector/InspectorPageAgent.cpp
r141403 r141555 942 942 } 943 943 944 void InspectorPageAgent::willRunJavaScriptDialog(const String& message) 945 { 946 m_frontend->javascriptDialogOpening(message); 947 } 948 949 void InspectorPageAgent::didRunJavaScriptDialog() 950 { 951 m_frontend->javascriptDialogClosed(); 952 } 953 944 954 void InspectorPageAgent::applyScreenWidthOverride(long* width) 945 955 { … … 1241 1251 } 1242 1252 1253 void InspectorPageAgent::handleJavaScriptDialog(ErrorString* errorString, bool accept) 1254 { 1255 if (!m_client->handleJavaScriptDialog(accept)) 1256 *errorString = "Could not handle JavaScript dialog"; 1257 } 1258 1243 1259 } // namespace WebCore 1244 1260 -
trunk/Source/WebCore/inspector/InspectorPageAgent.h
r141403 r141555 127 127 virtual void setCompositingBordersVisible(ErrorString*, bool); 128 128 virtual void captureScreenshot(ErrorString*, String* data); 129 virtual void handleJavaScriptDialog(ErrorString*, bool accept); 129 130 130 131 // Geolocation override helpers. … … 145 146 void frameScheduledNavigation(Frame*, double delay); 146 147 void frameClearedScheduledNavigation(Frame*); 148 void willRunJavaScriptDialog(const String& message); 149 void didRunJavaScriptDialog(); 147 150 void applyScreenWidthOverride(long*); 148 151 void applyScreenHeightOverride(long*); -
trunk/Source/WebCore/inspector/front-end/ResourceTreeModel.js
r140649 r141555 604 604 }, 605 605 606 frameStartedLoading: function(frameId) { 607 }, 608 609 frameStoppedLoading: function(frameId) { 610 }, 611 612 frameScheduledNavigation: function(frameId, delay) { 613 }, 614 615 frameClearedScheduledNavigation: function(frameId) { 606 frameStartedLoading: function(frameId) 607 { 608 }, 609 610 frameStoppedLoading: function(frameId) 611 { 612 }, 613 614 frameScheduledNavigation: function(frameId, delay) 615 { 616 }, 617 618 frameClearedScheduledNavigation: function(frameId) 619 { 620 }, 621 622 javascriptDialogOpening: function(message) 623 { 624 }, 625 626 javascriptDialogClosed: function() 627 { 616 628 } 617 629 } -
trunk/Source/WebCore/page/Chrome.cpp
r134886 r141555 294 294 PageGroupLoadDeferrer deferrer(m_page, true); 295 295 296 return m_client->runBeforeUnloadConfirmPanel(message, frame); 296 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRunJavaScriptDialog(m_page, message); 297 bool ok = m_client->runBeforeUnloadConfirmPanel(message, frame); 298 InspectorInstrumentation::didRunJavaScriptDialog(cookie); 299 return ok; 297 300 } 298 301 … … 313 316 ASSERT(frame); 314 317 notifyPopupOpeningObservers(); 315 m_client->runJavaScriptAlert(frame, frame->displayStringModifiedByEncoding(message)); 318 String displayMessage = frame->displayStringModifiedByEncoding(message); 319 320 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRunJavaScriptDialog(m_page, displayMessage); 321 m_client->runJavaScriptAlert(frame, displayMessage); 322 InspectorInstrumentation::didRunJavaScriptDialog(cookie); 316 323 } 317 324 … … 327 334 ASSERT(frame); 328 335 notifyPopupOpeningObservers(); 329 return m_client->runJavaScriptConfirm(frame, frame->displayStringModifiedByEncoding(message)); 336 String displayMessage = frame->displayStringModifiedByEncoding(message); 337 338 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRunJavaScriptDialog(m_page, displayMessage); 339 bool ok = m_client->runJavaScriptConfirm(frame, displayMessage); 340 InspectorInstrumentation::didRunJavaScriptDialog(cookie); 341 return ok; 330 342 } 331 343 … … 341 353 ASSERT(frame); 342 354 notifyPopupOpeningObservers(); 343 bool ok = m_client->runJavaScriptPrompt(frame, frame->displayStringModifiedByEncoding(prompt), frame->displayStringModifiedByEncoding(defaultValue), result); 355 String displayPrompt = frame->displayStringModifiedByEncoding(prompt); 356 357 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRunJavaScriptDialog(m_page, displayPrompt); 358 bool ok = m_client->runJavaScriptPrompt(frame, displayPrompt, frame->displayStringModifiedByEncoding(defaultValue), result); 359 InspectorInstrumentation::didRunJavaScriptDialog(cookie); 344 360 345 361 if (ok) -
trunk/Source/WebKit/chromium/ChangeLog
r141554 r141555 1 2013-02-01 Ken Kania <kkania@chromium.org> 2 3 Web Inspector: Add support for handling modal dialogs 4 https://bugs.webkit.org/show_bug.cgi?id=107883 5 6 Reviewed by Pavel Feldman. 7 8 Introduce support for being notified when a JavaScript modal dialog 9 is opening and closing, as well as a new command for accepting or 10 dismissing the dialog. 11 12 * public/WebDevToolsAgent.h: 13 * src/InspectorClientImpl.cpp: 14 (WebKit::InspectorClientImpl::handleJavaScriptDialog): 15 (WebKit): 16 * src/InspectorClientImpl.h: 17 (InspectorClientImpl): 18 * src/WebDevToolsAgentImpl.cpp: 19 (BrowserDataHintStringValues): 20 (WebKit::WebDevToolsAgentImpl::captureScreenshot): 21 (WebKit::WebDevToolsAgentImpl::handleJavaScriptDialog): 22 (WebKit): 23 (WebKit::browserHintToString): 24 (WebKit::browserHintFromString): 25 (WebKit::WebDevToolsAgent::patchWithBrowserData): 26 * src/WebDevToolsAgentImpl.h: 27 (WebDevToolsAgentImpl): 28 1 29 2013-02-01 Dan Alcantara <dfalcantara@chromium.org> 2 30 -
trunk/Source/WebKit/chromium/public/WebDevToolsAgent.h
r140951 r141555 52 52 // Hint for the browser on the data it should prepare for message patching. 53 53 enum BrowserDataHint { 54 BrowserDataHintNone = 0, 55 BrowserDataHintScreenshot = 1, 54 BrowserDataHintNone, 55 BrowserDataHintScreenshot, 56 BrowserDataHintAcceptJavaScriptDialog, 57 BrowserDataHintDismissJavaScriptDialog, 56 58 }; 57 59 -
trunk/Source/WebKit/chromium/src/InspectorClientImpl.cpp
r141550 r141555 212 212 } 213 213 214 bool InspectorClientImpl::handleJavaScriptDialog(bool accept) 215 { 216 if (WebDevToolsAgentImpl* agent = devToolsAgent()) 217 return agent->handleJavaScriptDialog(accept); 218 return false; 219 } 220 214 221 WebDevToolsAgentImpl* InspectorClientImpl::devToolsAgent() 215 222 { -
trunk/Source/WebKit/chromium/src/InspectorClientImpl.h
r140798 r141555 90 90 virtual bool captureScreenshot(WTF::String* data); 91 91 92 virtual bool handleJavaScriptDialog(bool accept); 93 92 94 private: 93 95 WebDevToolsAgentImpl* devToolsAgent(); -
trunk/Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp
r140951 r141555 84 84 namespace BrowserDataHintStringValues { 85 85 static const char screenshot[] = "screenshot"; 86 static const char acceptJavaScriptDialog[] = "acceptJavaScriptDialog"; 87 static const char dismissJavaScriptDialog[] = "dismissJavaScriptDialog"; 86 88 } 87 89 … … 575 577 } 576 578 577 bool WebDevToolsAgentImpl::captureScreenshot( WTF::String* data)578 { 579 // Value is going to be substituted with the actual data on the browser level.579 bool WebDevToolsAgentImpl::captureScreenshot(String* data) 580 { 581 // Value is going to be substituted with the actual data in the browser process. 580 582 *data = "{screenshot-placeholder}"; 581 583 m_sendWithBrowserDataHint = BrowserDataHintScreenshot; 584 return true; 585 } 586 587 bool WebDevToolsAgentImpl::handleJavaScriptDialog(bool accept) 588 { 589 // Operation is going to be performed in the browser process. 590 m_sendWithBrowserDataHint = accept ? BrowserDataHintAcceptJavaScriptDialog : BrowserDataHintDismissJavaScriptDialog; 582 591 return true; 583 592 } … … 662 671 case WebDevToolsAgent::BrowserDataHintScreenshot: 663 672 return BrowserDataHintStringValues::screenshot; 673 case WebDevToolsAgent::BrowserDataHintAcceptJavaScriptDialog: 674 return BrowserDataHintStringValues::acceptJavaScriptDialog; 675 case WebDevToolsAgent::BrowserDataHintDismissJavaScriptDialog: 676 return BrowserDataHintStringValues::dismissJavaScriptDialog; 664 677 case WebDevToolsAgent::BrowserDataHintNone: 665 678 default: … … 673 686 if (value == BrowserDataHintStringValues::screenshot) 674 687 return WebDevToolsAgent::BrowserDataHintScreenshot; 688 if (value == BrowserDataHintStringValues::acceptJavaScriptDialog) 689 return WebDevToolsAgent::BrowserDataHintAcceptJavaScriptDialog; 690 if (value == BrowserDataHintStringValues::dismissJavaScriptDialog) 691 return WebDevToolsAgent::BrowserDataHintDismissJavaScriptDialog; 675 692 ASSERT_NOT_REACHED(); 676 693 return WebDevToolsAgent::BrowserDataHintNone; … … 828 845 resultObject->setString("data", hintData); 829 846 break; 847 case BrowserDataHintAcceptJavaScriptDialog: 848 break; 849 case BrowserDataHintDismissJavaScriptDialog: 850 break; 830 851 case BrowserDataHintNone: 831 852 default: -
trunk/Source/WebKit/chromium/src/WebDevToolsAgentImpl.h
r140951 r141555 114 114 virtual bool captureScreenshot(WTF::String* data); 115 115 116 virtual bool handleJavaScriptDialog(bool accept); 117 116 118 int hostId() { return m_hostId; } 117 119
Note: See TracChangeset
for help on using the changeset viewer.