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

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: Rebase. 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
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/update.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1f2ebbbc180bf81c7f83f52baff6c511aa3f7b20 100644
--- a/LayoutTests/http/tests/serviceworker/resources/update-worker.php
+++ b/LayoutTests/http/tests/serviceworker/resources/update-worker.php
@@ -1,9 +1,30 @@
<?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'; // Set mode to 'init' for initial fetch.
+else
+ $mode = $_COOKIE['mode']; // $_COOKIE['mode'] is either 'normal' or 'error'.
+// no-cache itself to ensure the user agent finds a new version for each update.
+header("Cache-Control: no-cache, must-revalidate");
+header("Pragma: no-cache");
+
+if ($mode == 'init') {
+ // Set a normal mimetype.
+ // Set cookie value to 'normal' so the next fetch will work in 'normal' mode.
+ header('Content-Type:application/javascript');
+ setcookie('mode', 'normal');
+} else if ($mode == 'normal') {
+ // Set a normal mimetype.
+ // Set cookie value to 'error' so the next fetch will work in 'error' mode.
+ header('Content-Type:application/javascript');
+ setcookie('mode', 'error');
+} else if ($mode == 'error') {
+ // Set a disallowed mimetype.
+ // Unset and delete cookie to clean up the test setting.
+ header('Content-Type:text/html');
+ unset($_COOKIE['mode']);
+ setcookie('mode', '', time() - 3600);
+}
// 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698