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

Side by Side 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../../../resources/js-test.js"></script> 2 <script src="../../../resources/js-test.js"></script>
3 <script src="resources/currentSrcHelper.js"></script> 3 <script src="resources/currentSrcHelper.js"></script>
4 <script> 4 <script>
5 if (window.testRunner) 5 if (window.testRunner)
6 testRunner.dumpAsText(); 6 testRunner.dumpAsText();
7 7
8 addEventListener("load", function() { 8 addEventListener("load", function() {
9 shouldBeTrue('document.getElementById("simple").currentSrc.indexOf("file ://") == 0'); 9 shouldBeTrue('document.getElementById("simple").currentSrc.indexOf("file ://") == 0');
10 shouldBe('document.getElementById("simple").clientWidth', '(window.inner Width)'); 10 shouldBe('document.getElementById("simple").clientWidth', '(window.inner Width)');
11 shouldBe('currentSrcFileName("simple")', '"image-set-2x.png"'); 11 shouldBe('currentSrcFileNameNoParams("simple")', '"image-set-2x.png"');
12 shouldBe('document.getElementById("small_sizes").clientWidth', '300'); 12 shouldBe('document.getElementById("small_sizes").clientWidth', '300');
13 shouldBe('currentSrcFileName("small_sizes")', '"image-set-1x.png"'); 13 shouldBe('currentSrcFileNameNoParams("small_sizes")', '"image-set-1x.png "');
14 shouldBe('document.getElementById("sizes_x_descriptors").clientWidth', ' 400'); 14 shouldBe('document.getElementById("sizes_x_descriptors").clientWidth', ' 400');
15 shouldBe('currentSrcFileName("sizes_x_descriptors")', '"image-set-1x.png "'); 15 shouldBe('currentSrcFileNameNoParams("sizes_x_descriptors")', '"image-se t-1x.png"');
16 shouldBe('document.getElementById("sizes_src").clientWidth', '400'); 16 shouldBe('document.getElementById("sizes_src").clientWidth', '400');
17 shouldBe('currentSrcFileName("sizes_src")', '"image-set-1x.png"'); 17 shouldBe('currentSrcFileNameNoParams("sizes_src")', '"image-set-1x.png"' );
18 shouldBe('document.getElementById("default_sizes").clientWidth', 'window .innerWidth'); 18 shouldBe('document.getElementById("default_sizes").clientWidth', 'window .innerWidth');
19 shouldBe('currentSrcFileName("default_sizes")', '"image-set-2x.png"'); 19 shouldBe('currentSrcFileNameNoParams("default_sizes")', '"image-set-2x.p ng"');
20 shouldBe('document.getElementById("invalid_length").clientWidth', 'windo w.innerWidth'); 20 shouldBe('document.getElementById("invalid_length").clientWidth', 'windo w.innerWidth');
21 shouldBe('currentSrcFileName("invalid_length")', '"image-set-2x.png"'); 21 shouldBe('currentSrcFileNameNoParams("invalid_length")', '"image-set-2x. png"');
22 shouldBeCloseTo('document.getElementById("src_and_w").clientWidth', 700, 1/64); 22 shouldBeCloseTo('document.getElementById("src_and_w").clientWidth', 700, 1/64);
23 shouldBe('currentSrcFileName("src_and_w")', '"image-set-4x.png"'); 23 shouldBe('currentSrcFileNameNoParams("src_and_w")', '"image-set-4x.png"' );
24 shouldBeCloseTo('document.getElementById("src_and_w2").clientWidth', 700 , 1/64); 24 shouldBeCloseTo('document.getElementById("src_and_w2").clientWidth', 700 , 1/64);
25 shouldBe('currentSrcFileName("src_and_w2")', '"image-set-1x.png"'); 25 shouldBe('currentSrcFileNameNoParams("src_and_w2")', '"image-set-1x.png" ');
26 shouldBeCloseTo('document.getElementById("x_and_w").clientWidth', 700, 1 /64); 26 shouldBeCloseTo('document.getElementById("x_and_w").clientWidth', 700, 1 /64);
27 shouldBe('currentSrcFileName("x_and_w")', '"image-set-4x.png"'); 27 shouldBe('currentSrcFileNameNoParams("x_and_w")', '"image-set-4x.png"');
28 shouldBe('document.getElementById("x_and_w2").clientWidth', '400'); 28 shouldBe('document.getElementById("x_and_w2").clientWidth', '400');
29 shouldBe('currentSrcFileName("x_and_w2")', '"image-set-2x.png"'); 29 shouldBe('currentSrcFileNameNoParams("x_and_w2")', '"image-set-2x.png"') ;
30 shouldBe('document.getElementById("x_and_w3").clientWidth', '400'); 30 shouldBe('document.getElementById("x_and_w3").clientWidth', '400');
31 shouldBe('currentSrcFileName("x_and_w3")', '"image-set-2x.png"'); 31 shouldBe('currentSrcFileNameNoParams("x_and_w3")', '"image-set-2x.png"') ;
32 shouldBe('document.getElementById("half_size").clientWidth', '(window.in nerWidth/2)'); 32 shouldBe('document.getElementById("half_size").clientWidth', '(window.in nerWidth/2)');
33 shouldBe('currentSrcFileName("half_size")', '"image-set-2x.png"'); 33 shouldBe('currentSrcFileNameNoParams("half_size")', '"image-set-2x.png"' );
34 shouldBe('document.getElementById("infitisimal_sizes").clientWidth', '(w indow.innerWidth/100)'); 34 shouldBe('document.getElementById("infitisimal_sizes").clientWidth', '(w indow.innerWidth/100)');
35 shouldBe('currentSrcFileName("infitisimal_sizes")', '"image-set-2x.png"' ); 35 shouldBe('currentSrcFileNameNoParams("infitisimal_sizes")', '"image-set- 2x.png"');
36 shouldBe('currentSrcFileName("fraction")', '"data:,a"'); 36 shouldBe('currentSrcFileNameNoParams("fraction")', '"data:,a"');
37 shouldBe('document.getElementById("seen_lowest_before").clientWidth', '1 600');
38 shouldBe('currentSrcFileNameNoParams("seen_lowest_before")', '"image-set -4x.png"');
39 shouldBe('document.getElementById("seen_highest_before").clientWidth', ' 800');
40 shouldBe('currentSrcFileNameNoParams("seen_highest_before")', '"image-se t-4x.png"');
37 }, false); 41 }, false);
38 </script> 42 </script>
39 <img id="simple" src="" sizes="(max-width: 300px) 400px, 800px" srcset="../../hi dpi/resources/image-set-1x.png 400w, ../../hidpi/resources/image-set-2x.png 800w "> 43 <img id="simple" src="" sizes="(max-width: 300px) 400px, 800px" srcset="../../hi dpi/resources/image-set-1x.png?1 400w, ../../hidpi/resources/image-set-2x.png?1 800w">
40 <img id="small_sizes" src="" sizes="300px" srcset="../../hidpi/resources/image-s et-1x.png 400w, ../../hidpi/resources/image-set-2x.png 800w"> 44 <img id="small_sizes" src="" sizes="300px" srcset="../../hidpi/resources/image-s et-1x.png?2 400w, ../../hidpi/resources/image-set-2x.png?2 800w">
41 <!-- 'sizes' has no impact on 'x' or 'src' resources --> 45 <!-- 'sizes' has no impact on 'x' or 'src' resources -->
42 <img id="sizes_x_descriptors" src="" sizes="50vw" srcset="../../hidpi/resources/ image-set-1x.png 1x, ../../hidpi/resources/image-set-2x.png 2x"> 46 <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">
43 <img id="sizes_src" src="../../hidpi/resources/image-set-1x.png" sizes="50vw"> 47 <img id="sizes_src" src="../../hidpi/resources/image-set-1x.png?4" sizes="50vw">
44 <!-- Missing sizes or an invalid one, give a source size of 100vw --> 48 <!-- Missing sizes or an invalid one, give a source size of 100vw -->
45 <img id="default_sizes" src="" srcset="../../hidpi/resources/image-set-1x.png 40 0w, ../../hidpi/resources/image-set-2x.png 800w, resources/image-set-4x.png 1600 w"> 49 <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">
46 <img id="invalid_length" src="" sizes="(max-width: 300px) 400w, 800w" srcset=".. /../hidpi/resources/image-set-1x.png 400w, ../../hidpi/resources/image-set-2x.pn g 800w"> 50 <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">
47 <!-- Make sure that the img src is not picked when 'w' is present --> 51 <!-- Make sure that the img src is not picked when 'w' is present -->
48 <img id="src_and_w" src="../../hidpi/resources/image-set-1x.png" sizes="700px" s rcset="resources/image-set-4x.png 1600w"> 52 <img id="src_and_w" src="../../hidpi/resources/image-set-1x.png?7" sizes="700px" srcset="resources/image-set-4x.png?7 1600w">
49 <img id="src_and_w2" src="../../hidpi/resources/image-set-2x.png" sizes="700px" srcset="../../hidpi/resources/image-set-1x.png 400w"> 53 <img id="src_and_w2" src="../../hidpi/resources/image-set-2x.png?8" sizes="700px " srcset="../../hidpi/resources/image-set-1x.png?8 400w">
50 <img id="x_and_w" sizes="700px" srcset="../../hidpi/resources/image-set-1x.png 0 .4x, resources/image-set-4x.png 1600w"> 54 <img id="x_and_w" sizes="700px" srcset="../../hidpi/resources/image-set-1x.png?9 0.4x, resources/image-set-4x.png?9 1600w">
51 <!-- The 'x' resource should be picked, and 'sizes' have no impact on its intris ic size --> 55 <!-- The 'x' resource should be picked, and 'sizes' have no impact on its intris ic size -->
52 <img id="x_and_w2" sizes="700px" srcset="../../hidpi/resources/image-set-2x.png 2x, resources/image-set-4x.png 16000w"> 56 <img id="x_and_w2" sizes="700px" srcset="../../hidpi/resources/image-set-2x.png? 10 2x, resources/image-set-4x.png?10 16000w">
53 <img id="x_and_w3" sizes="700px" srcset="resources/image-set-4x.png 16000w, ../. ./hidpi/resources/image-set-2x.png 2x"> 57 <img id="x_and_w3" sizes="700px" srcset="resources/image-set-4x.png?11 16000w, . ./../hidpi/resources/image-set-2x.png?11 2x">
54 <!-- The intrinsic size should be identical to the 'sizes' value --> 58 <!-- The intrinsic size should be identical to the 'sizes' value -->
55 <img id="half_size" sizes="50vw" srcset="../../hidpi/resources/image-set-2x.png 800w, resources/image-set-4x.png 16000w"> 59 <img id="half_size" sizes="50vw" srcset="../../hidpi/resources/image-set-2x.png? 12 800w, resources/image-set-4x.png?12 16000w">
56 <img id="infitisimal_sizes" sizes="1vw" srcset="../../hidpi/resources/image-set- 2x.png 800w, resources/image-set-4x.png 16000w"> 60 <img id="infitisimal_sizes" sizes="1vw" srcset="../../hidpi/resources/image-set- 2x.png?13 800w, resources/image-set-4x.png?13 16000w">
57 <img id="fraction" sizes="0.5px" srcset="data:,a 1w, data:,b 2x"> 61 <img id="fraction" sizes="0.5px" srcset="data:,a 1w, data:,b 2x">
62 <!-- Testing with cached resources. If a higher resolution cached resource is av ailable, it should be picked -->
63 <img id="seen_lowest_before" sizes="1600px" srcset="../../hidpi/resources/image- set-2x.png?1 800w, resources/image-set-4x.png?1 1600w">
64 <img id="seen_highest_before" sizes="800px" srcset="../../hidpi/resources/image- set-2x.png?7 800w, resources/image-set-4x.png?7 1600w">
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698