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-largest-painted-element.html - WPT Dashboard Interop Dashboard
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>Container Timing: lastPaintedElement is the largest element, not the last painted</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>
let beforeRender;
async_test(function (t) {
assert_implements(window.PerformanceContainerTiming, "PerformanceContainerTiming is not implemented");
const observer = new PerformanceObserver(
t.step_func_done(function(entryList) {
assert_equals(entryList.getEntries().length, 1);
const entry = entryList.getEntries()[0];
// The small image is painted last, but the big one has the largest area
// of its own, so it is the one reported.
checkContainerEntry(entry, 'div_ct', 'big_id', beforeRender)
checkContainerIntersectionRect(entry, [0, 240, 0, 240])
checkContainerSize(entry, 11600);
})
);
observer.observe({entryTypes: ['container']});
// Add a div that is the container timing root
const div = document.createElement('div');
div.setAttribute('containertiming', 'div_ct');
document.body.appendChild(div);
// 100x100 = 10000 for the big one, 40x40 = 1600 for the small one.
const big = document.createElement('img');
big.src = '/container-timing/resources/square100.png';
big.setAttribute('id', 'big_id');
big.style.position = 'absolute';
big.style.left = '0px';
big.style.top = '0px';
big.style.width = '100px';
big.style.height = '100px';
div.appendChild(big);
const small = document.createElement('img');
small.src = '/container-timing/resources/square100.png';
small.setAttribute('id', 'small_id');
small.style.position = 'absolute';
small.style.left = '200px';
small.style.top = '200px';
small.style.width = '40px';
small.style.height = '40px';
div.appendChild(small);
beforeRender = performance.now();
}, 'lastPaintedElement reports the largest element painted.');
</script>
</body>