diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/element-timing/invisible-images.html | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/element-timing/invisible-images.html')
-rw-r--r-- | testing/web-platform/tests/element-timing/invisible-images.html | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/testing/web-platform/tests/element-timing/invisible-images.html b/testing/web-platform/tests/element-timing/invisible-images.html new file mode 100644 index 0000000000..ffde3ce2f6 --- /dev/null +++ b/testing/web-platform/tests/element-timing/invisible-images.html @@ -0,0 +1,79 @@ +<!DOCTYPE HTML> +<meta charset=utf-8> +<title>Element Timing: invisible images are not observable</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<style> + #opacity0 { + opacity: 0; + } + #visibilityHidden { + visibility: hidden; + } + #displayNone { + display: none; + } +</style> +<script> + async_test(function (t) { + assert_implements(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented"); + const observer = new PerformanceObserver( + t.step_func_done((entries) => { + // The image should not have caused an entry, so fail test. + assert_unreached('Should not have received an entry! Received one with identifier ' + + entries.getEntries()[0].identifier); + }) + ); + observer.observe({entryTypes: ['element']}); + // We add the images during onload to be sure that the observer is registered + // in time for it to observe the element timing. + window.onload = () => { + const img = document.createElement('img'); + img.src = 'resources/square100.png'; + img.setAttribute('elementtiming', 'my_image'); + img.setAttribute('id', 'opacity0'); + document.body.appendChild(img); + + const img2 = document.createElement('img'); + img2.src = 'resources/square20.png'; + img2.setAttribute('elementtiming', 'my_image2'); + img2.setAttribute('id', 'visibilityHidden'); + document.body.appendChild(img2); + + const img3 = document.createElement('img'); + img3.src = 'resources/circle.svg'; + img3.setAttribute('elementtiming', 'my_image3'); + img3.setAttribute('id', 'displayNone'); + document.body.appendChild(img3); + + const div = document.createElement('div'); + div.setAttribute('id', 'opacity0'); + const img4 = document.createElement('img'); + img4.src = '/images/blue.png'; + img4.setAttribute('elementtiming', 'my_image4'); + div.appendChild(img4); + document.body.appendChild(div); + + const div2 = document.createElement('div'); + div2.setAttribute('id', 'visibilityHidden'); + const img5 = document.createElement('img'); + img5.src = '/images/blue.png'; + img5.setAttribute('elementtiming', 'my_image5'); + div.appendChild(img5); + document.body.appendChild(div2); + + const div3 = document.createElement('div'); + div3.setAttribute('id', 'displayNone'); + const img6 = document.createElement('img'); + img6.src = '/images/blue.png'; + img6.setAttribute('elementtiming', 'my_image6'); + div.appendChild(img6); + document.body.appendChild(div3); + // Images have been added but should not cause entries to be dispatched. + // Wait for 500ms and end test, ensuring no entry was created. + t.step_timeout(() => { + t.done(); + }, 500); + }; + }, 'Images with opacity: 0, visibility: hidden, or display: none are not observable.'); +</script> |