summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/element-timing/invisible-images.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/element-timing/invisible-images.html
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
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.html79
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>