How can I exclude setTimeout or setInterval statements when debugging with "Break on Next"?

I am currently working with a large existing code base that can work with one or more setInterval timers, starting with various plug-ins or libraries. This basically makes it impossible to use Break on Next to debug what happens when I click on an element.

Problem . As soon as I click Break on Next, the browser debugger (with Firebug and Chrome) stops in one of the setInterval functions before I get the opportunity to interact with the page to actually debug the event that I want.

Specific problem . I have checkboxes that are not checked when unchecked, no matter how many times I click on them. I also deleted the identifiers and class names, but to no avail, and they did not have event handlers.

Note: do not use jQuery

+6
source share
1 answer

This can slow down other things, but what if you try to defuse these calls as follows:

window.setInterval = function() { console.log("setInterval", arguments); }; window.setTimeout = function() { console.log("setTimeout", arguments); }; 

If you find that some timeouts / intervals are really necessary to reproduce your problem, you can try skipping them. What could be the code:

 window.oldSetTimeout = window.setTimeout; window.setTimeout = function() { if (arguments[0] == "code you want to allow") { oldSetTimeout.apply(null, arguments); } else { console.log("setTimeout", arguments); } }; 

Note. I would not be surprised that he decapitates setTimeout, the cross browser does not work, but it works on FF 18.0

+1
source

All Articles