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:
- /element-timing/input-type-image.html - WPT Dashboard Interop Dashboard
<!DOCTYPE HTML>
<head>
<meta charset=utf-8>
<title>Element Timing: observe an input type image</title>
<style>
body {
margin: 20px;
}
</style>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/element-timing-helpers.js"></script>
<script>
let beforeRender;
let input;
async_test(function (t) {
assert_implements(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
const observer = new PerformanceObserver(
t.step_func_done(function(entryList) {
assert_equals(entryList.getEntries().length, 1);
const entry = entryList.getEntries()[0];
const pathname = window.location.origin + '/images/green-100x50.png';
checkElement(entry, pathname, 'my_input', 'rectangle', beforeRender, input);
checkRect(entry, [20, 120, 20, 70]);
checkNaturalSize(entry, 100, 50);
})
);
observer.observe({entryTypes: ['element']});
// We add the image input during onload to be sure that the observer is
// registered in time for it to observe the element timing.
window.onload = () => {
// Add input of width equal to 100 and height equal to 50.
input = document.createElement('input');
input.type = 'image';
input.id = 'rectangle';
input.src = '/images/green-100x50.png';
input.setAttribute('elementtiming', 'my_input');
document.body.appendChild(input);
beforeRender = performance.now();
};
}, 'Element with an image input.');
</script>
</head>
<body></body>