Skip to content

Commit

Permalink
[DevTools] take into account column in uiLocationToRawLocation with s…
Browse files Browse the repository at this point in the history
…ourceMap

.. otherwise inline breakpoints are just broken for files with source map.

R=lushnikov@chromium.org

Bug: chromium:760229
Change-Id: I2658258ac6f4b6f255583bdea16ede4ad99940f3
Reviewed-on: https://chromium-review.googlesource.com/716660
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: Andrey Lushnikov <lushnikov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#508443}
  • Loading branch information
alexkozy authored and Commit Bot committed Oct 12, 2017
1 parent 48493dc commit 05e936f
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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.

Original file line number Diff line number Diff line change
@@ -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();
})();
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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() {
Expand Down
15 changes: 11 additions & 4 deletions third_party/WebKit/Source/devtools/front_end/sdk/SourceMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 05e936f

Please sign in to comment.