forked from mirrors/gecko-dev
Automatic update from web-platform-tests Refactor longtask monitoring to use LoAF code Currently behind a flag (LongTaskFromLongAnimationFrame) This consolidates a lot of this code, and a lot of PerformanceMonitor can be removed once the flag is enabled. Because window-attribution uses the scheduler rather than rely on particular scripts, promise-based tasks work out of the box, so added a test. Note that enabling this would be a subtle change in behavior, as apart from reporting longtasks that were previously unreported, we also stop reporting longtask that occur in hidden windows. Bug: 1251964 Bug: 1441419 Change-Id: I2bbad4562cd1aceb2087d9a52eab31c44bb7d9df Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4495305 Reviewed-by: Yoav Weiss <yoavweiss@chromium.org> Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org> Commit-Queue: Noam Rosenthal <nrosenthal@chromium.org> Cr-Commit-Position: refs/heads/main@{#1138244} -- wpt-commits: 10063aa63eb438f7e1cbff41da41dfe62bf7d77d wpt-pr: 39769
33 lines
907 B
JavaScript
33 lines
907 B
JavaScript
// META: script=/resources/WebIDLParser.js
|
|
// META: script=/resources/idlharness.js
|
|
|
|
// https://w3c.github.io/longtasks/
|
|
|
|
'use strict';
|
|
|
|
idl_test(
|
|
['longtasks'],
|
|
['performance-timeline', 'hr-time'],
|
|
(idl_array, t) => new Promise((resolve, reject) => {
|
|
const longTask = () => {
|
|
const begin = self.performance.now();
|
|
while (self.performance.now() < begin + 100);
|
|
}
|
|
t.step_timeout(longTask, 0);
|
|
|
|
const observer = new PerformanceObserver((entryList, observer) => {
|
|
const entries = Array.from(entryList.getEntries());
|
|
idl_array.add_objects({
|
|
PerformanceLongTaskTiming: entries.slice(0, 1),
|
|
TaskAttributionTiming: entries[0].attribution,
|
|
});
|
|
observer.disconnect();
|
|
resolve();
|
|
});
|
|
observer.observe({entryTypes: ['longtask']});
|
|
|
|
t.step_timeout(() => {
|
|
reject('longtask entry was not observed');
|
|
}, 1000);
|
|
})
|
|
);
|