| OLD | NEW |
| 1 <?php | 1 <?php |
| 2 require_once '../resources/portabilityLayer.php'; | 2 require_once '../resources/portabilityLayer.php'; |
| 3 | 3 |
| 4 // This test loads an uncacheable main resource and a cacheable image subresourc
e. | 4 // This test loads an uncacheable main resource and a cacheable image subresourc
e. |
| 5 // We request this page as a GET, then reload this page with a POST. | 5 // We request this page as a GET, then reload this page with a POST. |
| 6 // On the post request, the image should be loaded from the cache and no HTTP | 6 // On the post request, the image should be loaded from the cache and no HTTP |
| 7 // request should be sent. The image resource will return 404 if it receives | 7 // request should be sent. The image resource will return 404 if it receives |
| 8 // a second request, which will cause us to FAIL. | 8 // a second request, which will cause us to FAIL. |
| 9 // See https://bugs.webkit.org/show_bug.cgi?id=38690 | 9 // See https://bugs.webkit.org/show_bug.cgi?id=38690 |
| 10 header('Cache-Control: no-cache, no-store, must-revalidate, max-age=0'); | 10 header('Cache-Control: no-cache, no-store, must-revalidate, max-age=0'); |
| 11 header('Pragma: no-cache'); | 11 header('Pragma: no-cache'); |
| 12 header('Expires: ' . gmdate(DATE_RFC1123, time()-1)); | 12 header('Expires: ' . gmdate(DATE_RFC1123, time()-1)); |
| 13 ?> | 13 ?> |
| 14 <html> | 14 <html> |
| 15 <body> | 15 <body> |
| 16 <div id="result"></div> | 16 <div id="result"></div> |
| 17 <script> | 17 <script> |
| 18 if (window.testRunner) { | 18 if (window.testRunner) { |
| 19 testRunner.dumpAsText(); | 19 testRunner.dumpAsText(); |
| 20 testRunner.waitUntilDone(); | 20 testRunner.waitUntilDone(); |
| 21 } | 21 } |
| 22 | 22 |
| 23 function logAndFinish(message) | 23 function logAndFinish(message) |
| 24 { | 24 { |
| 25 document.getElementById("result").appendChild(document.createTextNode(messag
e)); | 25 document.getElementById("result").appendChild(document.createTextNode(messag
e)); |
| 26 var xhr = new XMLHttpRequest; | 26 var xhr = new XMLHttpRequest; |
| 27 xhr.open("GET", "../resources/reset-temp-file.php?filename=post.tmp", false)
; | 27 xhr.open("GET", "../resources/reset-temp-file.php?filename=post-with-cached-
subresources.tmp", false); |
| 28 xhr.send(null); | 28 xhr.send(null); |
| 29 if (window.testRunner) | 29 if (window.testRunner) |
| 30 testRunner.notifyDone(); | 30 testRunner.notifyDone(); |
| 31 } | 31 } |
| 32 </script> | 32 </script> |
| 33 <?php | 33 <?php |
| 34 clearstatcache(); | 34 clearstatcache(); |
| 35 if ($_POST["submit"] == "finish") { | 35 if ($_POST["submit"] == "finish") { |
| 36 // The initial load of the image might have been done from the cache. In tha
t case, touch the | 36 // The initial load of the image might have been done from the cache. In tha
t case, touch the |
| 37 // state file to indicate a load has already occurred. | 37 // state file to indicate a load has already occurred. |
| 38 if (!file_exists(sys_get_temp_dir() . "/post.tmp")) { | 38 if (!file_exists(sys_get_temp_dir() . "/post-with-cached-subresources.tmp"))
{ |
| 39 echo "<script>"; | 39 echo "<script>"; |
| 40 echo "xhr = new XMLHttpRequest;"; | 40 echo "xhr = new XMLHttpRequest;"; |
| 41 echo "xhr.open('GET', '../resources/touch-temp-file.php?filename=post.tm
p', false);"; | 41 echo "xhr.open('GET', '../resources/touch-temp-file.php?filename=post-wi
th-cached-subresources.tmp', false);"; |
| 42 echo "xhr.send(null);"; | 42 echo "xhr.send(null);"; |
| 43 echo "</script>"; | 43 echo "</script>"; |
| 44 } | 44 } |
| 45 // Evict resources in memory cache before re-posting. Otherwise, it will | 45 // Evict resources in memory cache before re-posting. Otherwise, it will |
| 46 // always PASS. | 46 // always PASS. |
| 47 echo "<script>"; | 47 echo "<script>"; |
| 48 echo "if (window.internals)"; | 48 echo "if (window.internals)"; |
| 49 echo " window.internals.evictAllResources();"; | 49 echo " window.internals.evictAllResources();"; |
| 50 echo "</script>"; | 50 echo "</script>"; |
| 51 echo "<img src='resources/post-image-to-verify.php' onload=\"logAndFinish('P
ASS');\" onerror=\"logAndFinish('FAIL');\"></img>"; | 51 echo "<img src='resources/post-image-to-verify.php?filename=post-with-cached
-subresources.tmp' onload=\"logAndFinish('PASS');\" onerror=\"logAndFinish('FAIL
');\"></img>"; |
| 52 } else { | 52 } else { |
| 53 echo "<form action='post-with-cached-subresources.php' method='post'>"; | 53 echo "<form action='post-with-cached-subresources.php?filename=post-with-cac
hed-subresources.tmp' method='post'>"; |
| 54 echo "<input type='submit' id='submit' name='submit' value='finish'>"; | 54 echo "<input type='submit' id='submit' name='submit' value='finish'>"; |
| 55 echo "</form>"; | 55 echo "</form>"; |
| 56 echo "<img src='resources/post-image-to-verify.php' onload=\"document.getEle
mentById('submit').click();\" onerror=\"logAndFinish('FAIL on initial load');\">
</img>"; | 56 echo "<img src='resources/post-image-to-verify.php?filename=post-with-cached
-subresources.tmp' onload=\"document.getElementById('submit').click();\" onerror
=\"logAndFinish('FAIL on initial load');\"></img>"; |
| 57 } | 57 } |
| 58 ?> | 58 ?> |
| 59 </body> | 59 </body> |
| 60 </html> | 60 </html> |
| OLD | NEW |