gecko-dev/testing/web-platform/tests/element-timing/observe-large-image.html
Nicolás Peña Moreno e6176f6902 Bug 1531187 [wpt PR 15554] - [ElementTiming] Add request URL and responseEnd, a=testonly
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
2019-04-01 14:42:54 +01:00

44 lines
1.6 KiB
HTML

<!DOCTYPE HTML>
<meta charset=utf-8>
<title>Element Timing: observe large elements</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/square20.jpg';
checkElement(entry, pathname, '', beforeRender);
// Assume viewport hasn't changed, so the element occupies all of it.
checkRect(entry,
[0, document.documentElement.clientWidth, 0, document.documentElement.clientHeight]);
})
);
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 an image setting width and height equal to viewport.
const img = document.createElement('img');
img.src = 'resources/square20.jpg';
img.width = document.documentElement.clientWidth;
img.height = document.documentElement.clientHeight;
document.body.appendChild(img);
beforeRender = performance.now();
};
}, 'Large img element is observable.');
</script>
</body>