Web Inspector: Add support for handling modal dialogs
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Feb 2013 08:50:19 +0000 (08:50 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Feb 2013 08:50:19 +0000 (08:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=107883

Patch by Ken Kania <kkania@chromium.org> on 2013-02-01
Reviewed by Pavel Feldman.

Introduce support for being notified when a JavaScript modal dialog
is opening and closing, as well as a new command for accepting or
dismissing the dialog.

Source/WebCore:

Test: inspector-protocol/page/willRunJavaScriptDialog.html

* inspector/Inspector.json:
* inspector/InspectorClient.h:
(WebCore::InspectorClient::handleJavaScriptDialog):
(InspectorClient):
* inspector/InspectorInstrumentation.cpp:
(WebCore):
(WebCore::InspectorInstrumentation::willRunJavaScriptDialogImpl):
(WebCore::InspectorInstrumentation::didRunJavaScriptDialogImpl):
* inspector/InspectorInstrumentation.h:
(InspectorInstrumentation):
(WebCore::InspectorInstrumentation::willRunJavaScriptDialog):
(WebCore):
(WebCore::InspectorInstrumentation::didRunJavaScriptDialog):
* inspector/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::willRunJavaScriptDialog):
(WebCore):
(WebCore::InspectorPageAgent::didRunJavaScriptDialog):
(WebCore::InspectorPageAgent::handleJavaScriptDialog):
* inspector/InspectorPageAgent.h:
* inspector/front-end/ResourceTreeModel.js:
(WebInspector.PageDispatcher.prototype.frameStartedLoading):
(WebInspector.PageDispatcher.prototype.frameStoppedLoading):
(WebInspector.PageDispatcher.prototype.frameScheduledNavigation):
(WebInspector.PageDispatcher.prototype.frameClearedScheduledNavigation):
(WebInspector.PageDispatcher.prototype.javascriptDialogOpening):
(WebInspector.PageDispatcher.prototype.javascriptDialogClosed):
* page/Chrome.cpp:
(WebCore::Chrome::runBeforeUnloadConfirmPanel):
(WebCore::Chrome::runJavaScriptAlert):
(WebCore::Chrome::runJavaScriptConfirm):
(WebCore::Chrome::runJavaScriptPrompt):

Source/WebKit/chromium:

* public/WebDevToolsAgent.h:
* src/InspectorClientImpl.cpp:
(WebKit::InspectorClientImpl::handleJavaScriptDialog):
(WebKit):
* src/InspectorClientImpl.h:
(InspectorClientImpl):
* src/WebDevToolsAgentImpl.cpp:
(BrowserDataHintStringValues):
(WebKit::WebDevToolsAgentImpl::captureScreenshot):
(WebKit::WebDevToolsAgentImpl::handleJavaScriptDialog):
(WebKit):
(WebKit::browserHintToString):
(WebKit::browserHintFromString):
(WebKit::WebDevToolsAgent::patchWithBrowserData):
* src/WebDevToolsAgentImpl.h:
(WebDevToolsAgentImpl):

LayoutTests:

* inspector-protocol/page/javascriptDialogEvents-expected.txt: Added.
* inspector-protocol/page/javascriptDialogEvents.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@141555 268f45cc-cd09-0410-ab3c-d52691b4dbfc

18 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector-protocol/page/javascriptDialogEvents-expected.txt [new file with mode: 0644]
LayoutTests/inspector-protocol/page/javascriptDialogEvents.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/inspector/Inspector.json
Source/WebCore/inspector/InspectorClient.h
Source/WebCore/inspector/InspectorInstrumentation.cpp
Source/WebCore/inspector/InspectorInstrumentation.h
Source/WebCore/inspector/InspectorPageAgent.cpp
Source/WebCore/inspector/InspectorPageAgent.h
Source/WebCore/inspector/front-end/ResourceTreeModel.js
Source/WebCore/page/Chrome.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/public/WebDevToolsAgent.h
Source/WebKit/chromium/src/InspectorClientImpl.cpp
Source/WebKit/chromium/src/InspectorClientImpl.h
Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp
Source/WebKit/chromium/src/WebDevToolsAgentImpl.h

index a22fc73..c182009 100644 (file)
@@ -1,3 +1,17 @@
+2013-02-01  Ken Kania  <kkania@chromium.org>
+
+        Web Inspector: Add support for handling modal dialogs
+        https://bugs.webkit.org/show_bug.cgi?id=107883
+
+        Reviewed by Pavel Feldman.
+
+        Introduce support for being notified when a JavaScript modal dialog
+        is opening and closing, as well as a new command for accepting or
+        dismissing the dialog.
+
+        * inspector-protocol/page/javascriptDialogEvents-expected.txt: Added.
+        * inspector-protocol/page/javascriptDialogEvents.html: Added.
+
 2013-02-01  Hajime Morrita  <morrita@google.com> 
 
         [Chromium] Unreviewed, marking table-section-overflow-clip-crash.html failed.
diff --git a/LayoutTests/inspector-protocol/page/javascriptDialogEvents-expected.txt b/LayoutTests/inspector-protocol/page/javascriptDialogEvents-expected.txt
new file mode 100644 (file)
index 0000000..9720d86
--- /dev/null
@@ -0,0 +1,13 @@
+CONFIRM NAVIGATION: beforeunload
+ALERT: alert
+CONFIRM: confirm
+PROMPT: prompt, default text: 
+Opening with message: beforeunload
+Closed
+Opening with message: alert
+Closed
+Opening with message: confirm
+Closed
+Opening with message: prompt
+Closed
+
diff --git a/LayoutTests/inspector-protocol/page/javascriptDialogEvents.html b/LayoutTests/inspector-protocol/page/javascriptDialogEvents.html
new file mode 100644 (file)
index 0000000..23e60ad
--- /dev/null
@@ -0,0 +1,43 @@
+<html>
+<head>
+<script type="text/javascript" src="../../http/tests/inspector-protocol/resources/protocol-test.js"></script>
+<script>
+
+window.addEventListener("beforeunload", onBeforeUnload);
+
+function onBeforeUnload()
+{
+    return "beforeunload";
+}
+
+function test()
+{
+    InspectorTest.eventHandler["Page.javascriptDialogOpening"] = onOpening;
+    InspectorTest.eventHandler["Page.javascriptDialogClosed"] = onClosed;
+    InspectorTest.sendCommand("Page.enable", {});
+
+    function onOpening(event)
+    {
+        InspectorTest.log("Opening with message: " + event.params.message);
+    }
+    function onClosed()
+    {
+        InspectorTest.log("Closed");
+    }
+
+    InspectorTest.sendCommand("Page.navigate", { "url": "nosuchurl" });
+    InspectorTest.sendCommand("Runtime.evaluate", { "expression": "alert('alert')" });
+    InspectorTest.sendCommand("Runtime.evaluate", { "expression": "confirm('confirm')" });
+    InspectorTest.sendCommand("Runtime.evaluate", { "expression": "prompt('prompt')" }, onDone);
+
+    function onDone()
+    {
+        InspectorTest.completeTest();
+    }
+}
+
+</script>
+</head>
+<body onload="runTest()">
+</body>
+</html>
index 302bccd..16cf61b 100644 (file)
@@ -1,3 +1,48 @@
+2013-02-01  Ken Kania  <kkania@chromium.org>
+
+        Web Inspector: Add support for handling modal dialogs
+        https://bugs.webkit.org/show_bug.cgi?id=107883
+
+        Reviewed by Pavel Feldman.
+
+        Introduce support for being notified when a JavaScript modal dialog
+        is opening and closing, as well as a new command for accepting or
+        dismissing the dialog.
+
+        Test: inspector-protocol/page/willRunJavaScriptDialog.html
+
+        * inspector/Inspector.json:
+        * inspector/InspectorClient.h:
+        (WebCore::InspectorClient::handleJavaScriptDialog):
+        (InspectorClient):
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore):
+        (WebCore::InspectorInstrumentation::willRunJavaScriptDialogImpl):
+        (WebCore::InspectorInstrumentation::didRunJavaScriptDialogImpl):
+        * inspector/InspectorInstrumentation.h:
+        (InspectorInstrumentation):
+        (WebCore::InspectorInstrumentation::willRunJavaScriptDialog):
+        (WebCore):
+        (WebCore::InspectorInstrumentation::didRunJavaScriptDialog):
+        * inspector/InspectorPageAgent.cpp:
+        (WebCore::InspectorPageAgent::willRunJavaScriptDialog):
+        (WebCore):
+        (WebCore::InspectorPageAgent::didRunJavaScriptDialog):
+        (WebCore::InspectorPageAgent::handleJavaScriptDialog):
+        * inspector/InspectorPageAgent.h:
+        * inspector/front-end/ResourceTreeModel.js:
+        (WebInspector.PageDispatcher.prototype.frameStartedLoading):
+        (WebInspector.PageDispatcher.prototype.frameStoppedLoading):
+        (WebInspector.PageDispatcher.prototype.frameScheduledNavigation):
+        (WebInspector.PageDispatcher.prototype.frameClearedScheduledNavigation):
+        (WebInspector.PageDispatcher.prototype.javascriptDialogOpening):
+        (WebInspector.PageDispatcher.prototype.javascriptDialogClosed):
+        * page/Chrome.cpp:
+        (WebCore::Chrome::runBeforeUnloadConfirmPanel):
+        (WebCore::Chrome::runJavaScriptAlert):
+        (WebCore::Chrome::runJavaScriptConfirm):
+        (WebCore::Chrome::runJavaScriptPrompt):
+
 2013-02-01  Dan Alcantara  <dfalcantara@chromium.org>
 
         Touch disambiguation blacklist is not being queried properly
index 1559201..6e24ab7 100644 (file)
                     { "name": "data", "type": "string", "description": "Base64-encoded image data (PNG)." }
                 ],
                 "hidden": true
+            },
+            {
+                "name": "handleJavaScriptDialog",
+                "description": "Accepts or dismisses a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload).",
+                "parameters": [
+                    { "name": "accept", "type": "boolean", "description": "Whether to accept or dismiss the dialog." }
+                ],
+                "hidden": true
             }
         ],
         "events": [
                     { "name": "frameId", "$ref": "Network.FrameId", "description": "Id of the frame that has cleared its scheduled navigation." }
                 ],
                 "hidden": true
+            },
+            {
+                "name": "javascriptDialogOpening",
+                "description": "Fired when a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload) is about to open.",
+                "parameters": [
+                    { "name": "message", "type": "string", "description": "Message that will be displayed by the dialog." }
+                ],
+                "hidden": true
+            },
+            {
+                "name": "javascriptDialogClosed",
+                "description": "Fired when a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload) has been closed.",
+                "hidden": true
             }
         ]
     },
index 0f28ebc..b9f8f56 100644 (file)
@@ -86,6 +86,8 @@ public:
 
     virtual bool captureScreenshot(String*) { return false; }
 
+    virtual bool handleJavaScriptDialog(bool) { return false; }
+
     static bool doDispatchMessageOnFrontendPage(Page* frontendPage, const String& message);
 };
 
index d29329e..a1f501d 100644 (file)
@@ -977,6 +977,19 @@ void InspectorInstrumentation::frameClearedScheduledNavigationImpl(Instrumenting
         inspectorPageAgent->frameClearedScheduledNavigation(frame);
 }
 
+InspectorInstrumentationCookie InspectorInstrumentation::willRunJavaScriptDialogImpl(InstrumentingAgents* instrumentingAgents, const String& message)
+{
+    if (InspectorPageAgent* inspectorPageAgent = instrumentingAgents->inspectorPageAgent())
+        inspectorPageAgent->willRunJavaScriptDialog(message);
+    return InspectorInstrumentationCookie(instrumentingAgents, 0);
+}
+
+void InspectorInstrumentation::didRunJavaScriptDialogImpl(const InspectorInstrumentationCookie& cookie)
+{
+    if (InspectorPageAgent* inspectorPageAgent = cookie.instrumentingAgents()->inspectorPageAgent())
+        inspectorPageAgent->didRunJavaScriptDialog();
+}
+
 void InspectorInstrumentation::willDestroyCachedResourceImpl(CachedResource* cachedResource)
 {
     if (!instrumentingAgentsSet)
index 31bf7e9..1fa8dfb 100644 (file)
@@ -215,6 +215,8 @@ public:
     static void frameStoppedLoading(Frame*);
     static void frameScheduledNavigation(Frame*, double delay);
     static void frameClearedScheduledNavigation(Frame*);
+    static InspectorInstrumentationCookie willRunJavaScriptDialog(Page*, const String& message);
+    static void didRunJavaScriptDialog(const InspectorInstrumentationCookie&);
     static void willDestroyCachedResource(CachedResource*);
 
     static InspectorInstrumentationCookie willWriteHTML(Document*, unsigned int length, unsigned int startLine);
@@ -418,6 +420,8 @@ private:
     static void frameStoppedLoadingImpl(InstrumentingAgents*, Frame*);
     static void frameScheduledNavigationImpl(InstrumentingAgents*, Frame*, double delay);
     static void frameClearedScheduledNavigationImpl(InstrumentingAgents*, Frame*);
+    static InspectorInstrumentationCookie willRunJavaScriptDialogImpl(InstrumentingAgents*, const String& message);
+    static void didRunJavaScriptDialogImpl(const InspectorInstrumentationCookie&);
     static void willDestroyCachedResourceImpl(CachedResource*);
 
     static InspectorInstrumentationCookie willWriteHTMLImpl(InstrumentingAgents*, unsigned int length, unsigned int startLine, Frame*);
@@ -1712,6 +1716,30 @@ inline void InspectorInstrumentation::frameClearedScheduledNavigation(Frame* fra
 #endif
 }
 
+inline InspectorInstrumentationCookie InspectorInstrumentation::willRunJavaScriptDialog(Page* page, const String& message)
+{
+#if ENABLE(INSPECTOR)
+    FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
+    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
+        return willRunJavaScriptDialogImpl(instrumentingAgents, message);
+#else
+    UNUSED_PARAM(page);
+    UNUSED_PARAM(message);
+#endif
+    return InspectorInstrumentationCookie();
+}
+
+inline void InspectorInstrumentation::didRunJavaScriptDialog(const InspectorInstrumentationCookie& cookie)
+{
+#if ENABLE(INSPECTOR)
+    FAST_RETURN_IF_NO_FRONTENDS(void());
+    if (cookie.isValid())
+        didRunJavaScriptDialogImpl(cookie);
+#else
+    UNUSED_PARAM(cookie);
+#endif
+}
+
 inline void InspectorInstrumentation::willDestroyCachedResource(CachedResource* cachedResource)
 {
 #if ENABLE(INSPECTOR)
index 12fcd7f..e673a00 100644 (file)
@@ -941,6 +941,16 @@ void InspectorPageAgent::frameClearedScheduledNavigation(Frame* frame)
     m_frontend->frameClearedScheduledNavigation(frameId(frame));
 }
 
+void InspectorPageAgent::willRunJavaScriptDialog(const String& message)
+{
+    m_frontend->javascriptDialogOpening(message);
+}
+
+void InspectorPageAgent::didRunJavaScriptDialog()
+{
+    m_frontend->javascriptDialogClosed();
+}
+
 void InspectorPageAgent::applyScreenWidthOverride(long* width)
 {
     long widthOverride = m_state->getLong(PageAgentState::pageAgentScreenWidthOverride);
@@ -1240,6 +1250,12 @@ void InspectorPageAgent::captureScreenshot(ErrorString* errorString, String* dat
         *errorString = "Could not capture screenshot";
 }
 
+void InspectorPageAgent::handleJavaScriptDialog(ErrorString* errorString, bool accept)
+{
+    if (!m_client->handleJavaScriptDialog(accept))
+        *errorString = "Could not handle JavaScript dialog";
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(INSPECTOR)
index 61d6b04..986cc74 100644 (file)
@@ -126,6 +126,7 @@ public:
     virtual void getCompositingBordersVisible(ErrorString*, bool* out_param);
     virtual void setCompositingBordersVisible(ErrorString*, bool);
     virtual void captureScreenshot(ErrorString*, String* data);
+    virtual void handleJavaScriptDialog(ErrorString*, bool accept);
 
     // Geolocation override helpers.
     GeolocationPosition* overrideGeolocationPosition(GeolocationPosition*);
@@ -144,6 +145,8 @@ public:
     void frameStoppedLoading(Frame*);
     void frameScheduledNavigation(Frame*, double delay);
     void frameClearedScheduledNavigation(Frame*);
+    void willRunJavaScriptDialog(const String& message);
+    void didRunJavaScriptDialog();
     void applyScreenWidthOverride(long*);
     void applyScreenHeightOverride(long*);
     void applyEmulatedMedia(String*);
index 0a876eb..d3e61eb 100644 (file)
@@ -603,16 +603,28 @@ WebInspector.PageDispatcher.prototype = {
         this._resourceTreeModel._frameDetached(frameId);
     },
 
-    frameStartedLoading: function(frameId) {
+    frameStartedLoading: function(frameId)
+    {
+    },
+
+    frameStoppedLoading: function(frameId)
+    {
+    },
+
+    frameScheduledNavigation: function(frameId, delay)
+    {
     },
 
-    frameStoppedLoading: function(frameId) {
+    frameClearedScheduledNavigation: function(frameId)
+    {
     },
 
-    frameScheduledNavigation: function(frameId, delay) {
+    javascriptDialogOpening: function(message)
+    {
     },
 
-    frameClearedScheduledNavigation: function(frameId) {
+    javascriptDialogClosed: function()
+    {
     }
 }
 
index 84dfcb4..85a9755 100644 (file)
@@ -293,7 +293,10 @@ bool Chrome::runBeforeUnloadConfirmPanel(const String& message, Frame* frame)
     // otherwise cause the load to continue while we're in the middle of executing JavaScript.
     PageGroupLoadDeferrer deferrer(m_page, true);
 
-    return m_client->runBeforeUnloadConfirmPanel(message, frame);
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRunJavaScriptDialog(m_page, message);
+    bool ok = m_client->runBeforeUnloadConfirmPanel(message, frame);
+    InspectorInstrumentation::didRunJavaScriptDialog(cookie);
+    return ok;
 }
 
 void Chrome::closeWindowSoon()
@@ -312,7 +315,11 @@ void Chrome::runJavaScriptAlert(Frame* frame, const String& message)
 
     ASSERT(frame);
     notifyPopupOpeningObservers();
-    m_client->runJavaScriptAlert(frame, frame->displayStringModifiedByEncoding(message));
+    String displayMessage = frame->displayStringModifiedByEncoding(message);
+
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRunJavaScriptDialog(m_page, displayMessage);
+    m_client->runJavaScriptAlert(frame, displayMessage);
+    InspectorInstrumentation::didRunJavaScriptDialog(cookie);
 }
 
 bool Chrome::runJavaScriptConfirm(Frame* frame, const String& message)
@@ -326,7 +333,12 @@ bool Chrome::runJavaScriptConfirm(Frame* frame, const String& message)
 
     ASSERT(frame);
     notifyPopupOpeningObservers();
-    return m_client->runJavaScriptConfirm(frame, frame->displayStringModifiedByEncoding(message));
+    String displayMessage = frame->displayStringModifiedByEncoding(message);
+
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRunJavaScriptDialog(m_page, displayMessage);
+    bool ok = m_client->runJavaScriptConfirm(frame, displayMessage);
+    InspectorInstrumentation::didRunJavaScriptDialog(cookie);
+    return ok;
 }
 
 bool Chrome::runJavaScriptPrompt(Frame* frame, const String& prompt, const String& defaultValue, String& result)
@@ -340,7 +352,11 @@ bool Chrome::runJavaScriptPrompt(Frame* frame, const String& prompt, const Strin
 
     ASSERT(frame);
     notifyPopupOpeningObservers();
-    bool ok = m_client->runJavaScriptPrompt(frame, frame->displayStringModifiedByEncoding(prompt), frame->displayStringModifiedByEncoding(defaultValue), result);
+    String displayPrompt = frame->displayStringModifiedByEncoding(prompt);
+
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRunJavaScriptDialog(m_page, displayPrompt);
+    bool ok = m_client->runJavaScriptPrompt(frame, displayPrompt, frame->displayStringModifiedByEncoding(defaultValue), result);
+    InspectorInstrumentation::didRunJavaScriptDialog(cookie);
 
     if (ok)
         result = frame->displayStringModifiedByEncoding(result);
index d3a14d8..2fdee77 100644 (file)
@@ -1,3 +1,31 @@
+2013-02-01  Ken Kania  <kkania@chromium.org>
+
+        Web Inspector: Add support for handling modal dialogs
+        https://bugs.webkit.org/show_bug.cgi?id=107883
+
+        Reviewed by Pavel Feldman.
+
+        Introduce support for being notified when a JavaScript modal dialog
+        is opening and closing, as well as a new command for accepting or
+        dismissing the dialog.
+
+        * public/WebDevToolsAgent.h:
+        * src/InspectorClientImpl.cpp:
+        (WebKit::InspectorClientImpl::handleJavaScriptDialog):
+        (WebKit):
+        * src/InspectorClientImpl.h:
+        (InspectorClientImpl):
+        * src/WebDevToolsAgentImpl.cpp:
+        (BrowserDataHintStringValues):
+        (WebKit::WebDevToolsAgentImpl::captureScreenshot):
+        (WebKit::WebDevToolsAgentImpl::handleJavaScriptDialog):
+        (WebKit):
+        (WebKit::browserHintToString):
+        (WebKit::browserHintFromString):
+        (WebKit::WebDevToolsAgent::patchWithBrowserData):
+        * src/WebDevToolsAgentImpl.h:
+        (WebDevToolsAgentImpl):
+
 2013-02-01  Dan Alcantara  <dfalcantara@chromium.org>
 
         Touch disambiguation blacklist is not being queried properly
index 4ccfb5a..f2f060f 100644 (file)
@@ -51,8 +51,10 @@ class WebDevToolsAgent {
 public:
     // Hint for the browser on the data it should prepare for message patching.
     enum BrowserDataHint {
-        BrowserDataHintNone = 0,
-        BrowserDataHintScreenshot = 1,
+        BrowserDataHintNone,
+        BrowserDataHintScreenshot,
+        BrowserDataHintAcceptJavaScriptDialog,
+        BrowserDataHintDismissJavaScriptDialog,
     };
 
     virtual ~WebDevToolsAgent() {}
index 5791c9d..e94df9a 100644 (file)
@@ -211,6 +211,13 @@ bool InspectorClientImpl::captureScreenshot(String* data)
     return false;
 }
 
+bool InspectorClientImpl::handleJavaScriptDialog(bool accept)
+{
+    if (WebDevToolsAgentImpl* agent = devToolsAgent())
+        return agent->handleJavaScriptDialog(accept);
+    return false;
+}
+
 WebDevToolsAgentImpl* InspectorClientImpl::devToolsAgent()
 {
     return static_cast<WebDevToolsAgentImpl*>(m_inspectedWebView->devToolsAgent());
index 87119e3..d173fca 100644 (file)
@@ -89,6 +89,8 @@ public:
 
     virtual bool captureScreenshot(WTF::String* data);
 
+    virtual bool handleJavaScriptDialog(bool accept);
+
 private:
     WebDevToolsAgentImpl* devToolsAgent();
 
index f54152b..4ea460a 100644 (file)
@@ -83,6 +83,8 @@ namespace WebKit {
 
 namespace BrowserDataHintStringValues {
 static const char screenshot[] = "screenshot";
+static const char acceptJavaScriptDialog[] = "acceptJavaScriptDialog";
+static const char dismissJavaScriptDialog[] = "dismissJavaScriptDialog";
 }
 
 class ClientMessageLoopAdapter : public PageScriptDebugServer::ClientMessageLoop {
@@ -574,14 +576,21 @@ void WebDevToolsAgentImpl::dumpUncountedAllocatedObjects(const HashMap<const voi
     m_client->dumpUncountedAllocatedObjects(&provider);
 }
 
-bool WebDevToolsAgentImpl::captureScreenshot(WTF::String* data)
+bool WebDevToolsAgentImpl::captureScreenshot(String* data)
 {
-    // Value is going to be substituted with the actual data on the browser level.
+    // Value is going to be substituted with the actual data in the browser process.
     *data = "{screenshot-placeholder}";
     m_sendWithBrowserDataHint = BrowserDataHintScreenshot;
     return true;
 }
 
+bool WebDevToolsAgentImpl::handleJavaScriptDialog(bool accept)
+{
+    // Operation is going to be performed in the browser process.
+    m_sendWithBrowserDataHint = accept ? BrowserDataHintAcceptJavaScriptDialog : BrowserDataHintDismissJavaScriptDialog;
+    return true;
+}
+
 void WebDevToolsAgentImpl::dispatchOnInspectorBackend(const WebString& message)
 {
     inspectorController()->dispatchMessageFromFrontend(message);
@@ -661,6 +670,10 @@ static String browserHintToString(WebDevToolsAgent::BrowserDataHint dataHint)
     switch (dataHint) {
     case WebDevToolsAgent::BrowserDataHintScreenshot:
         return BrowserDataHintStringValues::screenshot;
+    case WebDevToolsAgent::BrowserDataHintAcceptJavaScriptDialog:
+        return BrowserDataHintStringValues::acceptJavaScriptDialog;
+    case WebDevToolsAgent::BrowserDataHintDismissJavaScriptDialog:
+        return BrowserDataHintStringValues::dismissJavaScriptDialog;
     case WebDevToolsAgent::BrowserDataHintNone:
     default:
         ASSERT_NOT_REACHED();
@@ -672,6 +685,10 @@ static WebDevToolsAgent::BrowserDataHint browserHintFromString(const String& val
 {
     if (value == BrowserDataHintStringValues::screenshot)
         return WebDevToolsAgent::BrowserDataHintScreenshot;
+    if (value == BrowserDataHintStringValues::acceptJavaScriptDialog)
+        return WebDevToolsAgent::BrowserDataHintAcceptJavaScriptDialog;
+    if (value == BrowserDataHintStringValues::dismissJavaScriptDialog)
+        return WebDevToolsAgent::BrowserDataHintDismissJavaScriptDialog;
     ASSERT_NOT_REACHED();
     return WebDevToolsAgent::BrowserDataHintNone;
 }
@@ -827,6 +844,10 @@ WebString WebDevToolsAgent::patchWithBrowserData(const WebString& message, Brows
     case BrowserDataHintScreenshot:
         resultObject->setString("data", hintData);
         break;
+    case BrowserDataHintAcceptJavaScriptDialog:
+        break;
+    case BrowserDataHintDismissJavaScriptDialog:
+        break;
     case BrowserDataHintNone:
     default:
         ASSERT_NOT_REACHED();
index fe340dd..5e8f245 100644 (file)
@@ -113,6 +113,8 @@ public:
 
     virtual bool captureScreenshot(WTF::String* data);
 
+    virtual bool handleJavaScriptDialog(bool accept);
+
     int hostId() { return m_hostId; }
 
     // WebPageOverlay