Automatic update from web-platform-tests [LongTasks] Truncate duration to 1 ms resolution Bug: 1146022 Change-Id: I71c726fdb85d432271220c66557a0fc64bdd341d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2552846 Commit-Queue: Nicolás Peña Moreno <npm@chromium.org> Reviewed-by: Yoav Weiss <yoavweiss@chromium.org> Cr-Commit-Position: refs/heads/master@{#832970} -- wpt-commits: d1aaf685cfb02e0350701550afe4146d555f2461 wpt-pr: 26614
27 lines
1.2 KiB
JavaScript
27 lines
1.2 KiB
JavaScript
// META: script=resources/utils.js
|
|
|
|
async_test(t => {
|
|
assert_implements(window.PerformanceLongTaskTiming, 'Longtasks are not supported.');
|
|
new PerformanceObserver(t.step_func((entryList, obs) => {
|
|
const observer = new PerformanceObserver(t.step_func_done(list => {
|
|
let longtaskObserved = false;
|
|
list.getEntries().forEach(entry => {
|
|
if (entry.entryType === 'mark')
|
|
return;
|
|
checkLongTaskEntry(entry);
|
|
longtaskObserved = true;
|
|
});
|
|
assert_true(longtaskObserved, 'Did not observe buffered longtask.');
|
|
}));
|
|
observer.observe({type: 'longtask', buffered: true});
|
|
// Observer mark so that we can flush the observer callback.
|
|
observer.observe({type: 'mark'});
|
|
performance.mark('m');
|
|
// Disconnect the embedding observer so this callback only runs once.
|
|
obs.disconnect();
|
|
})).observe({entryTypes: ['longtask']});
|
|
// Create a long task.
|
|
const begin = window.performance.now();
|
|
while (window.performance.now() < begin + 60);
|
|
}, 'PerformanceObserver with buffered flag can see previous longtask entries.');
|