diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/html/semantics/embedded-content/the-img-element/not-rendered-below-viewport-image-loading-lazy.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/semantics/embedded-content/the-img-element/not-rendered-below-viewport-image-loading-lazy.html')
-rw-r--r-- | testing/web-platform/tests/html/semantics/embedded-content/the-img-element/not-rendered-below-viewport-image-loading-lazy.html | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/not-rendered-below-viewport-image-loading-lazy.html b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/not-rendered-below-viewport-image-loading-lazy.html new file mode 100644 index 0000000000..401771565a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/not-rendered-below-viewport-image-loading-lazy.html @@ -0,0 +1,63 @@ +<!DOCTYPE html> +<head> + <title>Below-viewport loading=lazy not-rendered images should never load, + even when scrolled into view</title> + <link rel="author" title="Rob Buis" href="mailto:rbuis@igalia.com"> + <link rel="author" title="Dom Farolino" href="mailto:dom@chromium.org"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="../resources/common.js"></script> +</head> + +<body> + <!-- These images must not attempt to load when scrolled into the + viewport --> + <img id="display_none" style="display:none;" src="resources/image.png?not-rendered-2" loading="lazy" + onload="display_none_img.resolve();" onerror="display_none_img.reject();"> + <img id="attribute_hidden" hidden src="resources/image.png?not-rendered-3" loading="lazy" + onload="attribute_hidden_img.resolve();" onerror="attribute_hidden_img.reject();"> + <img id="js_display_none" src="resources/image.png?not-rendered-4" loading="lazy" + onload="js_display_none_img.resolve();" onerror="js_display_none_img.reject();"> + <script> + document.getElementById("js_display_none").style = 'display:none;'; + </script> + + <!-- Later in the test we'll scroll to this div, instead of the above images, + since due to them not being rendered, they cannot be scrolled to --> + <div id="rendered_div"></div> +</body> + +<script> + const display_none_img = new ElementLoadPromise("display_none"); + const attribute_hidden_img = new ElementLoadPromise("attribute_hidden"); + const js_display_none_img = new ElementLoadPromise("js_display_none"); + const rendered_div_element = document.querySelector('#rendered_div'); + + async_test(t => { + window.addEventListener("load", t.step_func(() => { + rendered_div.scrollIntoView(); + })); + + const unreached_not_rendered_img_func = + t.unreached_func("The not-rendered below-viewport loading=lazy images " + + "should not attempt to load."); + + display_none_img.promise + .then(unreached_not_rendered_img_func) + .catch(unreached_not_rendered_img_func); + + attribute_hidden_img.promise + .then(unreached_not_rendered_img_func) + .catch(unreached_not_rendered_img_func); + + js_display_none_img.promise + .then(unreached_not_rendered_img_func) + .catch(unreached_not_rendered_img_func); + + // If none of the above images load after being scrolled to within the below + // timeout, the test passes. + t.step_timeout(t.done, 2000); + }, "Below-viewport loading=lazy not-rendered images should never load, " + + "even when scrolled into view"); +</script> + |