OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script> | 3 <script> |
4 </script> | 4 </script> |
5 <script src="resources/srcset-helper.js"></script> | 5 <script src="resources/srcset-helper.js"></script> |
6 <script src="../../resources/js-test.js"></script> | 6 <script src="../../resources/js-test.js"></script> |
7 <script> | 7 <script> |
8 function updateSrc() { | 8 function updateSrc() { |
9 var img = document.getElementById("foo"); | 9 var img = document.getElementById("foo"); |
10 // The below should not trigger the load of the blue image according to
the spec. | 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" | 11 img.src = "resources/blue-100-px-square.png" |
12 img.srcset = "resources/blue-100-px-square.png 1x, resources/green-400-p
x-square.png 2x"; | 12 img.srcset = "resources/blue-100-px-square.png 1x, resources/green-400-p
x-square.png 2x"; |
13 } | 13 } |
14 | 14 |
15 addEventListener("DOMContentLoaded", function() { | 15 addEventListener("DOMContentLoaded", function() { |
16 if (window.testRunner && sessionStorage.pageReloaded) { | 16 if (window.testRunner && sessionStorage.pageReloaded) { |
17 testRunner.dumpResourceRequestCallbacks(); | |
18 // Have to make sure to only load the src after the reload. | 17 // Have to make sure to only load the src after the reload. |
19 // Otherwise, we'd request and cache the 1x URL while the | 18 // Otherwise, we'd request and cache the 1x URL while the |
20 // scale factor is 1, and after we reload we find the URL | 19 // scale factor is 1, and after we reload we find the URL |
21 // in the cache and reuse it, leading us to dump two requests. | 20 // in the cache and reuse it, leading us to dump two requests. |
22 updateSrc(); | 21 updateSrc(); |
23 } else if (!window.testRunner) { | 22 } else if (!window.testRunner) { |
24 // This else exists purely to allow running the test manually. | 23 // This else exists purely to allow running the test manually. |
25 updateSrc(); | 24 updateSrc(); |
26 } | 25 } |
27 }, false); | 26 }, false); |
28 addEventListener("load", function() { | 27 addEventListener("load", function() { |
29 shouldBeTrue('document.getElementById("foo").clientWidth==200'); | 28 shouldBeTrue('document.getElementById("foo").clientWidth==200'); |
30 }, false); | 29 }, false); |
31 </script> | 30 </script> |
32 </head> | 31 </head> |
33 | 32 |
34 <body id="body"> | 33 <body id="body"> |
35 <div>This test passes if this img tag below is a green square when the scale
factor is 2. | 34 <div>This test passes if this img tag below is a green square when the scale
factor is 2. |
36 It ensures that attributes can be changed dynamically from javascript, and
that only the correct resource is loaded.</div> | 35 It ensures that attributes can be changed dynamically from javascript, and
that only the correct resource is loaded.</div> |
37 <img id="foo"> | 36 <img id="foo"> |
38 </body> | 37 </body> |
39 </html> | 38 </html> |
OLD | NEW |