diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/paint-timing/fcp-only/fcp-document-opacity-image.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/paint-timing/fcp-only/fcp-document-opacity-image.html')
-rw-r--r-- | testing/web-platform/tests/paint-timing/fcp-only/fcp-document-opacity-image.html | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/testing/web-platform/tests/paint-timing/fcp-only/fcp-document-opacity-image.html b/testing/web-platform/tests/paint-timing/fcp-only/fcp-document-opacity-image.html new file mode 100644 index 0000000000..e407f68708 --- /dev/null +++ b/testing/web-platform/tests/paint-timing/fcp-only/fcp-document-opacity-image.html @@ -0,0 +1,49 @@ +<!DOCTYPE html> +<html class="hide"> +<head> +<title>Performance Paint Timing Test: Image FCP due to the documentElement's opacity</title> +<style> + html { + will-change: opacity; + } + .hide { + opacity: 0; + } +</style> +</head> +<body> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="../resources/utils.js"></script> +<div id="main"></div> +<script> +// Load the image, add it to the DOM and make sure it's decoded. +const load_image = () => { + const img = document.createElement("img"); + img.src = "../resources/circles.png"; + document.body.appendChild(img); + return img.decode(); +}; + +const change_opacity = () => { + document.documentElement.className = ""; +} + +promise_test(async t => { + assert_implements(window.PerformancePaintTiming, "Paint Timing isn't supported."); + await load_image(); + await assertNoFirstContentfulPaint(t); + change_opacity(); + await waitForAnimationFrames(3); + const fcp_entries = performance.getEntriesByName('first-contentful-paint'); + assert_equals(fcp_entries.length, 1, "Got an FCP entry"); + const lcp_entries = await new Promise(resolve => {new PerformanceObserver((list) => resolve(list.getEntries())).observe({type: 'largest-contentful-paint', buffered: true})}); + assert_equals(lcp_entries.length, 1, "Got an LCP entry"); + // TODO: Rewrite this assertion after the FCP and LCP precision alignment CL is landed. Currently FCP start time has a higher precision than that of LCP. That means, even if the two are intrinsically the same, FCP.startTime will be larger as it has more fractional digits. + isLess = fcp_entries[0].startTime < lcp_entries[0].startTime; + isEqualToMicrosecond = Math.abs(fcp_entries[0].startTime - lcp_entries[0].startTime) < 0.001; + assert_true(isLess || isEqualToMicrosecond, "FCP should be smaller than FCP."); +}, "Test that FCP after opacity change is not a larger value than LCP"); +</script> +</body> +</html> |