Stop debugger on a breakpoint in code outside of function

56 views
Skip to first unread message

Новак Бошков

unread,
Jun 6, 2014, 7:13:08 PM6/6/14
to fir...@googlegroups.com
Today is my first day using Firebug and I'm noticed that I can't stop debugger on a line outside of function.
There is following code:
                var oneClassContener = $(".oneClass");
               
[breakpoint]for (var i=0; i<oneClassContener.length; i++){
                   
if (oneClassContener[i].tagName === "IMG"){
                        document
.write('<img src="' + oneClassContener[i].src.split("/")[oneClassContener[i].src.split("/").length - 1] + '"></img>' + "<br />");
                   
} else {
                        document
.write(oneClassContener[i].innerHTML);  
                   
}
               
}

And debugger just passes by the breakpoint. Code works but i want to stop execution on this line.
If I surround the code from above with a anonymous function and make a call after that, then debugger works like I expect and stops on specified line.
Like this:
                var foo = function(){
                var
oneClassContener = $(".oneClass");
               
[breakpoint]for (var i=0; i<oneClassContener.length; i++){
                   
if (oneClassContener[i].tagName === "IMG"){
                        document
.write('<img src="' + oneClassContener[i].src.split("/")[oneClassContener[i].src.split("/").length - 1] + '"></img>' + "<br />");
                   
} else {
                        document
.write(oneClassContener[i].innerHTML);  
                   
}
                }
                foo();
               
}
Have I missed some settings or is it a bug?
If there is reasonable reason for this, what is it?
Thank you.

Sebastian Zartner

unread,
Jun 6, 2014, 10:15:05 PM6/6/14
to fir...@googlegroups.com
If your code is on the global scope, i.e. not within a function, you have to reload the page to let the script execution stop at the breakpoint.
If that doesn't work, please attach a complete test case, so the problem can be reproduced.

Sebastian

Lawrence San

unread,
Jun 7, 2014, 10:23:21 PM6/7/14
to fir...@googlegroups.com
In the past, I was never able to get a breakpoint to work outside a function no matter what I did. However, I just tried it again (using Mac FF 28 and FB 1.12.8) and it worked fine, and I didn't even have to reload the page. I have no idea what changed. Maybe it depends on what the code line is doing?

BTW... a little off-topic, but I just noticed something else. I can delete the breakpoint from the breakpoints side-panel, but if I right-click on the breakpoint indicator right in the FB code display, I can only disable it, not delete it. Seems like it would be nice to be able to delete it there too, without having to open the side-panel and hunt around for that breakpoint.

Lawrence San
Business Writing: Santhology.com
Cartoon Stories for Thoughtful People: Sanstudio.com




--
You received this message because you are subscribed to the Google Groups "Firebug" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebug+u...@googlegroups.com.
To post to this group, send email to fir...@googlegroups.com.
Visit this group at http://groups.google.com/group/firebug.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebug/b3560164-4332-46ad-8b83-89b5926176dc%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Stefan Krüger

unread,
Jun 8, 2014, 4:10:48 AM6/8/14
to fir...@googlegroups.com

i think there is a small bug in your second code example?!
var foo = function(){
   
var oneClassContener = $(".oneClass");
   
[breakpoint]for (var i=0; i<oneClassContener.length; i++){
       
if (oneClassContener[i].tagName === "IMG"){
            document
.write('<img src="' + oneClassContener[i].src.split("/")[oneClassContener[i].src.split("/").length - 1] + '"></img>' + "<br />");
       
} else {
            document
.write(oneClassContener[i].innerHTML);
       
}

   
} // end for loop
    foo
();
} // end anonymous function

so the foo(); should be outside of the function body?!

sunny greetings
stefan
Reply all
Reply to author
Forward
0 new messages