Index: third_party/WebKit/LayoutTests/http/tests/cache/resources/random-cached-image.php |
diff --git a/third_party/WebKit/LayoutTests/http/tests/cache/resources/random-cached-image.php b/third_party/WebKit/LayoutTests/http/tests/cache/resources/random-cached-image.php |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bd9286b4539e81c6566c1d34c48a0e80c7d28e62 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/http/tests/cache/resources/random-cached-image.php |
@@ -0,0 +1,32 @@ |
+<?php |
+# Returns a cacheable image randomly. |
yhirano
2017/05/12 10:30:43
Isn't this comment (and filename) confusing? The t
hiroshige
2017/05/12 17:14:51
Maybe. I chose the name because this is used simil
|
+ |
+require_once '../../resources/portabilityLayer.php'; |
+ |
+if (!sys_get_temp_dir()) { |
kouhei (in TOK)
2017/05/11 18:22:08
I'm not sure if we are guaranteed to get same temp
|
+ echo "FAIL: No temp dir was returned.\n"; |
+ exit(); |
+} |
+ |
+$id = intval($_GET['id']); |
+$countFilename = sys_get_temp_dir() . "/random-cached-image." . $id . ".tmp"; |
+$count = 0; |
+if (file_exists($countFilename)) { |
+ $count = file_get_contents($countFilename); |
+} |
+$count += 1; |
+file_put_contents($countFilename, $count); |
+ |
+# Images with different dimensions. |
+$imageFilenames = array( |
+ '../../resources/square20.png', |
+ '../../resources/square100.png', |
+ '../../resources/square200.png' |
+); |
+ |
+header("Content-type: image/png"); |
+header("Cache-control: max-age=60000"); |
+header("ETag: 98765"); |
+ |
+readfile($imageFilenames[$count % count($imageFilenames)]); |
+?> |