Open Bug 868378 Opened 11 years ago Updated 2 years ago

Break on page load

Categories

(DevTools :: Debugger, enhancement, P3)

enhancement

Tracking

(Not tracked)

People

(Reporter: msucan, Unassigned)

References

(Blocks 1 open bug)

Details

A web developer told me she is having a really hard time debugging why some JavaScript library she was working with loads the wrong page on button click. She couldn't debug the scripts because the codebase was new to her and she couldn't find which function triggers the wrong load - apparently the event handler she added wasn't event triggered. She later learned that the page had an unrelated event handler which broke things.

Similar use-cases would be easier to debug if we had an option to break JS execution when a page load is requested. Like break on event or break on exception, you would see why a page load has been triggered.
Implementing this will be tricky without support for watchpoints, since intercepting the load using an event would present the stack in a new turn of the event loop, with the original call missing.
if we could inject our on onload handler we might be able to fake this.

Would be super-useful to have.
Priority: -- → P3
Exposing this in the frontend could be as easy as adding a "Pause on navigation" in the debugger's gear menu.

There are many stages in a navigation though. We could break when the currently debugged page unloads. Or the next page loads. Or before it loads. Or...

I think the most useful use-case that we should support is pausing on what we call "will-navigate", so basically when the current target starts reloading/ navigating away.
How about adding it in the debugger's events tab.
The events tab lists handlers present in the page, so copying the break-on-error UI seems better in this case. I'm still not sure if pausing in the progress listener will have content frames in the stack, which is what both comment 0 and bug 977261 actually need.
Any news about this?
Summary: Add an option to break on page load → Break on page load
Product: Firefox → DevTools
Type: defect → enhancement
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.