mirror of
https://github.com/servo/servo
synced 2026-05-14 10:56:44 +02:00
37 lines
1.4 KiB
HTML
37 lines
1.4 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<meta charset=utf-8 />
|
|
<title>Element Timing: buffer elements before onload</title>
|
|
<script src=/resources/testharness.js></script>
|
|
<script src=/resources/testharnessreport.js></script>
|
|
<script src="resources/element-timing-helpers.js"></script>
|
|
<body>
|
|
<img src=resources/slow-image.py?name=square20.png&sleep=500>
|
|
<script>
|
|
/*
|
|
In this test, a slow image is added to the frame to delay onload. The entry
|
|
for the other image should be available before onload, and thus delivered to
|
|
the performance timeline.
|
|
*/
|
|
async_test(function(t) {
|
|
beforeRender = performance.now();
|
|
const img = document.createElement('img');
|
|
img.src = 'resources/square20.jpg';
|
|
img.setAttribute('elementtiming', 'my_image');
|
|
document.body.appendChild(img);
|
|
window.onload = t.step_func_done( () => {
|
|
const entries = performance.getEntriesByType('element');
|
|
assert_greater_than_equal(entries.length, 1);
|
|
assert_equals(performance.getEntries().filter(e => e.identifier === 'my_image').length, 1);
|
|
const entry = entries[0];
|
|
const index = window.location.href.lastIndexOf('/');
|
|
const pathname = window.location.href.substring(0, index) +
|
|
'/resources/square20.jpg';
|
|
checkElement(entry, pathname, 'my_image', beforeRender);
|
|
});
|
|
}, "Element Timing: image loads before onload.");
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|