Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /largest-contentful-paint/observe-text.html - WPT Dashboard Interop Dashboard
<!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>
<script src="resources/largest-contentful-paint-helpers.js"></script>
<style>
p {
font-size: 12px;
}
</style>
<script>
async_test(function (t) {
assert_implements(window.LargestContentfulPaint, "LargestContentfulPaint is not implemented");
let beforeRender;
const observer = new PerformanceObserver(
t.step_func_done(function(entryList) {
assert_equals(entryList.getEntries().length, 1);
const entry = entryList.getEntries()[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.
checkTextEntry(entry, 'my_text', 1200, beforeRender);
})
);
observer.observe({type: 'largest-contentful-paint', buffered: true});
beforeRender = performance.now();
}, 'Text element is observable as a LargestContentfulPaint candidate.');
</script>
<p id='my_text'>This is important text! :)</p>
</body>