Bug 107883

Summary: Web Inspector: Add support for handling modal dialogs
Product: WebKit Reporter: Ken Kania <kkania>
Component: Web Inspector (Deprecated)Assignee: Ken Kania <kkania>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, apavlov, buildbot, dglazkov, fishd, jamesr, keishi, loislo, pfeldman, pmuellr, rniwa, tkent+wkapi, vsevik, web-inspector-bugs, webkit.review.bot, yurys
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Description Ken Kania 2013-01-24 16:59:54 PST
We'd like to add support for handling modal dialogs opened by javascript, including onbeforeonload. I propose:

Page.modalDialogOpening [event]
frameId: <frameId>
message: String

Page.handleModalDialog [cmd]
accept: Boolean
promptText: String [optional]


Page.modalDialogOpening will be sent before asking the client to run the javascript dialog in Chrome.cpp. Page.handleModalDialog will need to be delegated to the inspector client and be asynchronous.
Comment 1 Ken Kania 2013-01-29 19:15:04 PST
Created attachment 185380 [details]
Patch
Comment 2 WebKit Review Bot 2013-01-29 19:18:22 PST
Please wait for approval from abarth@webkit.org, dglazkov@chromium.org, fishd@chromium.org, jamesr@chromium.org or tkent@chromium.org before submitting, as this patch contains changes to the Chromium public API. See also https://trac.webkit.org/wiki/ChromiumWebKitAPI.
Comment 3 Build Bot 2013-01-29 19:42:06 PST
Comment on attachment 185380 [details]
Patch

Attachment 185380 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://queues.webkit.org/results/16198423
Comment 4 Build Bot 2013-01-29 20:13:57 PST
Comment on attachment 185380 [details]
Patch

Attachment 185380 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/16187477
Comment 5 Ken Kania 2013-01-29 20:43:02 PST
Created attachment 185385 [details]
Patch
Comment 6 Build Bot 2013-01-29 22:17:46 PST
Comment on attachment 185385 [details]
Patch

Attachment 185385 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://queues.webkit.org/results/16202492

New failing tests:
inspector/audits/audits-panel-functional.html
inspector-protocol/page/javascriptDialogEvents.html
Comment 7 Pavel Feldman 2013-01-30 03:23:46 PST
Comment on attachment 185385 [details]
Patch

New test fails on Mac EWS. You should file a bug requesting that mac port implements client hook and disable the test on non-chromium ports. Implementation-wise, it looks good.
Comment 8 Ken Kania 2013-01-30 14:57:49 PST
Created attachment 185588 [details]
Patch
Comment 9 Ken Kania 2013-01-30 15:22:56 PST
(In reply to comment #7)
> (From update of attachment 185385 [details])
> New test fails on Mac EWS. You should file a bug requesting that mac port implements client hook and disable the test on non-chromium ports. Implementation-wise, it looks good.

The new test failed on mac-wk2 because the printf for onbeforeunload occurs in the UIProcess (TestController.cpp), while the printfs for alert/prompt/confirm occur in the WebProcess (InjectedBundlePage.cpp) and aren't printed to the test log until the end, which causes the 'CONFIRM NAVIGATION' to be at the beginning. I think the easiest fix, which my 3rd patch does, is just test the onbeforeunload case at the beginning.
Comment 10 Build Bot 2013-01-30 21:30:31 PST
Comment on attachment 185588 [details]
Patch

Attachment 185588 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/16258095
Comment 11 Yury Semikhatsky 2013-01-31 01:29:02 PST
Comment on attachment 185588 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=185588&action=review

> Source/WebCore/inspector/Inspector.json:560
> +                    { "name": "message", "type": "string", "description": "Message that will be displayed by the dialog." }

Since we cannot pass the message yet then the parameter doesn't make much sense.

> Source/WebCore/inspector/InspectorInstrumentation.h:423
> +    static void javascriptDialogOpeningImpl(InstrumentingAgents*, const String& message);

In case of pairs willFoo/didFoo methods we usually return InspectorInstrumentationCookie from the first method and pass it to the second (see http://trac.webkit.org/browser/trunk/Source/WebCore/inspector/InspectorInstrumentation.h#L220 for example). I'd use the same approach here for consistency.

> Source/WebKit/chromium/public/WebDevToolsAgent.h:56
> +        BrowserDataHintAcceptJavaScriptDialog = 2,

We don't have to explicitly specify enum values here. We could only leave "BrowserDataHintNone = 0," for clarity but since it matches default behavior I'd omit that as well.

> Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp:589
> +    // Operation is going to be performed on the browser level.

I'd rephrase "on the browser level" -> "in the browser process"
Comment 12 Ken Kania 2013-01-31 08:41:27 PST
Created attachment 185791 [details]
Patch
Comment 13 Ken Kania 2013-01-31 08:43:19 PST
(In reply to comment #11)
> (From update of attachment 185588 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=185588&action=review
> 
> > Source/WebCore/inspector/Inspector.json:560
> > +                    { "name": "message", "type": "string", "description": "Message that will be displayed by the dialog." }
> 
> Since we cannot pass the message yet then the parameter doesn't make much sense.
> 
> > Source/WebCore/inspector/InspectorInstrumentation.h:423
> > +    static void javascriptDialogOpeningImpl(InstrumentingAgents*, const String& message);
> 
> In case of pairs willFoo/didFoo methods we usually return InspectorInstrumentationCookie from the first method and pass it to the second (see http://trac.webkit.org/browser/trunk/Source/WebCore/inspector/InspectorInstrumentation.h#L220 for example). I'd use the same approach here for consistency.
> 
> > Source/WebKit/chromium/public/WebDevToolsAgent.h:56
> > +        BrowserDataHintAcceptJavaScriptDialog = 2,
> 
> We don't have to explicitly specify enum values here. We could only leave "BrowserDataHintNone = 0," for clarity but since it matches default behavior I'd omit that as well.
> 
> > Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp:589
> > +    // Operation is going to be performed on the browser level.
> 
> I'd rephrase "on the browser level" -> "in the browser process"

Thanks for the review. I've made all your proposed changes.
Comment 14 Pavel Feldman 2013-01-31 09:49:28 PST
Comment on attachment 185791 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=185791&action=review

A couple of renames and it is good to go.

> Source/WebCore/inspector/Inspector.json:556
> +                "name": "willRunJavaScriptDialog",

Protocol naming that you had earlier was correct. Yury's comment was only about the InspectorInstrumentation.
Comment 15 Ken Kania 2013-01-31 10:12:40 PST
Created attachment 185803 [details]
Patch
Comment 16 WebKit Review Bot 2013-02-01 00:51:53 PST
Comment on attachment 185803 [details]
Patch

Clearing flags on attachment: 185803

Committed r141555: <http://trac.webkit.org/changeset/141555>
Comment 17 WebKit Review Bot 2013-02-01 00:51:58 PST
All reviewed patches have been landed.  Closing bug.