Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE HTML>
<meta charset=utf-8>
<title>Container Timing: a container root inserted again is reported as a new container</title>
<body>
<style>
body {
margin: 0;
}
img {
position: absolute;
width: 100px;
height: 100px;
}
</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");
const collector = observeContainerEntries(t);
const div = addContainerRoot(document.body, 'div_ct');
t.add_cleanup(() => div.remove());
addSquare100Image(div, {id: 'img_id', style: 'left: 0px; top: 0px'});
let entries = await collector.take();
assert_equals(entries.length, 1, 'entry for the initial paint');
div.remove();
entries = await collector.take();
assert_equals(entries.length, 0, 'no entries while removed');
document.body.appendChild(div);
const beforeRender = performance.now();
entries = await collector.take();
assert_equals(entries.length, 1, 'entry after inserting the root again');
checkContainerEntry(entries[0], 'div_ct', 'img_id', beforeRender);
checkContainerIntersectionRect(entries[0], [0, 100, 0, 100]);
checkContainerSize(entries[0], 10000);
}, 'Paints after inserting the container root again are reported from scratch.');
promise_test(async t => {
assert_implements(window.PerformanceContainerTiming, "PerformanceContainerTiming is not implemented");
const collector = observeContainerEntries(t);
const div = addContainerRoot(document.body, 'text_ct');
t.add_cleanup(() => div.remove());
addText(div, {id: 'text_id'});
let entries = await collector.take();
assert_equals(entries.length, 1, 'entry for the initial paint');
const size = entries[0].size;
div.remove();
entries = await collector.take();
assert_equals(entries.length, 0, 'no entries while removed');
document.body.appendChild(div);
const beforeRender = performance.now();
entries = await collector.take();
assert_equals(entries.length, 1, 'entry after inserting the root again');
checkContainerEntry(entries[0], 'text_ct', 'text_id', beforeRender);
checkContainerSize(entries[0], size);
}, 'Text painted after inserting the container root again is reported from scratch.');
</script>
</body>