Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Unified Diff: LayoutTests/fast/dom/HTMLImageElement/image-sizes-1x.html

Issue 674923004: Avoid srcset resource download when higher density resource is in cache. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed layout tests and added some. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/dom/HTMLImageElement/image-sizes-1x.html
diff --git a/LayoutTests/fast/dom/HTMLImageElement/image-sizes-1x.html b/LayoutTests/fast/dom/HTMLImageElement/image-sizes-1x.html
index 575fba1493428529629a0e19f19352ca7776d271..2f73e8e00e256c6f2582d505faba829d05567505 100644
--- a/LayoutTests/fast/dom/HTMLImageElement/image-sizes-1x.html
+++ b/LayoutTests/fast/dom/HTMLImageElement/image-sizes-1x.html
@@ -8,50 +8,57 @@
addEventListener("load", function() {
shouldBeTrue('document.getElementById("simple").currentSrc.indexOf("file://") == 0');
shouldBe('document.getElementById("simple").clientWidth', '(window.innerWidth)');
- shouldBe('currentSrcFileName("simple")', '"image-set-2x.png"');
+ shouldBe('currentSrcFileNameNoParams("simple")', '"image-set-2x.png"');
shouldBe('document.getElementById("small_sizes").clientWidth', '300');
- shouldBe('currentSrcFileName("small_sizes")', '"image-set-1x.png"');
+ shouldBe('currentSrcFileNameNoParams("small_sizes")', '"image-set-1x.png"');
shouldBe('document.getElementById("sizes_x_descriptors").clientWidth', '400');
- shouldBe('currentSrcFileName("sizes_x_descriptors")', '"image-set-1x.png"');
+ shouldBe('currentSrcFileNameNoParams("sizes_x_descriptors")', '"image-set-1x.png"');
shouldBe('document.getElementById("sizes_src").clientWidth', '400');
- shouldBe('currentSrcFileName("sizes_src")', '"image-set-1x.png"');
+ shouldBe('currentSrcFileNameNoParams("sizes_src")', '"image-set-1x.png"');
shouldBe('document.getElementById("default_sizes").clientWidth', 'window.innerWidth');
- shouldBe('currentSrcFileName("default_sizes")', '"image-set-2x.png"');
+ shouldBe('currentSrcFileNameNoParams("default_sizes")', '"image-set-2x.png"');
shouldBe('document.getElementById("invalid_length").clientWidth', 'window.innerWidth');
- shouldBe('currentSrcFileName("invalid_length")', '"image-set-2x.png"');
+ shouldBe('currentSrcFileNameNoParams("invalid_length")', '"image-set-2x.png"');
shouldBeCloseTo('document.getElementById("src_and_w").clientWidth', 700, 1/64);
- shouldBe('currentSrcFileName("src_and_w")', '"image-set-4x.png"');
+ shouldBe('currentSrcFileNameNoParams("src_and_w")', '"image-set-4x.png"');
shouldBeCloseTo('document.getElementById("src_and_w2").clientWidth', 700, 1/64);
- shouldBe('currentSrcFileName("src_and_w2")', '"image-set-1x.png"');
+ shouldBe('currentSrcFileNameNoParams("src_and_w2")', '"image-set-1x.png"');
shouldBeCloseTo('document.getElementById("x_and_w").clientWidth', 700, 1/64);
- shouldBe('currentSrcFileName("x_and_w")', '"image-set-4x.png"');
+ shouldBe('currentSrcFileNameNoParams("x_and_w")', '"image-set-4x.png"');
shouldBe('document.getElementById("x_and_w2").clientWidth', '400');
- shouldBe('currentSrcFileName("x_and_w2")', '"image-set-2x.png"');
+ shouldBe('currentSrcFileNameNoParams("x_and_w2")', '"image-set-2x.png"');
shouldBe('document.getElementById("x_and_w3").clientWidth', '400');
- shouldBe('currentSrcFileName("x_and_w3")', '"image-set-2x.png"');
+ shouldBe('currentSrcFileNameNoParams("x_and_w3")', '"image-set-2x.png"');
shouldBe('document.getElementById("half_size").clientWidth', '(window.innerWidth/2)');
- shouldBe('currentSrcFileName("half_size")', '"image-set-2x.png"');
+ shouldBe('currentSrcFileNameNoParams("half_size")', '"image-set-2x.png"');
shouldBe('document.getElementById("infitisimal_sizes").clientWidth', '(window.innerWidth/100)');
- shouldBe('currentSrcFileName("infitisimal_sizes")', '"image-set-2x.png"');
- shouldBe('currentSrcFileName("fraction")', '"data:,a"');
+ shouldBe('currentSrcFileNameNoParams("infitisimal_sizes")', '"image-set-2x.png"');
+ shouldBe('currentSrcFileNameNoParams("fraction")', '"data:,a"');
+ shouldBe('document.getElementById("seen_lowest_before").clientWidth', '1600');
+ shouldBe('currentSrcFileNameNoParams("seen_lowest_before")', '"image-set-4x.png"');
+ shouldBe('document.getElementById("seen_highest_before").clientWidth', '800');
+ shouldBe('currentSrcFileNameNoParams("seen_highest_before")', '"image-set-4x.png"');
}, false);
</script>
-<img id="simple" src="" sizes="(max-width: 300px) 400px, 800px" srcset="../../hidpi/resources/image-set-1x.png 400w, ../../hidpi/resources/image-set-2x.png 800w">
-<img id="small_sizes" src="" sizes="300px" srcset="../../hidpi/resources/image-set-1x.png 400w, ../../hidpi/resources/image-set-2x.png 800w">
+<img id="simple" src="" sizes="(max-width: 300px) 400px, 800px" srcset="../../hidpi/resources/image-set-1x.png?1 400w, ../../hidpi/resources/image-set-2x.png?1 800w">
+<img id="small_sizes" src="" sizes="300px" srcset="../../hidpi/resources/image-set-1x.png?2 400w, ../../hidpi/resources/image-set-2x.png?2 800w">
<!-- 'sizes' has no impact on 'x' or 'src' resources -->
-<img id="sizes_x_descriptors" src="" sizes="50vw" srcset="../../hidpi/resources/image-set-1x.png 1x, ../../hidpi/resources/image-set-2x.png 2x">
-<img id="sizes_src" src="../../hidpi/resources/image-set-1x.png" sizes="50vw">
+<img id="sizes_x_descriptors" src="" sizes="50vw" srcset="../../hidpi/resources/image-set-1x.png?3 1x, ../../hidpi/resources/image-set-2x.png?3 2x">
+<img id="sizes_src" src="../../hidpi/resources/image-set-1x.png?4" sizes="50vw">
<!-- Missing sizes or an invalid one, give a source size of 100vw -->
-<img id="default_sizes" src="" srcset="../../hidpi/resources/image-set-1x.png 400w, ../../hidpi/resources/image-set-2x.png 800w, resources/image-set-4x.png 1600w">
-<img id="invalid_length" src="" sizes="(max-width: 300px) 400w, 800w" srcset="../../hidpi/resources/image-set-1x.png 400w, ../../hidpi/resources/image-set-2x.png 800w">
+<img id="default_sizes" src="" srcset="../../hidpi/resources/image-set-1x.png?5 400w, ../../hidpi/resources/image-set-2x.png?5 800w, resources/image-set-4x.png?5 1600w">
+<img id="invalid_length" src="" sizes="(max-width: 300px) 400w, 800w" srcset="../../hidpi/resources/image-set-1x.png?6 400w, ../../hidpi/resources/image-set-2x.png?6 800w">
<!-- Make sure that the img src is not picked when 'w' is present -->
-<img id="src_and_w" src="../../hidpi/resources/image-set-1x.png" sizes="700px" srcset="resources/image-set-4x.png 1600w">
-<img id="src_and_w2" src="../../hidpi/resources/image-set-2x.png" sizes="700px" srcset="../../hidpi/resources/image-set-1x.png 400w">
-<img id="x_and_w" sizes="700px" srcset="../../hidpi/resources/image-set-1x.png 0.4x, resources/image-set-4x.png 1600w">
+<img id="src_and_w" src="../../hidpi/resources/image-set-1x.png?7" sizes="700px" srcset="resources/image-set-4x.png?7 1600w">
+<img id="src_and_w2" src="../../hidpi/resources/image-set-2x.png?8" sizes="700px" srcset="../../hidpi/resources/image-set-1x.png?8 400w">
+<img id="x_and_w" sizes="700px" srcset="../../hidpi/resources/image-set-1x.png?9 0.4x, resources/image-set-4x.png?9 1600w">
<!-- The 'x' resource should be picked, and 'sizes' have no impact on its intrisic size -->
-<img id="x_and_w2" sizes="700px" srcset="../../hidpi/resources/image-set-2x.png 2x, resources/image-set-4x.png 16000w">
-<img id="x_and_w3" sizes="700px" srcset="resources/image-set-4x.png 16000w, ../../hidpi/resources/image-set-2x.png 2x">
+<img id="x_and_w2" sizes="700px" srcset="../../hidpi/resources/image-set-2x.png?10 2x, resources/image-set-4x.png?10 16000w">
+<img id="x_and_w3" sizes="700px" srcset="resources/image-set-4x.png?11 16000w, ../../hidpi/resources/image-set-2x.png?11 2x">
<!-- The intrinsic size should be identical to the 'sizes' value -->
-<img id="half_size" sizes="50vw" srcset="../../hidpi/resources/image-set-2x.png 800w, resources/image-set-4x.png 16000w">
-<img id="infitisimal_sizes" sizes="1vw" srcset="../../hidpi/resources/image-set-2x.png 800w, resources/image-set-4x.png 16000w">
+<img id="half_size" sizes="50vw" srcset="../../hidpi/resources/image-set-2x.png?12 800w, resources/image-set-4x.png?12 16000w">
+<img id="infitisimal_sizes" sizes="1vw" srcset="../../hidpi/resources/image-set-2x.png?13 800w, resources/image-set-4x.png?13 16000w">
<img id="fraction" sizes="0.5px" srcset="data:,a 1w, data:,b 2x">
+<!-- Testing with cached resources. If a higher resolution cached resource is available, it should be picked -->
+<img id="seen_lowest_before" sizes="1600px" srcset="../../hidpi/resources/image-set-2x.png?1 800w, resources/image-set-4x.png?1 1600w">
+<img id="seen_highest_before" sizes="800px" srcset="../../hidpi/resources/image-set-2x.png?7 800w, resources/image-set-4x.png?7 1600w">

Powered by Google App Engine
This is Rietveld 408576698