Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/cache/resources/random-cached-image.php

Issue 2874073003: Add layout tests for ImageLoader::UpdateFromElement(kUpdateForcedReload) (Closed)
Patch Set: fix Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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)]);
+?>

Powered by Google App Engine
This is Rietveld 408576698