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/preload/link-header-preload-imagesrcset.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/preload/link-header-preload-imagesrcset.html')
-rw-r--r-- | testing/web-platform/tests/preload/link-header-preload-imagesrcset.html | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/testing/web-platform/tests/preload/link-header-preload-imagesrcset.html b/testing/web-platform/tests/preload/link-header-preload-imagesrcset.html new file mode 100644 index 0000000000..65c8c061ad --- /dev/null +++ b/testing/web-platform/tests/preload/link-header-preload-imagesrcset.html @@ -0,0 +1,56 @@ +<!DOCTYPE html> +<title>Makes sure that Link headers preload images with imagesrcset/imagesizes attributes.</title> +<link rel="help" href="https://github.com/w3c/preload/issues/120"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/preload/resources/preload_helper.js"></script> +<body> +<script> + setup({single_test: true}); + + var iterations = 0; + var expectation = new Array(10).fill(0); + if (window.devicePixelRatio < 1.5) { + expectation[0] = expectation[5] = expectation[8] = 1; + } else if (window.devicePixelRatio >= 1.5) { + expectation[1] = expectation[6] = expectation[9] = 1; + } + + function check_finished() { + if (numberOfResourceTimingEntries('resources/square.png?from-header&1x') == expectation[0] && + numberOfResourceTimingEntries('resources/square.png?from-header&2x') == expectation[1] && + numberOfResourceTimingEntries('resources/square.png?from-header&3x') == expectation[2] && + numberOfResourceTimingEntries('resources/square.png?from-header&base') == expectation[3] && + numberOfResourceTimingEntries('resources/square.png?from-header&200') == expectation[4] && + numberOfResourceTimingEntries('resources/square.png?from-header&400') == expectation[5] && + numberOfResourceTimingEntries('resources/square.png?from-header&800') == expectation[6] && + numberOfResourceTimingEntries('resources/square.png?from-header&150') == expectation[7] && + numberOfResourceTimingEntries('resources/square.png?from-header&300') == expectation[8] && + numberOfResourceTimingEntries('resources/square.png?from-header&600') == expectation[9]) { + done(); + } + iterations++; + if (iterations == 10) { + // At least one is expected to fail, but this should give details to the exact failure(s). + verifyNumberOfResourceTimingEntries('resources/square.png?from-header&1x', expectation[0]); + verifyNumberOfResourceTimingEntries('resources/square.png?from-header&2x', expectation[1]); + verifyNumberOfResourceTimingEntries('resources/square.png?from-header&3x', expectation[2]); + verifyNumberOfResourceTimingEntries('resources/square.png?from-header&base', expectation[3]); + verifyNumberOfResourceTimingEntries('resources/square.png?from-header&200', expectation[4]); + verifyNumberOfResourceTimingEntries('resources/square.png?from-header&400', expectation[5]); + verifyNumberOfResourceTimingEntries('resources/square.png?from-header&800', expectation[6]); + verifyNumberOfResourceTimingEntries('resources/square.png?from-header&150', expectation[7]); + verifyNumberOfResourceTimingEntries('resources/square.png?from-header&300', expectation[8]); + verifyNumberOfResourceTimingEntries('resources/square.png?from-header&600', expectation[9]); + done(); + } else { + step_timeout(check_finished, 500); + } + } + + window.addEventListener("load", function() { + verifyPreloadAndRTSupport(); + step_timeout(check_finished, 500); + }); +</script> +</body> |