OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Ensure preloaded resources are not downloaded again when used</title> |
2 <script src="/resources/testharness.js"></script> | 3 <script src="/resources/testharness.js"></script> |
3 <script src="/resources/testharnessreport.js"></script> | 4 <script src="/resources/testharnessreport.js"></script> |
| 5 <link rel=preload href="resources/square.png?pipe=trickle(d1)" as=image> |
4 <script> | 6 <script> |
5 var t = async_test('Makes sure that preloaded resources are not downloaded a
gain when used'); | 7 var link = document.getElementsByTagName("link")[0] |
| 8 assert_equals(link.as, "image"); |
| 9 link.addEventListener("load", () => { |
| 10 assert_equals(performance.getEntriesByType("resource").length, 3) |
| 11 var img = document.createElement("img"); |
| 12 img.src = "resources/square.png?pipe=trickle(d1)"; |
| 13 img.onload = () => { |
| 14 assert_equals(performance.getEntriesByType("resource").length, 3); |
| 15 done(); |
| 16 }; |
| 17 document.body.appendChild(img); |
| 18 }); |
6 </script> | 19 </script> |
7 <div id=result></div> | 20 <body> |
8 <link rel=preload href="resources/square.png" as=image> | |
9 <script> | |
10 window.addEventListener("load", t.step_func(function() { | |
11 t.step_timeout(function() { | |
12 document.getElementById("result").innerHTML = "<image src='resources
/square.png'>"; | |
13 t.step_timeout(function() { | |
14 assert_equals(performance.getEntriesByType("resource").length, 3
); | |
15 t.done(); | |
16 }, 1000); | |
17 }, 1000); | |
18 })); | |
19 </script> | |
OLD | NEW |