Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /container-timing/tentative/containertiming-text-itself.html - WPT Dashboard Interop Dashboard
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>Container Timing: observe a paragraph with containertiming attribute</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 src="/element-timing/resources/element-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, 'p_ct', 'my_id', beforeRender);
})
);
observer.observe({entryTypes: ['container']});
// Add the text during onload to be sure that the observer is registered
// in time.
window.onload = () => {
const p = document.createElement('p');
p.setAttribute('containertiming', 'p_ct');
p.id = 'my_id';
p.innerText = "This is a text";
document.body.appendChild(p);
beforeRender = performance.now();
};
}, 'Element with containertiming attribute is observable and reports the text paint.');
</script>
</body>