blob: 77ed06e2aa1fb99d1199b9e3b6e99620037ef959 [file] [log] [blame]
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>Largest Contentful Paint: observe text.</title>
<body>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
p {
font-size: 12px;
}
</style>
<script>
let beforeRender;
async_test(function (t) {
if (!window.LargestContentfulPaint) {
assert_unreached("LargestContentfulPaint is not implemented");
}
const observer = new PerformanceObserver(
t.step_func_done(function(entryList) {
assert_equals(entryList.getEntries().length, 1);
const entry = entryList.getEntries()[0];
assert_equals(entry.entryType, 'largestContentfulPaint');
assert_greater_than_equal(entry.startTime, beforeRender);
assert_greater_than_equal(performance.now(), entry.startTime);
assert_equals(entry.duration, 0);
// Some lower bound: height of at least 12 px.
// Width of at least 100 px.
// TODO: find a good way to bound text width.
assert_greater_than_equal(entry.size, 1200);
})
);
observer.observe({type: 'largestContentfulPaint', buffered: true});
beforeRender = performance.now();
}, 'Element with elementtiming attribute is observable.');
</script>
<p>This is important text! :)</p>
</body>