Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /container-timing/tentative/containertiming-and-ignore-on-text-itself.html - WPT Dashboard Interop Dashboard
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>Container Timing: observe a paragraph with both containertiming and containertimingignore</title>
<body>
<style>
body {
margin: 0;
}
</style>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/container-timing/resources/container-timing-helpers.js"></script>
<script>
promise_test(async t => {
assert_implements(window.PerformanceContainerTiming, "PerformanceContainerTiming is not implemented");
// Add a paragraph that is itself a container timing root AND has
// containertimingignore set. containertimingignore only blocks upward
// propagation to ancestor roots; the element's own text paint still
// reports under its own root.
addText(document.body, {
containertiming: 'p_ct',
containertimingignore: '',
id: 'my_id'
});
const beforeRender = performance.now();
const entries = await getContainerEntries(t);
assert_equals(entries.length, 1);
const entry = entries[0];
checkContainerEntry(entry, 'p_ct', 'my_id', beforeRender);
// The exact text size depends on font metrics, so unlike the image
// version we only assert the painted area and intersection rect are
// non-zero (symmetry with containertiming-and-ignore-on-img-itself).
assert_greater_than(entry.size, 0, 'container size should be non-zero');
assert_greater_than(
entry.intersectionRect.right - entry.intersectionRect.left, 0,
'intersection rect width should be non-zero');
assert_greater_than(
entry.intersectionRect.bottom - entry.intersectionRect.top, 0,
'intersection rect height should be non-zero');
}, 'Text element with both containertiming and containertimingignore reports its own paint.');
</script>
</body>