diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/compiler-script-mapping.html b/third_party/WebKit/LayoutTests/http/tests/devtools/compiler-script-mapping.html index cc5cf977c7b327..8fe8efc701db5a 100644 --- a/third_party/WebKit/LayoutTests/http/tests/devtools/compiler-script-mapping.html +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/compiler-script-mapping.html @@ -59,11 +59,11 @@ SourcesTestRunner.checkUILocation(originalUISourceCode, 1, 200, uiLocation(script, 1, 200)); SourcesTestRunner.checkRawLocation( - script, 0, 42, Bindings.debuggerWorkspaceBinding.uiLocationToRawLocation(uiSourceCode1, 3, 10)); + script, 0, 48, Bindings.debuggerWorkspaceBinding.uiLocationToRawLocation(uiSourceCode1, 3, 10)); SourcesTestRunner.checkRawLocation( script, 1, 85, Bindings.debuggerWorkspaceBinding.uiLocationToRawLocation(uiSourceCode2, 1, 0)); SourcesTestRunner.checkRawLocation( - script, 1, 110, Bindings.debuggerWorkspaceBinding.uiLocationToRawLocation(uiSourceCode2, 5, 2)); + script, 1, 140, Bindings.debuggerWorkspaceBinding.uiLocationToRawLocation(uiSourceCode2, 5, 2)); TestRunner.addResult('Location checks passed. Requesting content'); uiSourceCode1.requestContent().then(didRequestContent1); diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/sources/debugger-breakpoints/inline-breakpoint-with-sourcemap-expected.txt b/third_party/WebKit/LayoutTests/http/tests/devtools/sources/debugger-breakpoints/inline-breakpoint-with-sourcemap-expected.txt new file mode 100644 index 00000000000000..f8815c7f12ca73 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/sources/debugger-breakpoints/inline-breakpoint-with-sourcemap-expected.txt @@ -0,0 +1,28 @@ +Checks inline breakpoint in file with sourcemap +Setting breakpoint at second line.. +breakpoint at 2 + inline breakpoint at (2, 4) + inline breakpoint at (2, 26) disabled + inline breakpoint at (2, 41) disabled + inline breakpoint at (2, 56) disabled + inline breakpoint at (2, 71) disabled + inline breakpoint at (2, 84) disabled + inline breakpoint at (2, 85) disabled +Disabling first breakpoint and enable forth breakpoint at line.. +breakpoint at 2 + inline breakpoint at (2, 4) disabled + inline breakpoint at (2, 26) disabled + inline breakpoint at (2, 41) disabled + inline breakpoint at (2, 56) + inline breakpoint at (2, 71) disabled + inline breakpoint at (2, 84) disabled + inline breakpoint at (2, 85) disabled +Calling function foo.. +Script execution paused. +Paused at: (2, 56) +Call stack: + 0) (arrow.ts:3) + 1) foo (arrow.ts:5) + 2) (:1) +Script execution resumed. + diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/sources/debugger-breakpoints/inline-breakpoint-with-sourcemap.js b/third_party/WebKit/LayoutTests/http/tests/devtools/sources/debugger-breakpoints/inline-breakpoint-with-sourcemap.js new file mode 100644 index 00000000000000..0bec9578fd8a89 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/sources/debugger-breakpoints/inline-breakpoint-with-sourcemap.js @@ -0,0 +1,46 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function test() { + TestRunner.addResult('Checks inline breakpoint in file with sourcemap'); + await TestRunner.loadModule('sources_test_runner'); + await TestRunner.showPanel('sources'); + + await SourcesTestRunner.startDebuggerTestPromise(); + /* arrow.ts, js generated with tsc arrow.ts --inlineSourceMap --inlineSources +function foo() { + function create() { + return (a: number) => (b: number) => (c: number) => (d: number) => a + b + c + d; + } + create()(1)(2)(3); +} + */ + await TestRunner.evaluateInPageAnonymously(`function foo() { + function create() { + return function (a) { return function (b) { return function (c) { return function (d) { return a + b + c + d; }; }; }; }; + } + create()(1)(2)(3); +} +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXJyb3cuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJhcnJvdy50cyJdLCJuYW1lcyI6WyJmb28iLCJmb28uY3JlYXRlIl0sIm1hcHBpbmdzIjoiQUFBQTtJQUNFQTtRQUNFQyxNQUFNQSxDQUFDQSxVQUFDQSxDQUFTQSxJQUFLQSxPQUFBQSxVQUFDQSxDQUFTQSxJQUFLQSxPQUFBQSxVQUFDQSxDQUFTQSxJQUFLQSxPQUFBQSxVQUFDQSxDQUFTQSxJQUFLQSxPQUFBQSxDQUFDQSxHQUFHQSxDQUFDQSxHQUFHQSxDQUFDQSxHQUFHQSxDQUFDQSxFQUFiQSxDQUFhQSxFQUE1QkEsQ0FBNEJBLEVBQTNDQSxDQUEyQ0EsRUFBMURBLENBQTBEQSxDQUFDQTtJQUNuRkEsQ0FBQ0E7SUFDREQsTUFBTUEsRUFBRUEsQ0FBQ0EsQ0FBQ0EsQ0FBQ0EsQ0FBQ0EsQ0FBQ0EsQ0FBQ0EsQ0FBQ0EsQ0FBQ0EsQ0FBQ0EsQ0FBQ0E7QUFDcEJBLENBQUNBIiwic291cmNlc0NvbnRlbnQiOlsiZnVuY3Rpb24gZm9vKCkge1xuICBmdW5jdGlvbiBjcmVhdGUoKSB7XG4gICAgcmV0dXJuIChhOiBudW1iZXIpID0+IChiOiBudW1iZXIpID0+IChjOiBudW1iZXIpID0+IChkOiBudW1iZXIpID0+IGEgKyBiICsgYyArIGQ7XG4gIH1cbiAgY3JlYXRlKCkoMSkoMikoMyk7XG59XG4iXX0=`); + + let sourceFrame = await new Promise(resolve => SourcesTestRunner.showScriptSource('arrow.ts', resolve)); + TestRunner.addResult('Setting breakpoint at second line..'); + SourcesTestRunner.toggleBreakpoint(sourceFrame, 2, false); + await SourcesTestRunner.waitJavaScriptSourceFrameBreakpoints(sourceFrame); + await SourcesTestRunner.dumpJavaScriptSourceFrameBreakpoints(sourceFrame); + + TestRunner.addResult('Disabling first breakpoint and enable forth breakpoint at line..'); + SourcesTestRunner.clickJavaScriptSourceFrameBreakpoint(sourceFrame, 2, 0); + SourcesTestRunner.clickJavaScriptSourceFrameBreakpoint(sourceFrame, 2, 3); + await SourcesTestRunner.waitJavaScriptSourceFrameBreakpoints(sourceFrame); + await SourcesTestRunner.dumpJavaScriptSourceFrameBreakpoints(sourceFrame); + + TestRunner.addResult('Calling function foo..'); + TestRunner.evaluateInPageAnonymously('foo()'); + let callFrames = await SourcesTestRunner.waitUntilPausedPromise(); + let pausedLocation = Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(callFrames[0].location()); + TestRunner.addResult(`Paused at: (${pausedLocation.lineNumber}, ${pausedLocation.columnNumber})`); + SourcesTestRunner.captureStackTrace(callFrames); + SourcesTestRunner.completeDebuggerTest(); +})(); \ No newline at end of file diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/text-source-map.html b/third_party/WebKit/LayoutTests/http/tests/devtools/text-source-map.html index 037956b5b4d336..9330a02d1954fb 100644 --- a/third_party/WebKit/LayoutTests/http/tests/devtools/text-source-map.html +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/text-source-map.html @@ -15,7 +15,7 @@ } function checkReverseMapping(compiledLineNumber, compiledColumnNumber, sourceURL, sourceLineNumber, mapping) { - var entry = mapping.firstSourceLineMapping(sourceURL, sourceLineNumber); + var entry = mapping.sourceLineMapping(sourceURL, sourceLineNumber, 0); if (!entry) { TestRunner.addResult('source line ' + sourceLineNumber + ' has no mappings.'); return; diff --git a/third_party/WebKit/Source/devtools/front_end/bindings/CompilerScriptMapping.js b/third_party/WebKit/Source/devtools/front_end/bindings/CompilerScriptMapping.js index 612ab4a4ace435..7fe0eec35d43db 100644 --- a/third_party/WebKit/Source/devtools/front_end/bindings/CompilerScriptMapping.js +++ b/third_party/WebKit/Source/devtools/front_end/bindings/CompilerScriptMapping.js @@ -168,7 +168,7 @@ Bindings.CompilerScriptMapping = class { var script = scripts.length ? scripts[0] : null; if (!script) return null; - var entry = sourceMap.firstSourceLineMapping(uiSourceCode.url(), lineNumber); + var entry = sourceMap.sourceLineMapping(uiSourceCode.url(), lineNumber, columnNumber); if (!entry) return null; return this._debuggerModel.createRawLocation(script, entry.lineNumber, entry.columnNumber); @@ -290,7 +290,7 @@ Bindings.CompilerScriptMapping = class { var sourceMap = uiSourceCode[Bindings.CompilerScriptMapping._sourceMapSymbol]; if (!sourceMap) return true; - return !!sourceMap.firstSourceLineMapping(uiSourceCode.url(), lineNumber); + return !!sourceMap.sourceLineMapping(uiSourceCode.url(), lineNumber, 0); } dispose() { diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/SourceMap.js b/third_party/WebKit/Source/devtools/front_end/sdk/SourceMap.js index becf68d57cbd89..bc0a591e80aa79 100644 --- a/third_party/WebKit/Source/devtools/front_end/sdk/SourceMap.js +++ b/third_party/WebKit/Source/devtools/front_end/sdk/SourceMap.js @@ -330,14 +330,21 @@ SDK.TextSourceMap = class { /** * @param {string} sourceURL * @param {number} lineNumber + * @param {number} columnNumber * @return {?SDK.SourceMapEntry} */ - firstSourceLineMapping(sourceURL, lineNumber) { + sourceLineMapping(sourceURL, lineNumber, columnNumber) { var mappings = this._reversedMappings(sourceURL); - var index = mappings.lowerBound(lineNumber, lineComparator); - if (index >= mappings.length || mappings[index].sourceLineNumber !== lineNumber) + var first = mappings.lowerBound(lineNumber, lineComparator); + var last = mappings.upperBound(lineNumber, lineComparator); + if (first >= mappings.length || mappings[first].sourceLineNumber !== lineNumber) + return null; + var columnMappings = mappings.slice(first, last); + var index = + columnMappings.lowerBound(columnNumber, (columnNumber, mapping) => columnNumber - mapping.sourceColumnNumber); + if (index >= columnMappings.length) return null; - return mappings[index]; + return columnMappings[index]; /** * @param {number} lineNumber