diff --git a/src/inspector/v8-debugger-agent-impl.cc b/src/inspector/v8-debugger-agent-impl.cc index eb95125025..b58555c561 100644 --- a/src/inspector/v8-debugger-agent-impl.cc +++ b/src/inspector/v8-debugger-agent-impl.cc @@ -194,6 +194,14 @@ void adjustBreakpointLocation(const V8DebuggerScript& script, int* columnNumber) { if (*lineNumber < script.startLine() || *lineNumber > script.endLine()) return; + if (*lineNumber == script.startLine() && + *columnNumber < script.startColumn()) { + return; + } + if (*lineNumber == script.endLine() && script.endColumn() < *columnNumber) { + return; + } + if (hint.isEmpty()) return; intptr_t sourceOffset = script.offset(*lineNumber, *columnNumber); if (sourceOffset == V8DebuggerScript::kNoOffset) return; @@ -915,6 +923,13 @@ V8DebuggerAgentImpl::setBreakpointImpl(const String16& breakpointId, if (lineNumber < script->startLine() || script->endLine() < lineNumber) { return nullptr; } + if (lineNumber == script->startLine() && + columnNumber < script->startColumn()) { + return nullptr; + } + if (lineNumber == script->endLine() && script->endColumn() < columnNumber) { + return nullptr; + } v8::debug::BreakpointId debuggerBreakpointId; v8::debug::Location location(lineNumber, columnNumber); diff --git a/test/inspector/regress/regress-crbug-1183664-expected.txt b/test/inspector/regress/regress-crbug-1183664-expected.txt new file mode 100644 index 0000000000..8a0dac1132 --- /dev/null +++ b/test/inspector/regress/regress-crbug-1183664-expected.txt @@ -0,0 +1,19 @@ +Regression test for crbug.com/1183664 + +Running test: testMultipleScriptsInSameLineWithSameURL +Setting breakpoint in first script +[ + [0] : { + columnNumber : 1 + lineNumber : 0 + scriptId : + } +] +Setting breakpoint in second script +[ + [0] : { + columnNumber : 65 + lineNumber : 0 + scriptId : + } +] diff --git a/test/inspector/regress/regress-crbug-1183664.js b/test/inspector/regress/regress-crbug-1183664.js new file mode 100644 index 0000000000..558ff2b2aa --- /dev/null +++ b/test/inspector/regress/regress-crbug-1183664.js @@ -0,0 +1,39 @@ +// Copyright 2021 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +let {session, contextGroup, Protocol} = InspectorTest.start('Regression test for crbug.com/1183664'); + +const url = 'test://foo.js'; +const lineNumber = 0; + +const columnNumber1 = 1; +contextGroup.addScript(`console.log("FIRST")`, lineNumber, columnNumber1, url); +const columnNumber2 = 65; +contextGroup.addScript(`console.log("SECOND")`, lineNumber, columnNumber2, url); + +InspectorTest.runAsyncTestSuite([ + async function testMultipleScriptsInSameLineWithSameURL() { + await Protocol.Debugger.enable(); + InspectorTest.logMessage('Setting breakpoint in first script') + { + const {result: {breakpointId, locations}} = await Protocol.Debugger.setBreakpointByUrl({ + url, + lineNumber, + columnNumber: columnNumber1, + }); + InspectorTest.logMessage(locations); + await Protocol.Debugger.removeBreakpoint({breakpointId}); + } + InspectorTest.logMessage('Setting breakpoint in second script') + { + const {result: {breakpointId, locations}} = await Protocol.Debugger.setBreakpointByUrl({ + url, + lineNumber, + columnNumber: columnNumber2, + }); + InspectorTest.logMessage(locations); + await Protocol.Debugger.removeBreakpoint({breakpointId}); + } + } +]);