Search code examples
javascriptgoogle-chromegoogle-chrome-devtoolsinline-code

Chrome debugger skips inline JavaScript code on first click


When using the Mouse click option under the sources of the Event Listener Breakpoints option on the right, the debugger skips the following function code:

<html>
    <head>
        <script type="text/javascript">
            function test()
            {
                return true;
            }
        </script>
    </head>
    <body>
        <input type="button" onclick="return test();" value="test">
    </body>
</html>

The problem is not that it doesn't run. It's that I can't debug it until I push the input button twice to be able to step into (F11) the function.

Otherwise I'm not able to debug what's inside the code. It's pretty frustrating because it happens every time I refresh the page. Is this a bug or is it meant to be like this?

I'm on: Chrome Ubuntu Version 40.0.2214.93 (64-bit)

P.S. For those that asked/will ask,

I'm working on maintaining a legacy application and unfortunately, it has many inline functions. There's no point in taking the time of putting all these into files when my company is building new software to replace it. Since resources are spent building out the new code, I'll have to do minor debugging of the legacy application this way.


Solution

  • Works for me, though I am using v38. As a workaround try adding the debugger statement into the handler (while you are debugging)

    function test(){
        debbugger;
        return true;
    }