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

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

Issue 236713005: Use SizesAttributeParser to get the right srcset resource (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@sizes_parser8
Patch Set: Rebase Created 6 years, 8 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
new file mode 100644
index 0000000000000000000000000000000000000000..92f5e1a5decff5475119ea00631c5ac78e19599c
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLImageElement/image-sizes-1x.html
@@ -0,0 +1,52 @@
+<html>
+<head>
+<script src="../../../resources/js-test.js"></script>
+<script>
+ if (window.testRunner)
+ testRunner.dumpAsText();
+
+ addEventListener("load", function() {
+ shouldBeTrue('document.getElementById("simple").clientWidth==(window.innerWidth)');
eseidel 2014/04/19 04:54:19 You wan "shouldBe()" then it will print nice thing
+ shouldBeTrue('document.getElementById("simple").currentSrc=="resources/image-set-2x.png"');
+ shouldBeTrue('document.getElementById("sizes_x_descriptors").clientWidth==400');
+ shouldBeTrue('document.getElementById("sizes_x_descriptors").currentSrc=="resources/image-set-1x.png"');
+ shouldBeTrue('document.getElementById("sizes_src").clientWidth==400');
+ shouldBeTrue('document.getElementById("sizes_src").currentSrc=="resources/image-set-1x.png"');
+ shouldBeTrue('document.getElementById("default_sizes").clientWidth==window.innerWidth');
+ shouldBeTrue('document.getElementById("default_sizes").currentSrc=="resources/image-set-2x.png"');
+ shouldBeTrue('document.getElementById("invalid_length").clientWidth==window.innerWidth');
+ shouldBeTrue('document.getElementById("invalid_length").currentSrc=="resources/image-set-2x.png"');
+ shouldBeTrue('document.getElementById("src_and_w").clientWidth==700');
+ shouldBeTrue('document.getElementById("src_and_w").currentSrc=="resources/image-set-4x.png"');
+ shouldBeTrue('document.getElementById("x_and_w").clientWidth==700');
+ shouldBeTrue('document.getElementById("x_and_w").currentSrc=="resources/image-set-4x.png"');
+ shouldBeTrue('document.getElementById("x_and_w2").clientWidth==400');
+ shouldBeTrue('document.getElementById("x_and_w2").currentSrc=="resources/image-set-2x.png"');
+ shouldBeTrue('document.getElementById("x_and_w3").clientWidth==400');
+ shouldBeTrue('document.getElementById("x_and_w3").currentSrc=="resources/image-set-2x.png"');
+ shouldBeTrue('document.getElementById("half_size").clientWidth==(window.innerWidth/2)');
+ shouldBeTrue('document.getElementById("half_size").currentSrc=="resources/image-set-2x.png"');
+ shouldBeTrue('document.getElementById("infitisimal_sizes").clientWidth==(window.innerWidth/100)');
+ shouldBeTrue('document.getElementById("infitisimal_sizes").currentSrc=="resources/image-set-2x.png"');
+ }, false);
+</script>
+</head>
+
+<body id="body">
+ <img id="simple" src="" sizes="(max-width: 300px) 400px, 800px" srcset="resources/image-set-1x.png 400w, resources/image-set-2x.png 800w">
+ <!-- 'sizes' has no imapct on 'x' or 'src' resources -->
+ <img id="sizes_x_descriptors" src="" sizes="50vw" srcset="resources/image-set-1x.png 1x, resources/image-set-2x.png 2x">
+ <img id="sizes_src" src="resources/image-set-1x.png" sizes="50vw">
+ <!-- Missing sizes or an invalid one, give a source size of 100vw -->
+ <img id="default_sizes" src="" srcset="resources/image-set-1x.png 400w, resources/image-set-2x.png 800w, resources/image-set-4x.png 1600w">
+ <img id="invalid_length" src="" sizes="(max-width: 300px) 400w, 800w" srcset="resources/image-set-1x.png 400w, resources/image-set-2x.png 800w">
+ <img id="src_and_w" src="resources/image-set-1x.png" sizes="700px" srcset="resources/image-set-4x.png 1600w">
+ <img id="x_and_w" sizes="700px" srcset="resources/image-set-1x.png 0.5x, resources/image-set-4x.png 1600w">
+ <!-- The 'x' resource should be picked, and 'sizes' have no impact on its intrisic size -->
+ <img id="x_and_w2" sizes="700px" srcset="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, resources/image-set-2x.png 2x">
+ <!-- The intrinsic size should be identical to the 'sizes' value -->
+ <img id="half_size" sizes="50vw" srcset="resources/image-set-2x.png 800w, resources/image-set-4x.png 16000w">
+ <img id="infitisimal_sizes" sizes="1vw" srcset="resources/image-set-2x.png 800w, resources/image-set-4x.png 16000w">
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698