2 require_once '../resources/portabilityLayer.php';
4 // This test loads an uncacheable main resource and a cacheable image subresource.
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
7 // request should be sent. The image resource will return 404 if it receives
8 // a second request, which will cause us to FAIL.
9 // See https://bugs.webkit.org/show_bug.cgi?id=38690
10 header('Cache-Control: no-cache, no-store, must-revalidate, max-age=0');
11 header('Pragma: no-cache');
12 header('Expires: ' . gmdate(DATE_RFC1123
, time()-1));
16 <div id
="result"></div
>
18 if (window
.testRunner
) {
19 testRunner
.dumpAsText();
20 testRunner
.waitUntilDone();
23 function logAndFinish(message
)
25 document
.getElementById("result").appendChild(document
.createTextNode(message
));
26 var xhr
= new XMLHttpRequest
;
27 xhr
.open("GET", "../resources/reset-temp-file.php?filename=post.tmp", false);
29 if (window
.testRunner
)
30 testRunner
.notifyDone();
35 if ($_POST["submit"] == "finish") {
36 // The initial load of the image might have been done from the cache. In that case, touch the
37 // state file to indicate a load has already occurred.
38 if (!file_exists(sys_get_temp_dir() . "/post.tmp")) {
40 echo "xhr = new XMLHttpRequest;";
41 echo "xhr.open('GET', '../resources/touch-temp-file.php?filename=post.tmp', false);";
42 echo "xhr.send(null);";
45 // Evict resources in memory cache before re-posting. Otherwise, it will
48 echo "if (window.internals)";
49 echo " window.internals.evictAllResources();";
51 echo "<img src='resources/post-image-to-verify.php' onload=\"logAndFinish('PASS');\" onerror=\"logAndFinish('FAIL');\"></img>";
53 echo "<form action='post-with-cached-subresources.php' method='post'>";
54 echo "<input type='submit' id='submit' name='submit' value='finish'>";
56 echo "<img src='resources/post-image-to-verify.php' onload=\"document.getElementById('submit').click();\" onerror=\"logAndFinish('FAIL on initial load');\"></img>";