blob: 77ed06e2aa1fb99d1199b9e3b6e99620037ef959 [file] [log] [blame]
<meta charset=utf-8>
<title>Largest Contentful Paint: observe text.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
p {
font-size: 12px;
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(, 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 =;
}, 'Element with elementtiming attribute is observable.');
<p>This is important text! :)</p>