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

Add {await} to http/tests/devtools/tracing/* web tests

Tracing web tests dump tracing events that can contain locations in
scripts. These locations may be source mapped. Resolving such a
location will be asynchronous in the future.

This CL prepares all tracing web tests for asynchronous source
mapping by adding async/await to the necessary places and waiting for
pending live location updates where needed.

The PerformanceTestRunner helpers that will be async in the
future are:

  * forAllEvents (since the callback may be async)
  * printTimelineRecordsWithDetails
  * printTraceEventPropertiesWithDetails
  * walkTimelineEventTree(UnderNode)

Note: One test is disabled for now, as the test passes an async
callback to a test helper that does not support that currently.
This test requires the usual 3-way dance.

Bug: chromium:1032016
Change-Id: I78d18b0aed922a06ab6e89db517a70119cd9ff72
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2064209
Commit-Queue: Simon Zünd <szuend@chromium.org>
Reviewed-by: default avatarMathias Bynens <mathias@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743500}
parent 8b83ebd6
......@@ -3237,6 +3237,8 @@ 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 ]
crbug.com/1032016 http/tests/devtools/tracing/timeline-js/timeline-script-id.js [ Pass Failure ]
crbug.com/1032016 virtual/threaded/http/tests/devtools/tracing/timeline-js/timeline-script-id.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 ]
......
......@@ -101,21 +101,21 @@
TestRunner.addResult('Original records');
filtersControl._notifyFiltersChanged();
dumpVisibleRecords();
await dumpVisibleRecords();
TestRunner.addResult(`Visible records when 'loading' is disabled`);
Timeline.TimelineUIUtils.categories().loading.hidden = true;
filtersControl._notifyFiltersChanged();
dumpVisibleRecords();
await dumpVisibleRecords();
TestRunner.addResult(`Visible records when 'scripting' is disabled`);
Timeline.TimelineUIUtils.categories().scripting.hidden = true;
filtersControl._notifyFiltersChanged();
dumpVisibleRecords();
await dumpVisibleRecords();
TestRunner.completeTest();
function dumpVisibleRecords() {
PerformanceTestRunner.walkTimelineEventTreeUnderNode(event => TestRunner.addResult(event.name), view._currentTree);
async function dumpVisibleRecords() {
await PerformanceTestRunner.walkTimelineEventTreeUnderNode(event => TestRunner.addResult(event.name), view._currentTree);
}
})();
......@@ -11,5 +11,5 @@
function performActions() {
var e = document.elementFromPoint(10, 10);
}`);
PerformanceTestRunner.performActionsAndPrint('performActions()', 'HitTest');
await PerformanceTestRunner.performActionsAndPrint('performActions()', 'HitTest');
})();
......@@ -23,6 +23,6 @@
`);
await PerformanceTestRunner.invokeAsyncWithTimeline('performActions');
PerformanceTestRunner.printTimelineRecordsWithDetails(TimelineModel.TimelineModel.RecordType.CompileScript);
await PerformanceTestRunner.printTimelineRecordsWithDetails(TimelineModel.TimelineModel.RecordType.CompileScript);
TestRunner.completeTest();
})();
......@@ -13,5 +13,5 @@
`);
UI.panels.timeline._disableCaptureJSProfileSetting.set(true);
PerformanceTestRunner.performActionsAndPrint('performActions()', 'FunctionCall');
await PerformanceTestRunner.performActionsAndPrint('performActions()', 'FunctionCall');
})();
......@@ -36,7 +36,7 @@
const debuggerModel = SDK.targetManager.mainTarget().model(SDK.DebuggerModel);
const rawLocation = debuggerModel.createRawLocationByScriptId(scriptId, 0, 0);
const uiLocation = Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(rawLocation);
const uiLocation = await Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(rawLocation);
await SourcesTestRunner.showUISourceCodePromise(uiLocation.uiSourceCode);
function decorationAdded(line, type, element) {
......
......@@ -32,19 +32,21 @@
const recordTypes = new Set(['TimerInstall', 'TimerRemove', 'FunctionCall']);
await PerformanceTestRunner.invokeAsyncWithTimeline('performActions');
PerformanceTestRunner.walkTimelineEventTree(formatter);
await PerformanceTestRunner.walkTimelineEventTree(formatter);
TestRunner.completeTest();
function formatter(event) {
async function formatter(event) {
if (!recordTypes.has(event.name))
return;
var detailsText = Timeline.TimelineUIUtils.buildDetailsTextForTraceEvent(
var detailsText = await Timeline.TimelineUIUtils.buildDetailsTextForTraceEvent(
event, PerformanceTestRunner.timelineModel().targetByEvent(event));
await TestRunner.waitForPendingLiveLocationUpdates();
TestRunner.addResult('detailsTextContent for ' + event.name + ' event: \'' + detailsText + '\'');
var details = Timeline.TimelineUIUtils.buildDetailsNodeForTraceEvent(
var details = await Timeline.TimelineUIUtils.buildDetailsNodeForTraceEvent(
event, PerformanceTestRunner.timelineModel().targetByEvent(event), linkifier);
await TestRunner.waitForPendingLiveLocationUpdates();
if (!details)
return;
TestRunner.addResult(
......
......@@ -24,8 +24,8 @@
await PerformanceTestRunner.invokeAsyncWithTimeline('performActions');
PerformanceTestRunner.printTimelineRecordsWithDetails('RequestAnimationFrame');
PerformanceTestRunner.printTimelineRecordsWithDetails('FireAnimationFrame');
PerformanceTestRunner.printTimelineRecordsWithDetails('CancelAnimationFrame');
await PerformanceTestRunner.printTimelineRecordsWithDetails('RequestAnimationFrame');
await PerformanceTestRunner.printTimelineRecordsWithDetails('FireAnimationFrame');
await PerformanceTestRunner.printTimelineRecordsWithDetails('CancelAnimationFrame');
TestRunner.completeTest();
})();
......@@ -25,8 +25,12 @@
TimelineModel.TimelineModel.RecordType.CryptoDoDecryptReply
]);
const tracingModel = PerformanceTestRunner.tracingModel();
const eventsToPrint = [];
tracingModel.sortedProcesses().forEach(p => p.sortedThreads().forEach(t =>
t.events().filter(event => events.has(event.name)).forEach(PerformanceTestRunner.printTraceEventPropertiesWithDetails)));
eventsToPrint.push(...t.events().filter(event => events.has(event.name)))));
for (const event of eventsToPrint) {
await PerformanceTestRunner.printTraceEventPropertiesWithDetails(event);
}
TestRunner.completeTest();
})();
......@@ -35,6 +35,7 @@
PerformanceTestRunner.timelineModel().targetByEvent(event), linkifier, true);
Timeline.TimelineUIUtils._generateCauses(
event, PerformanceTestRunner.timelineModel().targetByEvent(event), null, contentHelper);
await TestRunner.waitForPendingLiveLocationUpdates();
var causes = contentHelper.element.deepTextContent();
TestRunner.check(causes, 'Should generate causes');
checkStringContains(causes, 'Timer Installed\n(anonymous) @ setTimeoutFunction.js:');
......@@ -58,6 +59,7 @@
PerformanceTestRunner.timelineModel().targetByEvent(event), linkifier, true);
Timeline.TimelineUIUtils._generateCauses(
event, PerformanceTestRunner.timelineModel().targetByEvent(event), null, contentHelper);
await TestRunner.waitForPendingLiveLocationUpdates();
var causes = contentHelper.element.deepTextContent();
TestRunner.check(causes, 'Should generate causes');
checkStringContains(causes, 'Animation Frame Requested\n(anonymous) @ requestAnimationFrameFunction.js:');
......@@ -83,6 +85,7 @@
PerformanceTestRunner.timelineModel().targetByEvent(event), linkifier, true);
Timeline.TimelineUIUtils._generateCauses(
event, PerformanceTestRunner.timelineModel().targetByEvent(event), null, contentHelper);
await TestRunner.waitForPendingLiveLocationUpdates();
var causes = contentHelper.element.deepTextContent();
TestRunner.check(causes, 'Should generate causes');
checkStringContains(causes, 'First Invalidated\nstyleRecalcFunction @ styleRecalcFunction.js:');
......@@ -108,6 +111,7 @@
PerformanceTestRunner.timelineModel().targetByEvent(event), linkifier, true);
Timeline.TimelineUIUtils._generateCauses(
event, PerformanceTestRunner.timelineModel().targetByEvent(event), null, contentHelper);
await TestRunner.waitForPendingLiveLocationUpdates();
var causes = contentHelper.element.deepTextContent();
TestRunner.check(causes, 'Should generate causes');
checkStringContains(causes, 'Layout Forced\nlayoutFunction @ layoutFunction.js:');
......
......@@ -100,22 +100,22 @@
TestRunner.addResult(' '.repeat(level) + text);
}
function dumpRecords() {
PerformanceTestRunner.walkTimelineEventTreeUnderNode(
async function dumpRecords() {
await PerformanceTestRunner.walkTimelineEventTreeUnderNode(
printEventMessage, view._root);
TestRunner.addResult('');
}
TestRunner.addResult('Initial:');
dumpRecords();
await dumpRecords();
TestRunner.addResult(`Filtered by 'AAA':`);
view._textFilterUI.setValue('AAA', true);
dumpRecords();
await dumpRecords();
TestRunner.addResult(`Filtered by 'BBB':`);
view._textFilterUI.setValue('BBB', true);
dumpRecords();
await dumpRecords();
TestRunner.completeTest();
})();
......@@ -290,21 +290,21 @@
TestRunner.addResult(' '.repeat(level) + text);
}
function dumpRecords() {
PerformanceTestRunner.walkTimelineEventTreeUnderNode(printEventMessage, view._currentTree);
async function dumpRecords() {
await PerformanceTestRunner.walkTimelineEventTreeUnderNode(printEventMessage, view._currentTree);
TestRunner.addResult('');
}
TestRunner.addResult('Initial:');
dumpRecords();
await dumpRecords();
TestRunner.addResult(`Filtered by 'bar':`);
view._textFilterUI.setValue('bar', true);
dumpRecords();
await dumpRecords();
TestRunner.addResult(`Filtered by 'foo':`);
view._textFilterUI.setValue('foo', true);
dumpRecords();
await dumpRecords();
TestRunner.completeTest();
})();
......@@ -195,9 +195,9 @@
];
var tracingTimelineModel = PerformanceTestRunner.createPerformanceModelWithEvents(commonMetadata.concat(traceEvents));
PerformanceTestRunner.forAllEvents(PerformanceTestRunner.mainTrackEvents(), (event, stack) => {
await PerformanceTestRunner.forAllEvents(PerformanceTestRunner.mainTrackEvents(), async (event, stack) => {
const prefix = Array(stack.length + 1).join('----') + (stack.length ? '> ' : '');
const details = Timeline.TimelineUIUtils.buildDetailsTextForTraceEvent(event, null) || '';
const details = await Timeline.TimelineUIUtils.buildDetailsTextForTraceEvent(event, null) || '';
TestRunner.addResult(`${prefix}${event.name}: ${details}`);
});
TestRunner.completeTest();
......
......@@ -32,28 +32,28 @@
const sendRequests = PerformanceTestRunner.mainTrackEvents().
filter(e => e.name === TimelineModel.TimelineModel.RecordType.ResourceSendRequest);
for (let event of sendRequests) {
printEvent(event);
printEventsWithId(event.args['data'].requestId);
await printEvent(event);
await printEventsWithId(event.args['data'].requestId);
}
TestRunner.completeTest();
function printEventsWithId(id) {
async function printEventsWithId(id) {
var model = PerformanceTestRunner.timelineModel();
PerformanceTestRunner.mainTrackEvents().forEach(event => {
if (event.name !== TimelineModel.TimelineModel.RecordType.ResourceReceiveResponse &&
event.name !== TimelineModel.TimelineModel.RecordType.ResourceFinish) {
return;
}
if (event.args['data'].requestId !== id)
return;
printEvent(event);
});
for (const event of PerformanceTestRunner.mainTrackEvents()) {
if (event.name !== TimelineModel.TimelineModel.RecordType.ResourceReceiveResponse &&
event.name !== TimelineModel.TimelineModel.RecordType.ResourceFinish) {
continue;
}
if (event.args['data'].requestId !== id)
continue;
await printEvent(event);
}
}
function printEvent(event) {
async function printEvent(event) {
TestRunner.addResult('');
PerformanceTestRunner.printTraceEventProperties(event);
TestRunner.addResult(
`Text details for ${event.name}: ` + Timeline.TimelineUIUtils.buildDetailsTextForTraceEvent(event));
`Text details for ${event.name}: ` + await Timeline.TimelineUIUtils.buildDetailsTextForTraceEvent(event));
}
})();
......@@ -56,6 +56,6 @@
if (typesToDump.has(traceEvent.name) && (traceEvent.name !== 'FunctionCall' || traceEvent.args['data']['url']))
TestRunner.addResult(' '.repeat(level - 1) + traceEvent.name);
}
PerformanceTestRunner.walkTimelineEventTree(dumpEvent);
await PerformanceTestRunner.walkTimelineEventTree(dumpEvent);
TestRunner.completeTest();
})();
......@@ -21,8 +21,13 @@
const events = new Set([TimelineModel.TimelineModel.RecordType.CompileModule, TimelineModel.TimelineModel.RecordType.EvaluateModule]);
const tracingModel = PerformanceTestRunner.tracingModel();
const eventsToPrint = [];
tracingModel.sortedProcesses().forEach(p => p.sortedThreads().forEach(t =>
t.events().filter(event => events.has(event.name)).forEach(PerformanceTestRunner.printTraceEventPropertiesWithDetails)));
eventsToPrint.push(...t.events().filter(event => events.has(event.name)))));
for (const event of eventsToPrint) {
await PerformanceTestRunner.printTraceEventPropertiesWithDetails(event);
}
TestRunner.completeTest();
})();
......@@ -79,7 +79,7 @@
}
UI.panels.timeline._disableCaptureJSProfileSetting.set(true);
await PerformanceTestRunner.evaluateWithTimeline(actions);
PerformanceTestRunner.walkTimelineEventTree(dumpName);
await PerformanceTestRunner.walkTimelineEventTree(dumpName);
next();
}
})();
......@@ -29,10 +29,10 @@
UI.panels.timeline._disableCaptureJSProfileSetting.set(true);
await PerformanceTestRunner.invokeAsyncWithTimeline('performActions');
PerformanceTestRunner.printTimelineRecordsWithDetails('TimerInstall');
PerformanceTestRunner.printTimelineRecordsWithDetails('TimerFire');
PerformanceTestRunner.printTimelineRecordsWithDetails('TimerRemove');
await PerformanceTestRunner.printTimelineRecordsWithDetails('TimerInstall');
await PerformanceTestRunner.printTimelineRecordsWithDetails('TimerFire');
await PerformanceTestRunner.printTimelineRecordsWithDetails('TimerRemove');
PerformanceTestRunner.printTimelineRecords('FunctionCall');
PerformanceTestRunner.printTimelineRecordsWithDetails('EvaluateScript');
await PerformanceTestRunner.printTimelineRecordsWithDetails('EvaluateScript');
TestRunner.completeTest();
})();
......@@ -23,7 +23,7 @@
await PerformanceTestRunner.invokeAsyncWithTimeline('performActions');
PerformanceTestRunner.printTimelineRecordsWithDetails('XHRReadyStateChange');
PerformanceTestRunner.printTimelineRecordsWithDetails('XHRLoad');
await PerformanceTestRunner.printTimelineRecordsWithDetails('XHRReadyStateChange');
await PerformanceTestRunner.printTimelineRecordsWithDetails('XHRLoad');
TestRunner.completeTest();
})();
......@@ -16,9 +16,9 @@
await PerformanceTestRunner.invokeAsyncWithTimeline('performActions');
PerformanceTestRunner.printTimelineRecordsWithDetails('WebSocketCreate');
PerformanceTestRunner.printTimelineRecordsWithDetails('WebSocketSendHandshakeRequest');
PerformanceTestRunner.printTimelineRecordsWithDetails('WebSocketReceiveHandshakeResponse');
PerformanceTestRunner.printTimelineRecordsWithDetails('WebSocketDestroy');
await PerformanceTestRunner.printTimelineRecordsWithDetails('WebSocketCreate');
await PerformanceTestRunner.printTimelineRecordsWithDetails('WebSocketSendHandshakeRequest');
await PerformanceTestRunner.printTimelineRecordsWithDetails('WebSocketReceiveHandshakeResponse');
await PerformanceTestRunner.printTimelineRecordsWithDetails('WebSocketDestroy');
TestRunner.completeTest();
})();
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