Index: LayoutTests/http/tests/serviceworker/resources/update-worker.php |
diff --git a/LayoutTests/http/tests/serviceworker/resources/update-worker.php b/LayoutTests/http/tests/serviceworker/resources/update-worker.php |
index e7e798f34cf1241820347fb3320e73e326ed2c81..81b1a341fff32be4ab82832929731bc583916e9f 100644 |
--- a/LayoutTests/http/tests/serviceworker/resources/update-worker.php |
+++ b/LayoutTests/http/tests/serviceworker/resources/update-worker.php |
@@ -1,9 +1,27 @@ |
<?php |
-// Force the browser to cache this script. update() should always bypass this |
-// cache and fetch a new version. |
-header('Cache-Control: max-age=86400'); |
+if(!isset($_COOKIE['mode'])) |
+ $mode = 'init'; // For the first fetch, set the mode to 'init'. |
+else |
+ $mode = $_COOKIE['mode']; // $_COOKIE['mode'] is either 'normal' or 'error'. |
+// 'init' or 'normal' mode sets the normal mimetype. |
+if ($mode == 'init' || $mode == 'normal') { |
+ header("Cache-Control: no-cache, must-revalidate"); |
+ header("Pragma: no-cache"); |
nhiroki
2015/08/10 02:32:42
Can you move these cache-control headers to out of
|
+ header('Content-Type:application/javascript'); |
+ if ($mode == 'init') |
+ setcookie('mode', 'normal'); // To make 2nd fetch to work in 'normal' mode. |
+ else |
+ setcookie('mode', 'error'); // To make 3rd fetch to work in 'error' mode. |
+} |
nhiroki
2015/08/10 02:32:42
if ($mode == 'init') {
// ...
} else if ($mode =
jungkees
2015/08/10 03:20:41
Re-organized the blocks as you commented. Looks mu
|
+// 'error' mode sets a disallowed mimetype. |
+else if ($mode == 'error') { |
+ header("Cache-Control: no-cache, must-revalidate"); |
+ header("Pragma: no-cache"); |
+ header('Content-Type:text/html'); |
+ unset($_COOKIE['mode']); |
+ setcookie('mode', '', time() - 3600); // Delete cookie at the end of the test. |
+} |
// Return a different script for each access. |
-header('Content-Type:application/javascript'); |
-echo '// ' . microtime() |
+echo '// ' . microtime(); |
?> |