<!DOCTYPE html>
<html>
<body>
<script src="../resources/runner.js"></script>
<table id="testElement">
<tr>
<th>Sender</th>
<td>Message</td>
</tr>
</table>
<script>
var isDone = false;
var startTime;
// Before the test starts, add 2000 rows to the table, something like a
// message board with lots of replies on a long thread.
// Ensure test content is generated before page load, so that the test
// construction is not part of the collected traces.
let table = document.getElementById('testElement');
for (let i = 0; i < 2000; i++) {
let tr = document.createElement('tr');
table.appendChild(tr);
let sender = document.createElement('td');
sender.innerHTML = 'user' + Math.floor(10000*Math.random());
tr.appendChild(sender);
let message = document.createElement('td');
message.innerHTML = '<div>Message content ' +
Math.floor(10000*Math.random()) + '</div>';
let link = document.createElement('a');
link.href = '#';
link.id = 'link' + i;
link.innerHTML = 'Reply';
message.appendChild(link);
tr.appendChild(message);
}
document.documentElement.className = ''; // Begin tracing after next a11y update.
function runTest() {
if (startTime) {
PerfTestRunner.measureValueAsync(PerfTestRunner.now() - startTime);
PerfTestRunner.addRunTestEndMarker();
}
if (!isDone) {
PerfTestRunner.addRunTestStartMarker();
startTime = PerfTestRunner.now();
// Iterate over some of the links and focus each one with a different
// delay. Just focusing a link shouldn't incur a large cost,
// even if the page has a lot of elements.
for (let i = 0; i < 33; i++) {
window.setTimeout(() => {
document.getElementById('link' + i).focus();
}, 250 + (2 * i));
}
// Wait to allow the asynchronous accessibility code that's
// covered by traceEventsToMeasure to have a chance to run.
setTimeout(runTest, 2500);
}
}
PerfTestRunner.startMeasureValuesAsync({
description: 'Test accessibility performance when appending to a textarea.',
unit: 'ms',
done: function () {
isDone = true;
},
run: function() {
runTest();
},
iterationCount: 6,
tracingCategories: 'accessibility',
traceEventsToMeasure: [
'TotalAccessibilityCleanLayoutLifecycleStages',
'ProcessDeferredUpdatesLifecycleStage',
'FinalizingTreeLifecycleStage',
'SerializeLifecycleStage',
'RenderAccessibilityImpl::SendPendingAccessibilityEvents',
'BrowserAccessibilityManager::OnAccessibilityEvents',
'SerializeLocationChanges',
"BrowserAccessibilityManager::OnLocationChanges"
]
});
</script>
</html>