Bug 46086

Summary: Web Inspector: implement pausing on XHR
Product: WebKit Reporter: Pavel Podivilov <podivilov>
Component: Web Inspector (Deprecated)Assignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: bweinstein, commit-queue, joepeck, keishi, loislo, pfeldman, pmuellr, rik, timothy, yurys
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Screenshot.
none
Proposed patch.
pfeldman: review+
Couple of renames.
none
Couple of renames.
pfeldman: review-
Proposed patch.
none
Proposed patch.
pfeldman: review-
Proposed patch. none

Description Pavel Podivilov 2010-09-20 07:18:36 PDT
Web Inspector: implement pausing on XHR
Comment 1 Pavel Podivilov 2010-09-20 07:20:46 PDT
Created attachment 68078 [details]
Screenshot.
Comment 2 Pavel Podivilov 2010-09-20 07:24:24 PDT
Created attachment 68079 [details]
Proposed patch.
Comment 3 Pavel Feldman 2010-09-20 07:43:30 PDT
Comment on attachment 68079 [details]
Proposed patch.

r+ with nits. I'd actually suggest adding one more item into the native breakpoints list: "Any JavaScript statement" that is On by default. In addition to that, you change behavior of the Pause button respectively.

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

> WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp:34
> +#include "InspectorController.h"

Please mind import order.

> WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp:117
> +    InspectorController::willSendXHR(xmlHttpRequest->scriptExecutionContext(), xmlHttpRequest->url());

I'd suggest calling it:

InspectorController::instrumentWillSendXmlHttpRequest

And all others will be 'instrument*'.

> WebCore/inspector/Inspector.idl:127
> +        [handler=Debug] void setPauseOnEventState(in unsigned int eventType, in boolean state);

pauseOnNextEvent ?
Comment 4 Yury Semikhatsky 2010-09-21 00:10:25 PDT
Comment on attachment 68079 [details]
Proposed patch.

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

>> WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp:117
>> +    InspectorController::willSendXHR(xmlHttpRequest->scriptExecutionContext(), xmlHttpRequest->url());
> 
> I'd suggest calling it:
> 
> InspectorController::instrumentWillSendXmlHttpRequest
> 
> And all others will be 'instrument*'.

It should be easy to support same functionality in JSC. There is already a bug about missing ScriptDebuggServer::breakProgram implementation in JSC which prevents this change from working in JSC but this functionality might deserve filing its own bug.

> WebCore/inspector/InspectorDebuggerAgent.h:99
> +    bool pauseOnEventState(unsigned eventType);

pauseOnEventState -> shouldPauseOnEvent
Comment 5 Pavel Podivilov 2010-09-21 09:08:02 PDT
Created attachment 68246 [details]
Couple of renames.
Comment 6 Pavel Podivilov 2010-09-21 09:24:43 PDT
Created attachment 68249 [details]
Couple of renames.
Comment 7 Pavel Feldman 2010-09-21 09:45:44 PDT
Comment on attachment 68249 [details]
Couple of renames.

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

> WebCore/inspector/InspectorController.cpp:2137
> +#if ENABLE(JAVASCRIPT_DEBUGGER)

I think you should inline willSendXHR here.

> WebCore/inspector/InspectorController.h:483
> +inline InspectorController* InspectorController::inspectorControllerForDocument(Document* document)

Can we employ static InspectorController counter here to speed up things?

> WebCore/inspector/InspectorDebuggerAgent.h:48
> +enum DebuggerEvent {

NativeBreakpointType ?

> WebCore/inspector/InspectorDebuggerAgent.h:83
> +    void willSendXHR(const String& url);

willSendXHR does not look good as a part of debugger agent.
Comment 8 Joseph Pecoraro 2010-09-21 10:01:48 PDT
Comment on attachment 68249 [details]
Couple of renames.

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

> WebCore/inspector/InspectorController.cpp:2140
> +#endif

Might need an #else with UNUSED_PARAM(url) here.

> WebCore/inspector/front-end/BreakpointManager.js:232
>  \ No newline at end of file

We do want newlines. =)
Comment 9 Pavel Podivilov 2010-09-22 05:19:06 PDT
Created attachment 68358 [details]
Proposed patch.
Comment 10 Pavel Podivilov 2010-09-22 05:22:14 PDT
Created attachment 68359 [details]
Proposed patch.
Comment 11 Pavel Feldman 2010-09-22 05:40:44 PDT
Comment on attachment 68359 [details]
Proposed patch.

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

> WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp:117
> +    InspectorController::instrumentWillSendXMLHttpRequest(xmlHttpRequest->scriptExecutionContext(), xmlHttpRequest->url());

Please guard this with #ifdef

> WebCore/inspector/Inspector.idl:140
> +        [handler=Controller] void setNativeBreakpoint(in unsigned int type, in Object breakpoint, out unsigned int breakpointId);

It is unclear how to specify 'breakpoint' parameter format. Why does it have url property? Should we merge 'type' into 'breakpoint' instead? Like

breakpoint: { type: "XHR", condition: { url : "foo" } }

> WebCore/inspector/InspectorController.h:492
> +    ASSERT(document);

Counter?
Comment 12 Pavel Podivilov 2010-09-22 06:16:19 PDT
Created attachment 68362 [details]
Proposed patch.
Comment 13 Pavel Podivilov 2010-09-22 06:17:40 PDT
(In reply to comment #11)
> (From update of attachment 68359 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=68359&action=review
> 
> > WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp:117
> > +    InspectorController::instrumentWillSendXMLHttpRequest(xmlHttpRequest->scriptExecutionContext(), xmlHttpRequest->url());
> 
> Please guard this with #ifdef
With disabled inspector controller, this function wouldn't be called.

> 
> > WebCore/inspector/Inspector.idl:140
> > +        [handler=Controller] void setNativeBreakpoint(in unsigned int type, in Object breakpoint, out unsigned int breakpointId);
> 
> It is unclear how to specify 'breakpoint' parameter format. Why does it have url property? Should we merge 'type' into 'breakpoint' instead? Like
> 
> breakpoint: { type: "XHR", condition: { url : "foo" } }
done

> 
> > WebCore/inspector/InspectorController.h:492
> > +    ASSERT(document);
> 
> Counter?
done
Comment 14 Pavel Feldman 2010-09-22 08:46:56 PDT
Comment on attachment 68362 [details]
Proposed patch.

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

> WebCore/inspector/InspectorController.cpp:156
> +unsigned InspectorController::s_inspectorControllerCount = 0;

I don't see it incrementing.

> WebCore/inspector/InspectorController.cpp:1683
> +        RefPtr<InspectorObject> condition = breakpoint->getObject("condition");

Nit: condition should be optional.

> WebCore/inspector/InspectorController.cpp:1687
> +        if (!condition->getString("url", &url))

Same here, just stop on any.

> WebCore/inspector/InspectorController.h:492
> +inline InspectorController* InspectorController::inspectorControllerForDocument(Document* document)

It is worth checking counter here.
Comment 15 WebKit Commit Bot 2010-09-22 09:06:41 PDT
Comment on attachment 68362 [details]
Proposed patch.

Clearing flags on attachment: 68362

Committed r68049: <http://trac.webkit.org/changeset/68049>
Comment 16 WebKit Commit Bot 2010-09-22 09:06:48 PDT
All reviewed patches have been landed.  Closing bug.