Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /paint-timing/paint-timing-mixin.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<head>
<title>Performance Paint Timing: Check that paintTime/presentationTime are available</title>
</head>
<body>
<script src="resources/utils.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({"hide_test_state": true});
promise_test(async t => {
assert_implements(window.PerformancePaintTiming, "Paint Timing isn't supported.");
assert_implements("paintTime" in window.PerformancePaintTiming.prototype, "Paint Timing doesn't expose `paintTime`");
await new Promise(r => window.addEventListener('load', r));
await assertNoFirstContentfulPaint(t);
const img = document.createElement('img');
img.src = 'resources/circles.png';
document.body.append(img);
const reference_time = performance.now();
const performance_entry_promise = new Promise(resolve => {
new PerformanceObserver(entries => {
const [entry] = entries.getEntriesByName("first-contentful-paint");
if (entry)
resolve(entry);
}).observe({type: "paint"});
});
await new Promise(resolve => img.addEventListener("load", () => resolve()));
const entry = await performance_entry_promise;
assert_greater_than(entry.paintTime, reference_time);
assert_greater_than(entry.presentationTime, entry.paintTime);
assert_equals(entry.presentationTime, entry.startTime);
}, "Paint timing entries should expose paintTime and presentationTime");
</script>
</body>
</html>