Skip to content

Breakpoints set in HTML script blocks not in a function will never be hit on page refresh #884

@EricCornelson

Description

@EricCornelson

Describe the bug
It is not possible to hit breakpoints in HTML script blocks on code that executes on page load (e.g. code not in a function that will be triggered later by user action)

To Reproduce

repro html:

<html>
    <body>
        <script>
            console.log('log outside a function');
            function clickme() {
                console.log('log inside a function');
            };
        </script>
        <button onclick="clickme()">Click Me</button>
    </body>
</html>

repro launch.json

{
    "configurations": [
        {
            "name": "Launch Chrome",
            "request": "launch",
            "type": "pwa-chrome",
            "url": "http://localhost:5000",
            "webRoot": "${workspaceFolder}",
            "trace": {
                "logFile": "C:/dev/repros/basic/log.txt"
            }
        }
    ]
}

Steps:

  1. Launch the debug session with no breakpoints set
  2. Set a breakpoint on line 4 of the repro HTML above console.log('log outside a function') (the breakpoint should bind)
  3. refresh the page
  4. See that the breakpoint becomes unbound, and is not hit

Repro2_12-9-2020

Log File
log.txt

VS Code Version:
Version: 1.52.0-insider (user setup)
Commit: ac165d7f974d70212be80cb15eaecfc1fd20b21a
Date: 2020-11-30T17:36:25.607Z
Electron: 11.0.2
Chrome: 87.0.4280.63
Node.js: 12.18.3
V8: 8.7.220.24-electron.0
OS: Windows_NT x64 10.0.19042

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions