5 ms·
>>setTimeout(function() { debugger; }, 5000); This is clever; after all, the only way to beat the recursive turtle stack of chrome debuggers debugging themselv
by Jerrrry 3y ago
>>setTimeout(function() { debugger; }, 5000);
This is clever; after all, the only way to beat the recursive turtle stack of chrome debuggers debugging themselves is with the debugger statement.
sam.pl, of the infamous myspace Sammy worm, used debugging gotcha's to prevent visitors from de-mystifying his obfuscated html homepage.
- retox 3y agoBrowser makers: please ignore 'debugger' statements by default with an opt-in in the dev tools. Almost all legitimate uses of the debugger statement can be replaced with a simple breakpoint if you're working on the code.
- zubairq 3y agoNice, I never knew this trick existed
- cookiengineer 3y agoThis is what happens when websites prevent an open Console/DevTools side panel. They basically have a main loop running, inserting a debugger; statement in various places where they're annoying, and they do that at 30FPS / 32ms so that the DevTools become useless because there's no way to "ignore" debugger statements.
- lexicality 3y agoWhy would this be a problem? I have a debugger. If you conveniently invoke it for me I can simply delete the offending code. Also both Chrome and Firefox have a "disable breakpoints" button that would instantly defeat this issue.
- themoonisachees 3y agoThis button was added to specifically combat that, and even then it means you can't use breakpoints at all. IMO the missing link is a way to specifically ignore a single debugger call.
- lexicality 3y agoThe debugger lets you edit the code in the VM, so if there's a debugger call you don't want you can simply delete it and continue and it'll not show up again until you refresh
- gear54rus 3y agoTFA has instructions on adding conditional breakpoint with 'false' inside. Wouldn't this work?
- sroussey 3y agoYes, this will work. Sometimes you do it to yourself and you want to ignore the line.
- deleted 3y ago[deleted]
- deleted 3y ago[deleted]
- 3abiton 3y agoWait, that's it? This is too simple to be so good.
- darekkay 3y agoThat's one of my most used bookmarklets: https://darekkay.com/blog/debugging-dynamic-content/ https://darekkay.com/blog/debugging-dynamic-content/
- lelandfe 3y agoWoah, “Emulate a focused page” is a great tip, too.
- awalGarg 3y agoYou can just hit F8 and the debugger will pause at the next instruction. Works in both Chrome/FF.
- DustinBrett 3y agoNeither the bookmarklet or F8 is ideal if you want to retain focus and any other state that you may effect by going and clicking or pressing a key.
- lelandfe 3y agoF8 first causes focus to be lost from the document body. Just tested in Chrome.
- johnfn 3y agoAnother way to do this, if you don't want to wait 5 seconds, is just to use the "pause script execution" shortcut, which is cmd-\. It'll freeze the page on whatever line of JS was currently executing, and then you can inspect the problematic element like normal.