Damn Vegetables
Damn Vegetables

Reputation: 12474

How to set breakpoint on window close or prevent the Developer Tools window from closing?

I opened the Developer Tools on a separate window for FireFox's pop-up window. The problem is that that pop-up window automatically closes by JavaScript after form submission and I cannot disable JavaScript itself because it needs JavaScript to submit the form.

I searched for a way to disable automatic closing of the Developer Tools on window closing, and I found this but it was for Chrome. Typing window.addEventListener('unload', function() { debugger; }) on the Console did not work. I could not find Developer tools -> "Sources" tab -> Event Listener Breakpoints -> Window -> close or Event Listener Breakpoints -> Load -> unload. The Event Listener Breakpoints panel has neither close nor unload (I typed them in the "Filter by event type").

How can I prevent Developer Tools's separate window from closing?

Upvotes: 5

Views: 4308

Answers (3)

mvreijn
mvreijn

Reputation: 2942

I searched around a lot for this issue. Many tips do not work. A solution that did work was presented here.

This involves using about:config to set the following values:

browser.link.open_newwindow                      1
browser.link.open_newwindow.restriction          0
browser.link.open_newwindow.override.external    3

After this, the popup will open in the same window. Then, the script cannot close the window since it is not the creator.

Upvotes: 2

almereyda
almereyda

Reputation: 146

Adding the Event Listener

  • Load
    • load

in the Debugger allowed me to keep an OAuth popup open before close.

Upvotes: 1

Sebastian Zartner
Sebastian Zartner

Reputation: 20125

The unload and beforeunload events obviously got removed from the list of event listener breakpoints in Firefox 69 due to causing bugs within the Debugger panel. See https://bugzil.la/1569775 for more info.

So it seems there is currently (as of Firefox 72) no way to halt the script execution on those events and you have to wait until the aforementioned bug is fixed.

Upvotes: 2

Related Questions