107

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?

3
  • 2
    FYI, I just filed a bug against Chromium about this: crbug.com/171447.
    – Mu Mind
    Jan 22, 2013 at 18:00
  • As of December 15, 2017, crbug.com/171447 is fixed. Dec 15, 2017 at 14:31
  • 1
    @tom_mai78101 how do I activate it? Apr 24, 2019 at 20:55

4 Answers 4

123

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

3
  • 9
    Does someone know why this doesn't do the trick for me? The window still closes.
    – Rubinous
    Mar 19, 2015 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 1, 2019 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, 2022 at 17:21
30

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.

1
  • For IE, you can use: window.attachEvent("onunload", function() { debugger; })
    – Freddie
    Jun 6, 2017 at 20:57
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.

1
  • 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, 2015 at 4:02
0

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

1
  • The only one that worked with a Chrome-based browser popup authn window (while testing new connection in a custom connector for PowerAutomate). In a fast sequence, press Ctrl+Shift+I (to load Developer Tools) then F8 to break the execution. From there, try the other recommendations. Oct 25 at 15:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.