105

I'm trying to use the chrome developer tools to debug an issue I'm having with Twitter oauth.

When the oauth window appears, I open the developer tools to monitor the requests - but as soon as the oauth window closes the developer tools window is also closed. I'd like to be able to keep the developer tools window open so that I can inspect the requests made.

Is this possible?

AlistairH
  • 3,139
  • 2
  • 21
  • 19

4 Answers4

121

Not a perfect solution, but you can add breakpoints on the events Window.close and unload by turning on the checkboxes at:

Developer tools -> "Sources" tab -> Event Listener Breakpoints -> Window -> close

And

Event Listener Breakpoints -> Load -> unload

Try to mark both and see which one works best for you

jfhfhf839
  • 1,629
  • 1
  • 12
  • 13
  • 9
    Does someone know why this doesn't do the trick for me? The window still closes. – Rubinous Mar 19 '15 at 19:55
  • 3
    I think I am having the same issue. It I have developer window open for my app but the oauth process is popping a new window and thus my break points are not there. I see the developer window pop and close with the oauth window...sigh – tavor999 Feb 01 '19 at 15:56
  • This is amazing. The `Window -> close` checkbox does the trick for me. Note: this setting (sadly) doesn't persist across windows or sessions, so you have to go check the box in whatever window is going to close, before it closes. – drmercer Jun 10 '22 at 17:21
29

Another option is to manually add a breakpoint yourself. Open up your closes-too-quickly window, open up JS console, and:

window.addEventListener('unload', function() { debugger; })

But it all comes down to exactly what the window is doing, and when exactly you want to stop things, so experimenting with Event Listener Breakpoints in the Sources tab, as in @jfhfhf839's answer, is a good idea too.

In my case (debugging Google OAuth flow), neither Window -> Close nor Load -> Unload did the trick, but Script > Script First Statement was useful, though I had to resume execution a few times before I got to where I wanted.

tobek
  • 4,349
  • 3
  • 32
  • 41
5

Try using remote debugging: https://developers.google.com/chrome-developer-tools/docs/remote-debugging In this case Developer Tools will be opened in a separate browser tab that won't be closed automatically.

Also consider setting a breakpoint in the code that closes the window if you can find it.

vsevik
  • 9,559
  • 3
  • 19
  • 11
  • 2
    This might work for debugging Chrome on Android, but didn't work for me on my computer. I went to chrome://inspect/#pages, found the tab, hit inspect, but dev tools still closed when the window closed. – tobek Jul 18 '15 at 04:02
-1

Just press F8 before closing and pause, then add breakpoints.

Don Diego
  • 1,309
  • 3
  • 23
  • 46