Commit aca480af authored by Simon Zünd's avatar Simon Zünd Committed by Commit Bot

Prepare http/tests/devtools/sources/* for async source mapping

Asynchronous source mapping makes {rawLocationToUILocation} asynchrounous.
This CL adds async/awaits to all affected test helpers and methods
in http/tests/devtools/sources/* web tests.

Note: The inline-breakpoint-with-source-map.js test is re-written using
a newer test utility that helps with flakiness.

Note 2: The live-edit-breakpoint.js web test is disabled for now, as it
requres a 3-way change. The new baseline is already committed with this
CL.

Bug: chromium:1032016
Change-Id: I77a98faff99c02c40df46b115a1da0f228282844
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2064214Reviewed-by: default avatarMathias Bynens <mathias@chromium.org>
Commit-Queue: Simon Zünd <szuend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743463}
parent 7d9b0111
......@@ -3236,6 +3236,7 @@ crbug.com/400829 virtual/audio-service/media/stable/video-object-fit-stable.html
# Source map asyncification requires some 3-way changes with the DevTools frontend.
crbug.com/1032016 http/tests/devtools/sources/debugger-breakpoints/breakpoints-ui-shifted-breakpoint.js [ Pass Failure Timeout ]
crbug.com/1032016 http/tests/devtools/sources/debugger/live-edit-breakpoints.js [ Pass Failure ]
# We only want to run one of the web-animations-api tests in stable mode.
crbug.com/441553 virtual/stable/web-animations-api/* [ Skip ]
......
......@@ -26,21 +26,21 @@ function foo() {
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.waitDebuggerPluginBreakpoints(sourceFrame);
await SourcesTestRunner.dumpDebuggerPluginBreakpoints(sourceFrame);
// We expect 7 breakpoint decorations on line 2.
await SourcesTestRunner.runActionAndWaitForExactBreakpointDecorations(sourceFrame, [[2, 7]], () =>
SourcesTestRunner.toggleBreakpoint(sourceFrame, 2, false));
TestRunner.addResult('Disabling first breakpoint and enable forth breakpoint at line..');
SourcesTestRunner.clickDebuggerPluginBreakpoint(sourceFrame, 2, 0);
SourcesTestRunner.clickDebuggerPluginBreakpoint(sourceFrame, 2, 3);
await SourcesTestRunner.waitDebuggerPluginBreakpoints(sourceFrame);
await SourcesTestRunner.dumpDebuggerPluginBreakpoints(sourceFrame);
await SourcesTestRunner.runActionAndWaitForExactBreakpointDecorations(sourceFrame, [[2, 7]], () => {
SourcesTestRunner.clickDebuggerPluginBreakpoint(sourceFrame, 2, 0);
SourcesTestRunner.clickDebuggerPluginBreakpoint(sourceFrame, 2, 3);
});
TestRunner.addResult('Calling function foo..');
TestRunner.evaluateInPageAnonymously('foo()');
let callFrames = await SourcesTestRunner.waitUntilPausedPromise();
let pausedLocation = Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(callFrames[0].location());
let pausedLocation = await Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(callFrames[0].location());
TestRunner.addResult(`Paused at: (${pausedLocation.lineNumber}, ${pausedLocation.columnNumber})`);
SourcesTestRunner.captureStackTrace(callFrames);
await SourcesTestRunner.captureStackTrace(callFrames);
SourcesTestRunner.completeDebuggerTest();
})();
\ No newline at end of file
......@@ -32,14 +32,14 @@
}
var callFrameIndex = 0;
function dumpNextCallFrame(next) {
async function dumpNextCallFrame(next) {
var callFrames = TestRunner.debuggerModel.callFrames;
if (callFrameIndex === callFrames.length) {
next();
return;
}
var frame = callFrames[callFrameIndex];
var uiLocation = Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(
var uiLocation = await Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(
frame.location());
SourcesTestRunner.showUISourceCode(
uiLocation.uiSourceCode, dumpCallFrameLine);
......
......@@ -31,9 +31,9 @@
TestRunner.evaluateInPage('setTimeout(testFunction, 0)');
}
function onSetExecutionLocation(liveLocation) {
async function onSetExecutionLocation(liveLocation) {
TestRunner.deprecatedRunAfterPendingDispatches(dumpAndContinue.bind(
null, this._textEditor, liveLocation.uiLocation().lineNumber));
null, this._textEditor, (await liveLocation.uiLocation()).lineNumber));
}
function dumpAndContinue(textEditor, lineNumber) {
......
......@@ -32,9 +32,9 @@
TestRunner.evaluateInPage('setTimeout(testFunction, 0)');
}
function onSetExecutionLocation(liveLocation) {
async function onSetExecutionLocation(liveLocation) {
TestRunner.deprecatedRunAfterPendingDispatches(dumpAndContinue.bind(
null, this._textEditor, liveLocation.uiLocation().lineNumber));
null, this._textEditor, (await liveLocation.uiLocation()).lineNumber));
}
function dumpAndContinue(textEditor, lineNumber) {
......
......@@ -43,13 +43,13 @@
TestRunner.evaluateInPageWithTimeout('f2()');
}
function pausedInF2(callFrames) {
async function pausedInF2(callFrames) {
SourcesTestRunner.dumpBreakpointSidebarPane('while paused in pretty printed');
SourcesTestRunner.waitBreakpointSidebarPane()
.then(() => SourcesTestRunner.dumpBreakpointSidebarPane('while paused in raw'))
.then(() => SourcesTestRunner.resumeExecution(next));
SourcesTestRunner.removeBreakpoint(formattedSourceFrame, 3);
Formatter.sourceFormatter.discardFormattedUISourceCode(panel.visibleView.uiSourceCode());
await Formatter.sourceFormatter.discardFormattedUISourceCode(panel.visibleView.uiSourceCode());
}
}
]);
......
......@@ -43,13 +43,13 @@
}
function pausedInF2(callFrames) {
async function pausedInF2(callFrames) {
SourcesTestRunner.dumpBreakpointSidebarPane('while paused in pretty printed');
SourcesTestRunner.waitBreakpointSidebarPane()
.then(() => SourcesTestRunner.dumpBreakpointSidebarPane('while paused in raw'))
.then(() => SourcesTestRunner.resumeExecution(next));
// No need to remove breakpoint since formattedUISourceCode was removed.
Formatter.sourceFormatter.discardFormattedUISourceCode(panel.visibleView.uiSourceCode());
await Formatter.sourceFormatter.discardFormattedUISourceCode(panel.visibleView.uiSourceCode());
}
}
]);
......
......@@ -38,9 +38,11 @@
TestRunner.evaluateInPage('addErrorToConsole()');
}
function didAddMessage(message) {
async function didAddMessage(message) {
if (this !== shownSourceFrame)
return;
// Messages can contain live locations.
await TestRunner.waitForPendingLiveLocationUpdates();
TestRunner.addResult('Message added to source frame: ' + message.text());
setImmediate(function() {
Console.ConsoleView.clearConsole();
......
......@@ -19,7 +19,7 @@
TestRunner.evaluateInPage('testFunction()');
TestRunner.networkManager.addEventListener(SDK.NetworkManager.Events.RequestFinished, requestFinished);
function requestFinished(event) {
async function requestFinished(event) {
if (!event.data.url().endsWith('resources/image.png'))
return;
......@@ -27,6 +27,8 @@
var element = new Components.Linkifier().linkifyScriptLocation(
TestRunner.mainTarget, initiatorInfo.scriptId, initiatorInfo.url, initiatorInfo.lineNumber,
initiatorInfo.columnNumber - 1);
// Linkified script locations may contain an unresolved live locations.
await TestRunner.waitForPendingLiveLocationUpdates();
TestRunner.addResult(element.textContent);
TestRunner.completeTest();
}
......
......@@ -40,7 +40,7 @@ Editing source:
Dumping breakpoint storage
edit-me-breakpoints.js:2, enabled:true
Dumping breakpoint locations
url: VMXX edit-me-breakpoints.js, lineNumber: 2, project type: debugger
url: edit-me-breakpoints.js, lineNumber: 2, project type: network
Dumping breakpoints
url: edit-me-breakpoints.js, lineNumber: 2, project type: network
Committing edited source:
......@@ -67,7 +67,7 @@ Editing source:
Dumping breakpoint storage
edit-me-breakpoints.js:2, enabled:true
Dumping breakpoint locations
url: VMXX edit-me-breakpoints.js, lineNumber: 2, project type: debugger
url: edit-me-breakpoints.js, lineNumber: 2, project type: network
Dumping breakpoints
url: edit-me-breakpoints.js, lineNumber: 2, project type: network
Committing edited source:
......@@ -108,7 +108,7 @@ Editing source:
Dumping breakpoint storage
edit-me-breakpoints.js:2, enabled:true
Dumping breakpoint locations
url: VMXX edit-me-breakpoints.js, lineNumber: 2, project type: debugger
url: edit-me-breakpoints.js, lineNumber: 2, project type: network
Dumping breakpoints
url: edit-me-breakpoints.js, lineNumber: 2, project type: network
Committing edited source:
......
......@@ -66,7 +66,7 @@
await SourcesTestRunner.setBreakpoint(sourceFrame, 2, '', true);
}
function breakpointResolved(callback, breakpointId, locations) {
async function breakpointResolved(callback, breakpointId, locations) {
var location = locations[0];
script = TestRunner.debuggerModel.scriptForId(location.scriptId);
......@@ -74,7 +74,7 @@
TestRunner.addResult('Editing source:');
SourcesTestRunner.replaceInSource(javaScriptSourceFrame, '}', '}//');
originalUISourceCode = Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(location).uiSourceCode;
originalUISourceCode = (await Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(location)).uiSourceCode;
SourcesTestRunner.showUISourceCode(originalUISourceCode, didShowOriginalUISourceCode);
}
......@@ -121,7 +121,7 @@
await SourcesTestRunner.setBreakpoint(sourceFrame, 2, '', true);
}
function breakpointResolved(callback, breakpointId, locations) {
async function breakpointResolved(callback, breakpointId, locations) {
var location = locations[0];
script = TestRunner.debuggerModel.scriptForId(location.scriptId);
......@@ -129,7 +129,7 @@
TestRunner.addResult('Editing source:');
SourcesTestRunner.replaceInSource(javaScriptSourceFrame, '}', '}//');
originalUISourceCode = Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(location).uiSourceCode;
originalUISourceCode = (await Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(location)).uiSourceCode;
SourcesTestRunner.showUISourceCode(originalUISourceCode, didShowOriginalUISourceCode);
}
......@@ -176,7 +176,7 @@
await SourcesTestRunner.setBreakpoint(sourceFrame, 2, '', true);
}
function breakpointResolved(callback, breakpointId, locations) {
async function breakpointResolved(callback, breakpointId, locations) {
var location = locations[0];
script = TestRunner.debuggerModel.scriptForId(location.scriptId);
......@@ -184,7 +184,7 @@
TestRunner.addResult('Editing source:');
SourcesTestRunner.replaceInSource(javaScriptSourceFrame, '}', '//}');
originalUISourceCode = Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(location).uiSourceCode;
originalUISourceCode = (await Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(location)).uiSourceCode;
SourcesTestRunner.showUISourceCode(originalUISourceCode, didShowOriginalUISourceCode);
}
......@@ -243,7 +243,7 @@
await SourcesTestRunner.setBreakpoint(sourceFrame, 2, '', true);
}
function breakpointResolved(callback, breakpointId, locations) {
async function breakpointResolved(callback, breakpointId, locations) {
var location = locations[0];
script = TestRunner.debuggerModel.scriptForId(location.scriptId);
......@@ -251,7 +251,7 @@
TestRunner.addResult('Editing source:');
SourcesTestRunner.replaceInSource(javaScriptSourceFrame, '}', '//}');
originalUISourceCode = Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(location).uiSourceCode;
originalUISourceCode = (await Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(location)).uiSourceCode;
SourcesTestRunner.showUISourceCode(originalUISourceCode, didShowOriginalUISourceCode);
}
......
......@@ -46,7 +46,7 @@
var line = script.lineOffset;
var column = script.columnOffset + 2;
var rawLocation = TestRunner.debuggerModel.createRawLocation(script, line, column);
var uiLocation = Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(rawLocation);
var uiLocation = await Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(rawLocation);
SourcesTestRunner.checkUILocation(uiSourceCode, line, column, uiLocation);
var reverseLocation = (await Bindings.debuggerWorkspaceBinding.uiLocationToRawLocations(uiSourceCode, line, column))[0];
SourcesTestRunner.checkRawLocation(script, line, column, reverseLocation);
......
......@@ -25,22 +25,22 @@
var position = text.positionFromOffset(offset);
var rawLocation = new SDK.CSSLocation(styleHeader, position.lineNumber, position.columnNumber);
rawLocations.push(rawLocation);
liveLocations.push(Bindings.cssWorkspaceBinding.createLiveLocation(rawLocation, () => {
liveLocations.push(await Bindings.cssWorkspaceBinding.createLiveLocation(rawLocation, () => {
locationUpdateCount++;
}, liveLocationsPool));
}
TestRunner.addResult('Location mapping with formatted source:');
dumpLocations();
await dumpLocations();
Formatter.sourceFormatter.discardFormattedUISourceCode(formatData.formattedSourceCode);
await Formatter.sourceFormatter.discardFormattedUISourceCode(formatData.formattedSourceCode);
TestRunner.addResult('Location mapping without formatted source:');
dumpLocations();
await dumpLocations();
TestRunner.completeTest();
function dumpLocations() {
async function dumpLocations() {
TestRunner.addResult('Mapped locations:');
for (var rawLocation of rawLocations) {
var uiLocation = Bindings.cssWorkspaceBinding.rawLocationToUILocation(rawLocation);
......@@ -52,7 +52,7 @@
}
TestRunner.addResult(`Live locations (updated: ${locationUpdateCount}):`);
for (var liveLocation of liveLocations) {
var uiLocation = liveLocation.uiLocation();
var uiLocation = await liveLocation.uiLocation();
TestRunner.addResult(`${uiLocation.lineNumber}:${uiLocation.columnNumber}`);
}
}
......
......@@ -24,7 +24,7 @@
TestRunner.addResult('Location mapping with formatted source:');
await dumpLocations(positions);
Formatter.sourceFormatter.discardFormattedUISourceCode(formatData.formattedSourceCode);
await Formatter.sourceFormatter.discardFormattedUISourceCode(formatData.formattedSourceCode);
TestRunner.addResult('Location mapping without formatted source:');
await dumpLocations(positions);
......@@ -34,7 +34,7 @@
async function dumpLocations(positions) {
for (var position of positions) {
var rawLocation = TestRunner.debuggerModel.createRawLocation(script, position.lineNumber, position.columnNumber);
var uiLocation = Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(rawLocation);
var uiLocation = await Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(rawLocation);
var reverseRawLocation = (await Bindings.debuggerWorkspaceBinding.uiLocationToRawLocations(
uiLocation.uiSourceCode, uiLocation.lineNumber, uiLocation.columnNumber))[0];
TestRunner.addResult(
......
......@@ -31,7 +31,10 @@
async function dumpToolbarItems(sourceFrame) {
const items = await sourceFrame.toolbarItems();
for (let item of items)
// Toolbar items have live locations.
await TestRunner.waitForPendingLiveLocationUpdates();
for (let item of items) {
TestRunner.addResult(item.element.deepTextContent());
}
}
})();
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment