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/preload/link-header-preload-imagesrcset.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/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> |