Bug 1572780 [wpt PR 18345] - [ElementTiming] Fix background image loadTime, a=testonly
authorNicolás Peña Moreno <npm@chromium.org>
Wed, 14 Aug 2019 10:57:39 +0000
changeset 488126 7982193408a52625ab69541709d2bca93d9e6d64
parent 488125 bae1cdaf20c87243d9da5bd5c633ad9175aa59bd
child 488127 6b6dcecddad69c4c0663cf65a403a93a3f3d7a37
push id36435
push usercbrindusan@mozilla.com
push dateThu, 15 Aug 2019 09:46:49 +0000
treeherdermozilla-central@0db07ff50ab5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1572780, 18345, 879270, 986891, 1745497, 686176
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
testing/web-platform/tests/element-timing/first-letter-background.html
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/element-timing/first-letter-background.html
@@ -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>