Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE HTML>
<meta charset=utf-8>
<title>Container Timing: observe with a node with containertiming and a canvas child</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];
checkContainerEntry(entry, 'div_ct', 'canvas_id', beforeRender);
checkContainerSize(entry, 10000);
})
);
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);
// Add canvas of width equal to 100 and height equal to 100.
const canvas = document.createElement('canvas');
canvas.width = 100;
canvas.height = 100;
canvas.setAttribute('id', 'canvas_id');
div.appendChild(canvas);
// Draw something on the canvas to make it "contentful"
const ctx = canvas.getContext('2d');
ctx.fillStyle = 'red';
ctx.fillRect(0, 0, 100, 100);
beforeRender = performance.now();
}, 'Paint of the canvas child of container timing is reported.');
</script>
</body>