Firefox - Disable 'debugger' keywords
Asked Answered
M

6

39

How do I tell Firefox not to stop if it sees a debugger keyword?

I need to avoid a continuous debugger loop in case the website uses debugging protection generating debugger statements on the fly using timers.

Here is an example. In case you open the debugging console the script will throw tons of debugger statements, which will block you from normal debugging work.

An example website is http://www.avito.ru - the biggest classified site in Russia. Open it and then open the debugger console and it will be immediately stop at the debugger keyword in generated script.

(function(x/**/) {
    (function(f){
        (function a(){
            try {
                function b(i) {
                    if(
                        (''+(i/i)).length !== 1 ||
                        i % 20 === 0
                    ) {
                        (function(){}).constructor('debugger')();
                    } else {
                        debugger;
                    }

                    b(++i);
                }

                b(0);
            } catch(e) {
                f.setTimeout(a, x)
            }
        })()
    })(document.body.appendChild(document.createElement('frame')).contentWindow);
});
Minutia answered 29/9, 2016 at 9:27 Comment(5)
As you didn't mention which tool you're using, I've added the 'firebug' and 'firefox-developer-tools' flags.Tanberg
For reference, the same question was asked in the Firebug discussion group, providing the website www.avito.ru as example.Tanberg
Sebastian, that was me seeking for help in there as well :)Minutia
I thought so :-), though in your question here you didn't include the website as example, so I thought I'll mention it in a comment. You may still adjust your question to include the link.Tanberg
Anybody who implements debugger protections like these believes in "security through obscurity" and seriously deserved to be checked out for vulnerabilities.Giacinta
B
30

As of Firefox 121, there are several choices for setting when the debugger stops.

In the Developer Tools, the Debugger section, there's an icon with the tooltip "Deactivate breakpoints". When enabled it disables stopping at any condition.

For fine-tuning, or to just prevent stopping at the debugger statement, leave the "Deactivate breakpoints" icon disabled (crossed), and then disable the relevant choice under the options for "Breakpoints" (because it's enabled by default).

Deactivae Breakpoints (as of FireFox 71.0b9)

Debugger breakpoint choices (as of Firefox 121)

Bobseine answered 25/11, 2018 at 4:10 Comment(6)
This is why modern interfaces suck. In the old days, that would have been a menu item in a "Debug" top level menu.Clinometer
This did not work for me, debugger still halts on debugger.Reagan
the icon is different but this worked the same in chromium Edge. thanks ;)Thundering
In my case Chrome is working while Firefox still freezing inspector.Balmuth
Whoever designed it into the JS to be able to detect whether the user has Dev Tools open is heinously evil.Xantho
Do this: New tab -> Deactivate breakpoints -> open page on tabXantho
T
4

Obviously the page tries to avoid people from debugging their JavaScript code with that construct.

Debugging in Firebug

Firebug allows to set disabled breakpoints on the debugger statements. Because the page generates a variable call stack depth, you'll need to set those disabled breakpoints for all of them to be able to debug the JavaScript properly. Unfortunately, Firebug seems to be buggy when it comes to set those breakpoints.

Furthermore, Firebug doesn't have an option to ignore all debugger statements.

So, if you don't need to debug JavaScript but only HTML, CSS, network requests, etc., you can simply disable the Script panel to avoid these annoying debugger halts. To do so, right-click the Script tab and click on Enable within the opening menu.

Disable Firebug's *Script* panel

Note: Because Firebug development is discontinued, it's useless to file an enhancement request for it.

Debugging in Firefox DevTools

Unfortunately, the Firefox DevTools currently don't allow to avoid halting on debugger statements. So you have to wait until bug 1300934 (which mentions the same website as an example), bug 925269 and/or issue 828 are fixed.

Furthermore there is no way to disable the Debugger panel completely, which is filed as bug 1247198.

Tanberg answered 30/9, 2016 at 5:48 Comment(7)
Firebug is, of course, open source (as is Firefox). So it may be possible to modify it to add the desired feature and send a pull request.Mansoor
Correct, though as noted, Firebug is discontinued and stops working once multi-process Firefox is enabled. Also the Firefox DevTools are open source, so it might be better to provide a patch for them instead.Tanberg
Sorry, I meant "modify either of them" rather than specifically Firebug.Mansoor
So basically there is only one option - try to implement this feature for firefox dev tools and get it approved ...Minutia
Correct. As the main work on the debugger seems to be on GitHub now, issue 828 seems the right place to do that.Tanberg
> there is no way to disable the Debugger panel completely Wouldn't devtools.debugger.enabled=false do the trick in about:config?Lashondra
This preference suggests that you can disable the Debugger, though from my tests it doesn't have any effect. The Debugger panel is still there and works the same with this preference enabled or disabled. And this observation is confirmed by looking at the code, which shows that the preference is never read within the debugger code.Tanberg
E
3

if you use Greasemonkey you can rewrite setTimeout/setInterval function to disable the script

unsafeWindow.setTimeout = function () {};
Elda answered 25/4, 2017 at 17:5 Comment(1)
This, of course, will prevent all timeout timers in the page window scope from workingMuseology
G
3

Chrome

in chrome you can edit the breakpoint and put a condition that is always false, it won't hit the debugger anymore

enter image description here

another option is to use "never pause here"

enter image description here

Firefox

for firefox, you can blackbox the script that you don't want to be hit by the breakpoint. for me it causes to hang the firefox. but when you restart the browser. then it's okay, enter image description here

Gooey answered 15/3, 2020 at 15:47 Comment(0)
A
1

I follow the instructions in this blog and create a workflow in GitHub Actions to automatically build Firefox browsers that evades JavaScript anti-debugging debugger mechanisms.

It works like this: demo

Anvil answered 27/4, 2023 at 8:34 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Buber
S
0

If you want to stop debugging without losing your breakpoints, then you need to disable breakpoints, not only to deactivate. Click right above the list of breakpoints and select Disable breakpoints. Then even if you refresh the page all breakpoints remain disabled. Tested with Firefox 101.0.1 on Ubuntu.

enter image description here

Sharyl answered 3/7, 2022 at 7:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.