Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <script src="../resources/testharness.js"></script> | |
| 3 <script src="../resources/testharnessreport.js"></script> | |
| 4 <body> | |
| 5 <script> | |
| 6 var t = async_test('Test that preloaded non-cacheable resources get reused even after onload'); | |
|
Charlie Harrison
2016/08/04 18:10:25
Seems like the file name should be "cache_reuse" r
Yoav Weiss
2016/08/04 20:26:14
renamed to memcache_reuse_of_non_cacheable_preload
| |
| 7 var action; | |
| 8 | |
| 9 var test = t.step_func(function() { | |
| 10 var entries = performance.getEntriesByType("resource"); | |
| 11 var resources = 0; | |
| 12 for (var i = 0; i < entries.length; ++i) { | |
| 13 if (entries[i].name.indexOf("timestamp") != -1) | |
| 14 ++resources; | |
| 15 } | |
| 16 assert_equals(resources, 1); | |
| 17 t.done(); | |
| 18 }); | |
| 19 | |
| 20 var loadTimestampWithXHR = t.step_func(function() { | |
| 21 var xhr = new XMLHttpRequest; | |
| 22 xhr.withCredentials = true; | |
| 23 xhr.open("GET", "resources/timestamp.php"); | |
| 24 xhr.send(); | |
| 25 xhr.onload = t.step_func(function() { | |
| 26 setTimeout(test, 0); | |
| 27 }); | |
| 28 }); | |
| 29 | |
| 30 var loadTimestampWithLink = (function() { | |
| 31 var l = document.createElement('link'); | |
| 32 l.setAttribute('rel', 'preload'); | |
| 33 l.setAttribute('href', "resources/timestamp.php"); | |
| 34 l.onload = loadTimestampWithXHR; | |
| 35 document.body.appendChild(l); | |
| 36 }); | |
| 37 | |
| 38 loadTimestampWithLink(); | |
| 39 </script> | |
| OLD | NEW |