Bug 159546 - Web Inspector: Add XHR breakpoint action to log request/response data to console
Summary: Web Inspector: Add XHR breakpoint action to log request/response data to console
Status: REOPENED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: Other
Hardware: All All
: P2 Enhancement
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2016-07-07 22:12 PDT by Igor Romanov
Modified: 2017-04-12 10:45 PDT (History)
5 users (show)

See Also:


Attachments
Screenshot (111.52 KB, image/png)
2016-07-07 22:12 PDT, Igor Romanov
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Igor Romanov 2016-07-07 22:12:41 PDT
Created attachment 283107 [details]
Screenshot

Please add the ability to logging XMLHttpRequest to the console (as in Chrome, see attachment)
Comment 1 Radar WebKit Bug Importer 2016-07-07 22:13:01 PDT
<rdar://problem/27239077>
Comment 2 Brian Burg 2017-04-10 16:55:38 PDT
XHRs are listed in the Network tab and in Timelines tab. Why would you want this dumped to the console?
Comment 3 Joseph Pecoraro 2017-04-10 19:11:16 PDT
This is a common thing in other tools:

  • Chrome
    - Right click in the Console to see Context Menu

  • Firefox
    - Console > Filter output > XHR

  • Firebug
    - "Firebug shows you each XMLHttpRequest, in ... and the Console tab"
    - http://getfirebug.com/network

I agree that this isn't the best way to debug network traffic but its something that developers are used to and may speed up debugging of some situations (turn on, perform action, turn off, debug the XHRs in that short time period). If it can easily be turned on / off it would be good for those developers that would rather have this then use the Network tab.

I think Nikita had a prototype in the past using just a Safari extension.

That said, if we did this I think we'd want to improve our Console filtering in general otherwise it would get out of Control. Firefox has done a really great job here, and I like what they've done with their filtering.
Comment 4 Igor Romanov 2017-04-11 08:38:38 PDT
To speed up debugging, yes.
It's just handy.

By the way, sometimes does not appear an XHR request in the Resources Tab.
I recorded this: http://recordit.co/NohOA1ckpw 
As you can see on the first site everything is OK, but on the another site XHRs are not listed.
Comment 5 Brian Burg 2017-04-11 08:56:20 PDT
(In reply to Joseph Pecoraro from comment #3)
> This is a common thing in other tools:
> 
>   • Chrome
>     - Right click in the Console to see Context Menu
> 
>   • Firefox
>     - Console > Filter output > XHR
> 
>   • Firebug
>     - "Firebug shows you each XMLHttpRequest, in ... and the Console tab"
>     - http://getfirebug.com/network
> 
> I agree that this isn't the best way to debug network traffic but its
> something that developers are used to and may speed up debugging of some
> situations (turn on, perform action, turn off, debug the XHRs in that short
> time period). If it can easily be turned on / off it would be good for those
> developers that would rather have this then use the Network tab.
> 
> I think Nikita had a prototype in the past using just a Safari extension.
> 
> That said, if we did this I think we'd want to improve our Console filtering
> in general otherwise it would get out of Control. Firefox has done a really
> great job here, and I like what they've done with their filtering.

Okay, wouldn't it fit in better with our feature set to make XHR breakpoints do the logging via actions? Is it possible for us to evaluate arbitrary JS (conditions, log expressions, etc) when paused at non-script breakpoints? At the least, we could add a "log to console" action.
Comment 6 Matt Baker 2017-04-11 09:29:21 PDT
(In reply to Brian Burg from comment #5)
> (In reply to Joseph Pecoraro from comment #3)
> > This is a common thing in other tools:
> > 
> >   • Chrome
> >     - Right click in the Console to see Context Menu
> > 
> >   • Firefox
> >     - Console > Filter output > XHR
> > 
> >   • Firebug
> >     - "Firebug shows you each XMLHttpRequest, in ... and the Console tab"
> >     - http://getfirebug.com/network
> > 
> > I agree that this isn't the best way to debug network traffic but its
> > something that developers are used to and may speed up debugging of some
> > situations (turn on, perform action, turn off, debug the XHRs in that short
> > time period). If it can easily be turned on / off it would be good for those
> > developers that would rather have this then use the Network tab.
> > 
> > I think Nikita had a prototype in the past using just a Safari extension.
> > 
> > That said, if we did this I think we'd want to improve our Console filtering
> > in general otherwise it would get out of Control. Firefox has done a really
> > great job here, and I like what they've done with their filtering.
> 
> Okay, wouldn't it fit in better with our feature set to make XHR breakpoints
> do the logging via actions? Is it possible for us to evaluate arbitrary JS
> (conditions, log expressions, etc) when paused at non-script breakpoints? At
> the least, we could add a "log to console" action.

Currently no breakpoint options/actions are available to XHR breakpoints, but we're already looking at adding some:

Web Inspector: Add regular expression support to XHR breakpoints	
https://bugs.webkit.org/show_bug.cgi?id=170099

The script location where the debugger will pause for an XHR breakpoint isn't known ahead of time (the same is true of DOM breakpoints) but this doesn't preclude us from adding Evaluate Script and Log Message actions for both breakpoint types.
Comment 7 Brian Burg 2017-04-11 09:40:28 PDT
Ok, let's retitle this bug to deal with breakpoint actions that provide equivalent functionality.
Comment 8 Brian Burg 2017-04-11 09:42:23 PDT
<rdar://problem/31558086>
Comment 9 Joseph Pecoraro 2017-04-12 10:45:40 PDT
I'm not sure I would think to use the Breakpoints sidebar.

Currently the XHR Breakpoints pause on XHR.send (and don't work yet with fetch). Yet what is interesting and useful here is to log the result of the async request.

I suppose there could be a breakpoint action that follows the XHR and logs its eventual results. Or maybe a way to change the conditions of the breakpoint to happen when the request completes (success/error) instead of or alongside the existing pause point before the load starts.