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

Unified Diff: LayoutTests/http/tests/serviceworker/resources/update-worker.php

Issue 1268663003: Service Worker: Make ServiceWorkerRegistration.update() return a promise. (Blink Layout 3/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove output set before setcookie. Created 5 years, 4 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: 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();
?>
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/update.html » ('j') | LayoutTests/http/tests/serviceworker/update.html » ('J')

Powered by Google App Engine
This is Rietveld 408576698