mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 16:55:40 +00:00
Bug 1572780 [wpt PR 18345] - [ElementTiming] Fix background image loadTime, a=testonly
Automatic update from web-platform-tests [ElementTiming] Fix background image loadTime This change adds a map |background_image_timestamps_| of load timestamps of background images tracked by StyleFetchedImage, which are the background images with url. The map only tracks the load time, as |images_notified_| must still be used to track the background image paints. Otherwise we'd only report an entry per background image even when applied to multiple elements. This change also makes computations a bit more efficient by only calling base::TimeTicks::Now() on the first time we load an entry. It also fixes a problem of calling Set() in between usages of an iterator, which is not allowed. Before this change, the added test would crash due to this problem. Bug: 879270, 986891 Change-Id: I86640f5587f69f94e13c429f3e55b3d5d6978cc0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1745497 Reviewed-by: Steve Kobes <skobes@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org> Cr-Commit-Position: refs/heads/master@{#686176} -- wpt-commits: 1d8fa760f9999ef13baa4c267bf042b7b4122789 wpt-pr: 18345
This commit is contained in:
parent
614b7a6bc9
commit
c14baae984
@ -0,0 +1,45 @@
|
||||
<!DOCTYPE HTML>
|
||||
<meta charset=utf-8>
|
||||
<title>Element Timing: observe element with background image in its first letter</title>
|
||||
<body>
|
||||
<style>
|
||||
#target::first-letter {
|
||||
background-image: url('/images/black-rectangle.png');
|
||||
}
|
||||
</style>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/element-timing-helpers.js"></script>
|
||||
<script>
|
||||
let beforeRender = performance.now();
|
||||
async_test(function (t) {
|
||||
if (!window.PerformanceElementTiming) {
|
||||
assert_unreached("PerformanceElementTiming is not implemented");
|
||||
}
|
||||
const div = document.getElementById('target');
|
||||
let textObserved = false;
|
||||
let imageObserved = false;
|
||||
const observer = new PerformanceObserver(
|
||||
t.step_func(function(entryList) {
|
||||
entryList.getEntries().forEach(entry => {
|
||||
if (entry.name === 'text-paint') {
|
||||
checkTextElement(entry, 'my_div', 'target', beforeRender, div);
|
||||
textObserved = true;
|
||||
}
|
||||
else {
|
||||
assert_equals(entry.name, 'image-paint');
|
||||
const pathname = window.location.origin + '/images/black-rectangle.png';
|
||||
checkElement(entry, pathname, 'my_div', 'target', beforeRender, div);
|
||||
checkNaturalSize(entry, 100, 50);
|
||||
imageObserved = true;
|
||||
}
|
||||
});
|
||||
if (textObserved && imageObserved)
|
||||
t.done();
|
||||
})
|
||||
);
|
||||
observer.observe({entryTypes: ['element']});
|
||||
}, 'Element with elementtiming attribute and background image in first-letter is observable.');
|
||||
</script>
|
||||
<div id='target' elementtiming='my_div'>A</div>
|
||||
</body>
|
Loading…
Reference in New Issue
Block a user