mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-12 22:28:59 +02:00
Automatic update from web-platform-tests [ElementTiming] Add request URL and responseEnd This CL adds the initial URL and the response end from ResourceTiming into ElementTiming. The information is currently only stored on the ResourceTimingInfo object which is not accessible to ImageElementTiming (and in fact, could be gone by the time the ElementTiming code is executed). Thus, we store the information in ImageResourceContent. Bug: 879270 Change-Id: I72a80c67956adb6e869f39ca3c77829bad86044e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1483733 Reviewed-by: Yoav Weiss <yoavweiss@chromium.org> Reviewed-by: Yutaka Hirano <yhirano@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org> Cr-Commit-Position: refs/heads/master@{#638153} -- wpt-commits: 84bcab667e849b1baa6b0bd70244375190521b59 wpt-pr: 15554
42 lines
1.5 KiB
HTML
42 lines
1.5 KiB
HTML
<!DOCTYPE HTML>
|
|
<meta charset=utf-8>
|
|
<title>Element Timing: observe elements with elementtiming attribute</title>
|
|
<body>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
}
|
|
</style>
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script src="resources/element-timing-helpers.js"></script>
|
|
<script>
|
|
let beforeRender;
|
|
async_test(function (t) {
|
|
const observer = new PerformanceObserver(
|
|
t.step_func_done(function(entryList) {
|
|
assert_equals(entryList.getEntries().length, 1);
|
|
const entry = entryList.getEntries()[0];
|
|
const index = window.location.href.lastIndexOf('/');
|
|
const pathname = window.location.href.substring(0, index) +
|
|
'/resources/square100.png';
|
|
checkElement(entry, pathname, 'my_image', beforeRender);
|
|
// Assume viewport has size at least 100, so the element is fully visible.
|
|
checkRect(entry, [0, 100, 0, 100]);
|
|
})
|
|
);
|
|
observer.observe({entryTypes: ['element']});
|
|
// We add the image during onload to be sure that the observer is registered
|
|
// in time for it to observe the element timing.
|
|
window.onload = () => {
|
|
// Add image of width and height equal to 100.
|
|
const img = document.createElement('img');
|
|
img.src = 'resources/square100.png';
|
|
img.setAttribute('elementtiming', 'my_image');
|
|
document.body.appendChild(img);
|
|
beforeRender = performance.now();
|
|
};
|
|
}, 'Element with elementtiming attribute is observable.');
|
|
</script>
|
|
|
|
</body>
|