Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

[Breakpoint] Adds XHR breakpoints #5255

Closed
karlcow opened this issue Jan 31, 2018 · 7 comments
Closed

[Breakpoint] Adds XHR breakpoints #5255

karlcow opened this issue Jan 31, 2018 · 7 comments

Comments

@karlcow
Copy link

karlcow commented Jan 31, 2018

It is sometimes necessary to discover which functions called a specific XHR request.

  1. Have a UI for adding breakpoints.
  2. Propose to add breakpoints on XHR requests (all of them or including a specific string)
  3. When the code reaches the XHR request, jump to the code at the right place (probably formatted version of the code).
@SebastianZ
Copy link

For reference, the idea of breaking on XHRs was initially requested in Bugzilla as bug 821610.

For what it's worth, Firebug had this feature and it had UIs within its Net and Console panels to set them and a Breakpoints side panel within its debugger to list and remove them.

Sebastian

@jasonLaster jasonLaster changed the title [feature] Adds XHR breakpoints [Breakpoint] Adds XHR breakpoints Feb 15, 2018
@jasonLaster
Copy link
Contributor

I'm moving the issue to the icebox. We will re-prioritize the issues in the icebox at the beginning of the next release in 6 weeks.

@jasonLaster
Copy link
Contributor

jasonLaster commented Mar 19, 2018

Here are some notes:

@jlast What the Network panel needs is server side hook (and actor?) that can be used to create a new breakpoint using URL (and later other props like e.g. a keyword saying that the XHR breakpoint should break the execution only when the response body contains the keyword, etc.) Consequently we can play with the Net panel UI/UX... (edited)

From API perspective, it could be as simple as: createXhrBreakpoint(url); - Breaks the current JS execution when the current XHR URL contains given url value. Later, it could be nice if support for conditional breakpoint is added. e.g. count == 2 - breaks only if URL parameter count is presented and equal to 2 or, checking the post/response body for specific keyword

Here is detailed description of how it works in Firebug http://www.softwareishard.com/blog/firebug/firebug-15-xhr-breakpoints/

We need an observer that handles http-on-opening-request and lives in the same (child) process as the page. This event is fired synchronously during the HTTP channel's send/open method, and so the JS stack (if any) is preserved. I think we are already handling e.g. http-on-examine-response and so, it could be around the same place I guess.
@jlast ^
Btw. this event has been introduced specifically for XHR BP
So, if XHR BP conditions are evaluated to true, the execution should break in that handler.
The handler should iterate all existing XHR BPs and check if anyone should break the execution or not.
createXhrBreakpoint API (I mentioned before) should ensure that a new BP is in the list.

@AnshulMalik
Copy link
Contributor

AnshulMalik commented Sep 5, 2018

Here is the diff, I'll keep updating as I progress. It doesn't work atm.
https://gist.github.com/AnshulMalik/bd58a202781bca39c8a66a69e627e576

@jasonLaster
Copy link
Contributor

jasonLaster commented Sep 5, 2018

CC @janodvarko @jimblandy i think you'll enjoy @AnshulMalik thread actor patch above.

My take on it is that is great that you have a frame and a url. We should be able to use that to get a script and set a breakpoint at the first entry-point of that script... I'm not sure if we want to loop over all of the scripts, there should be a better function on frame to get the script. I'd grep for frame. or look in the FrameActor

@AnshulMalik
Copy link
Contributor

Can we get this one out of icebox?

@jasonLaster jasonLaster removed the icebox label Jan 3, 2019
@jasonLaster jasonLaster reopened this Jan 3, 2019
@AnshulMalik
Copy link
Contributor

Ohh I think we have covered the points from this bug, I have created another bug for enhancement. Sorry for the trouble.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants