javascriptsafaridojodebuggingweb-inspector

How does one get Safari's debugger to persist a breakpoint across a page refresh?


How does one get Safari's debugger to persist a breakpoint across a page refresh?

I'm trying to debug code that's executed onLoad, so I don't have time to set the breakpoint before the code is executed, and when I refresh the page after setting the breakpoint, the breakpoint is lost.

(The code in question is in a Dojo widget, so it's loaded via an XHR, if that matters.)


Solution

  • There is a javascript statement which might be of use to you called debugger. While this function is poorly documented, it usually triggers your browser's built-in debugger. The only note I've really found on the statement is this.

    Javascript as a language spec does not have a debug statement, however all implementations do implement a debugger statement.

    Although, I am not sure why your breakpoints are not persisting. I do not have Safari available to test, but Chrome (which is also based on Webkit) does seem to be persisting breakpoints correctly.

    EDIT

    I managed to find documentation for the debugger statement, but it is not very descriptive:

    Invokes any available debugging functionality. If no debugging functionality is available, this statement has no effect.