Explicit breakpoint via Javascript Code

111 views
Skip to first unread message

Jacques Crocker

unread,
Mar 19, 2009, 8:17:06 PM3/19/09
to Firebug
Hi. I'd really like a way to fire off a breakpoint in my javascript
code itself. Is there a way to do this?

For example:
function someFunction(){
console.break();
// do something
}

So whenever firebug sees "console.break()", it can just fire off a
breakpoint immediately and launch the script debugger (provided
firebug is enabled).

In response to the inevitable "why would you want this?" question, it
turns out to be extremely useful in ruby land (using ruby-debug) to
just write "debugger" in your code whenever you need to fire off a
breakpoint. It also lets you easily write if checks on that breakpoint
using standard javascript, and not have to use the IDE to define crazy
rulesets for when/if breakpoints get executed.

All in all, its easier to add/remove breakpoint in textmate than it is
in firebug so it seems like it'd be really useful. Let me know if its
already possible, or if I should help implement this functionality in
the Firebug SVN

Thanks

johnjbarton

unread,
Mar 19, 2009, 8:38:25 PM3/19/09
to Firebug
just write "debugger;" in your code. ;-)
jjb

Jacques Crocker

unread,
Mar 19, 2009, 8:41:11 PM3/19/09
to Firebug
Thanks for the quick response

I tried adding "debugger;" to the place I need the breakpoint. It
doesn't catch in the debugger.

Does it work for you?

Jacques Crocker

unread,
Mar 19, 2009, 8:47:42 PM3/19/09
to Firebug
Ah, got it. Pretty finnicky though. If I try it 3 or 4 times, it'll
work maybe once. I'll try to see whats up with that, probably some
caching issues.

Thanks for the heads up
Reply all
Reply to author
Forward
0 new messages