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

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: comment 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/images/force-reload.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..89d3d5645a50099e4129b31f158317c612e98726
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/cache/resources/random-cached-image.php
@@ -0,0 +1,42 @@
+<?php
+# The script name is "random-cached-image" because this is expected to return
+# different images on every (re)load to test caching, which is similar to
+# other random-cached* scripts.
+# However, this actually returns an image from a small number of predefined
+# images in sequence,
+# because it is hard to generate random (PNG/JPEG/etc.) images from scratch.
+
+require_once '../../resources/portabilityLayer.php';
+
+if (!sys_get_temp_dir()) {
+ echo "FAIL: No temp dir was returned.\n";
+ exit();
+}
+
+$id = $_GET['id'];
+if (filter_var($id, FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=>"/^[a-z0-9\-]+$/"))) === false) {
+ echo "FAIL: invalid id.\n";
+ exit();
+}
+
+$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)]);
+?>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/images/force-reload.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698