chromium/third_party/blink/web_tests/fast/dom/HTMLImageElement/image-srcset-react-to-media-changes-when-viewport-downsized.html

<!DOCTYPE html>
<title>Test that does not load a low quality resource when viewport is downsized</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<iframe style="width: 120px;"></iframe>
<script>
async_test(function(t) {
    var iframe = document.querySelector('iframe');
    var iframeDoc = iframe.contentWindow.document;

    document.body.offsetTop;
    iframeDoc.body.innerHTML = '<img id="srcset" srcset="resources/blue_rect.jpg 90w, resources/image-set-4x.png 120w">';

    img = iframeDoc.getElementById('srcset');

    var first = true;
    img.onload = t.step_func(function() {
        assert_true(first);
        first = false;
        assert_equals(img.currentSrc.indexOf("blue_rect.jpg"), -1);

        iframe.style.width = '90px';
        requestAnimationFrame(function() {
            requestAnimationFrame(function() {
                setTimeout(t.step_func(function() {
                    assert_equals(img.currentSrc.indexOf("blue_rect.jpg"), -1);
                    t.done();
                }), 0);
            });
        });
    });
});
</script>