Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / HTMLImageElement / image-srcset-react-to-media-changes-when-viewport-downsized.html
blob8d41c53a1c5eee68612ecad28ce5ea3b79ab69ff
1 <!DOCTYPE html>
2 <title>Test that does not load a low quality resource when viewport is downsized</title>
3 <script src="../../../resources/testharness.js"></script>
4 <script src="../../../resources/testharnessreport.js"></script>
5 <iframe style="width: 120px;"></iframe>
6 <script>
7 async_test(function(t) {
8 var iframe = document.querySelector('iframe');
9 var iframeDoc = iframe.contentWindow.document;
11 document.body.offsetTop;
12 iframeDoc.body.innerHTML = '<img id="srcset" srcset="resources/blue_rect.jpg 90w, resources/image-set-4x.png 120w">';
14 img = iframeDoc.getElementById('srcset');
16 var first = true;
17 img.onload = t.step_func(function() {
18 assert_true(first);
19 first = false;
20 assert_equals(img.currentSrc.indexOf("blue_rect.jpg"), -1);
22 iframe.style.width = '90px';
23 requestAnimationFrame(function() {
24 requestAnimationFrame(function() {
25 setTimeout(t.step_func(function() {
26 assert_equals(img.currentSrc.indexOf("blue_rect.jpg"), -1);
27 t.done();
28 }), 0);
29 });
30 });
31 });
32 });
33 </script>