OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../resources/testharness.js"></script> | 2 <script src="../resources/testharness.js"></script> |
3 <script src="../resources/testharnessreport.js"></script> | 3 <script src="../resources/testharnessreport.js"></script> |
4 <body> | 4 <body> |
5 <script> | 5 <script> |
6 var t = async_test('Test that preloaded resources get evicted from MemoryCache')
; | 6 var t = async_test('Test that preloaded resources get evicted from MemoryCache')
; |
7 var action; | 7 var action; |
8 var loadTimestampWithXHR = t.step_func(function() { | 8 var loadTimestampWithXHR = t.step_func(function() { |
9 var xhr = new XMLHttpRequest; | 9 var xhr = new XMLHttpRequest; |
10 xhr.withCredentials = true; | 10 xhr.withCredentials = true; |
11 xhr.open("GET", "resources/timestamp.php"); | 11 xhr.open("GET", "resources/timestamp.php"); |
12 xhr.send(); | 12 xhr.send(); |
13 xhr.onload = function() { | 13 xhr.onload = function() { |
14 action(xhr.responseText); | 14 action(xhr.responseText); |
15 }; | 15 }; |
16 }); | 16 }); |
17 | 17 |
18 var loadTimestampWithLink = t.step_func(function() { | 18 var loadTimestampWithLink = t.step_func(function() { |
19 var l = document.createElement('link'); | 19 var l = document.createElement('link'); |
20 l.setAttribute('rel', 'preload'); | 20 l.setAttribute('rel', 'preload'); |
21 l.setAttribute('href', "resources/timestamp.php"); | 21 l.setAttribute('href', "resources/timestamp.php"); |
| 22 l.setAttribute('as', 'fetch'); |
22 l.onload = loadTimestampWithXHR; | 23 l.onload = loadTimestampWithXHR; |
23 document.body.appendChild(l); | 24 document.body.appendChild(l); |
24 }); | 25 }); |
25 | 26 |
26 var writeAndReload = t.step_func(function(text) { | 27 var writeAndReload = t.step_func(function(text) { |
27 sessionStorage.timestamp = text; | 28 sessionStorage.timestamp = text; |
28 document.location.reload(true); | 29 document.location.reload(true); |
29 }); | 30 }); |
30 | 31 |
31 var compare = t.step_func(function(text) { | 32 var compare = t.step_func(function(text) { |
32 assert_true(sessionStorage.timestamp != text); | 33 assert_true(sessionStorage.timestamp != text); |
33 t.done(); | 34 t.done(); |
34 }); | 35 }); |
35 | 36 |
36 if (!sessionStorage.timestamp) { | 37 if (!sessionStorage.timestamp) { |
37 action = writeAndReload; | 38 action = writeAndReload; |
38 } else { | 39 } else { |
39 action = compare; | 40 action = compare; |
40 } | 41 } |
41 loadTimestampWithLink(); | 42 loadTimestampWithLink(); |
42 </script> | 43 </script> |
OLD | NEW |