5 <script src=
"resources/srcset-helper.js"></script>
6 <script src=
"../../resources/js-test.js"></script>
9 var img
= document
.getElementById("foo");
10 // The below should not trigger the load of the blue image according to the spec.
11 img
.src
= "resources/blue-100-px-square.png"
12 img
.srcset
= "resources/blue-100-px-square.png 1x, resources/green-400-px-square.png 2x";
15 addEventListener("DOMContentLoaded", function() {
16 if (window
.testRunner
&& sessionStorage
.pageReloaded
) {
17 // Have to make sure to only load the src after the reload.
18 // Otherwise, we'd request and cache the 1x URL while the
19 // scale factor is 1, and after we reload we find the URL
20 // in the cache and reuse it, leading us to dump two requests.
22 } else if (!window
.testRunner
) {
23 // This else exists purely to allow running the test manually.
27 addEventListener("load", function() {
28 shouldBeTrue('document.getElementById("foo").clientWidth==200');
34 <div>This test passes if this img tag below is a green square when the scale factor is
2.
35 It ensures that attributes can be changed dynamically from javascript, and that only the correct resource is loaded.
</div>