| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <meta charset="utf-8"> | 2 <meta charset="utf-8"> |
| 3 <body></body> | 3 <body></body> |
| 4 <script> | 4 <script> |
| 5 function runTest() { | 5 function runTest() { |
| 6 var l = document.createElement('link'); | 6 var l = document.createElement('link'); |
| 7 // Use link rel=preload to try to get the browser to cache the opaque |
| 8 // response. |
| 7 l.setAttribute('rel', 'preload'); | 9 l.setAttribute('rel', 'preload'); |
| 8 l.setAttribute('href', 'opaque-response'); | 10 l.setAttribute('href', 'opaque-response'); |
| 9 l.onload = function() { | 11 l.onload = function() { |
| 10 xhr = new XMLHttpRequest; | 12 xhr = new XMLHttpRequest; |
| 11 xhr.withCredentials = true; | 13 xhr.withCredentials = true; |
| 12 xhr.open('GET', 'opaque-response'); | 14 xhr.open('GET', 'opaque-response'); |
| 13 // opaque-response returns an opaque response from serviceworker and thus | 15 // opaque-response returns an opaque response from serviceworker and thus |
| 14 // the XHR must fail because it is not no-cors request. | 16 // the XHR must fail because it is not no-cors request. |
| 15 // Particularly, the XHR must not reuse preloaded the opaque response on | 17 // Particularly, the XHR must not reuse the opaque response from the |
| 16 // MemoryCache. | 18 // preload request. |
| 17 xhr.onerror = function() { | 19 xhr.onerror = function() { |
| 18 parent.done('PASS'); | 20 parent.done('PASS'); |
| 19 }; | 21 }; |
| 20 xhr.onload = function() { | 22 xhr.onload = function() { |
| 21 parent.done('FAIL: ' + xhr.responseText); | 23 parent.done('FAIL: ' + xhr.responseText); |
| 22 }; | 24 }; |
| 23 xhr.send(); | 25 xhr.send(); |
| 24 }; | 26 }; |
| 25 l.onerror = function() { | 27 l.onerror = function() { |
| 26 parent.done('FAIL: preload failed unexpectedly'); | 28 parent.done('FAIL: preload failed unexpectedly'); |
| 27 }; | 29 }; |
| 28 document.body.appendChild(l); | 30 document.body.appendChild(l); |
| 29 } | 31 } |
| 30 </script> | 32 </script> |
| 31 <body onload="setTimeout(runTest, 100)"></body> | 33 <body onload="setTimeout(runTest, 100)"></body> |
| OLD | NEW |