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

Unified Diff: LayoutTests/fast/dom/HTMLImageElement/image-srcset-react-to-media-changes-when-image-not-changed.html

Issue 369423002: Have srcset respond to viewport changes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Got rid of assert Created 6 years, 5 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-srcset-react-to-media-changes-when-image-not-changed.html
diff --git a/LayoutTests/fast/dom/HTMLImageElement/image-srcset-react-to-media-changes-when-image-not-changed.html b/LayoutTests/fast/dom/HTMLImageElement/image-srcset-react-to-media-changes-when-image-not-changed.html
new file mode 100644
index 0000000000000000000000000000000000000000..026d5f343156bc02d0c1058989773d9e53f9b0ad
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLImageElement/image-srcset-react-to-media-changes-when-image-not-changed.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<script src="../../../resources/js-test.js"></script>
+<script>
+var jsTestIsAsync = true;
+var img;
+
+onload = function() {
+ var iframe = document.getElementById('frame');
+ var iframeDoc = iframe.contentWindow.document;
+
+ iframeDoc.body.innerHTML = '<img id="srcset" srcset="resources/blue_rect.jpg 75w, resources/image-set-4x.png 120w">';
+
+ img = iframeDoc.getElementById('srcset');
+
+ var first = true;
+ img.onload = function() {
+ if (first) {
+ first = false;
+ shouldNotBe('img.currentSrc.indexOf("blue_rect")', '-1');
+ shouldBe('img.width', '70');
+ iframe.style.width = '75px';
+ // Make sure that once 2 RAFs have passed, the image is set to the right dimensions.
+ requestAnimationFrame(function() {
+ requestAnimationFrame(function() {
+ setTimeout(function() {
+ shouldNotBe('img.currentSrc.indexOf("blue_rect")', '-1');
+ shouldBe('img.width', '75');
+ finishJSTest();
+ }, 0);
+ });
+ });
+ }
+ };
+ img.onerror = function() {
+ testFailed('Image should have loaded');
+ };
+}
+</script>
+
+<iframe id="frame" style="width: 70px;"></iframe>

Powered by Google App Engine
This is Rietveld 408576698