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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/update-worker.php

Issue 2904063003: Upstream service worker "update" tests to WPT (Closed)
Patch Set: Move Chromium-specific test Created 3 years, 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 <?php
2 if(!isset($_COOKIE['mode']))
3 $mode = 'init'; // Set mode to 'init' for initial fetch.
4 else
5 $mode = $_COOKIE['mode']; // $_COOKIE['mode'] is either 'normal' or 'error'.
6
7 // no-cache itself to ensure the user agent finds a new version for each update.
8 header("Cache-Control: no-cache, must-revalidate");
9 header("Pragma: no-cache");
10
11 $extra_body = '';
12
13 if ($mode == 'init') {
14 // Set a normal mimetype.
15 // Set cookie value to 'normal' so the next fetch will work in 'normal' mode.
16 header('Content-Type:application/javascript');
17 setcookie('mode', 'normal');
18 } else if ($mode == 'normal') {
19 // Set a normal mimetype.
20 // Set cookie value to 'error' so the next fetch will work in 'error' mode.
21 header('Content-Type:application/javascript');
22 setcookie('mode', 'error');
23 } else if ($mode == 'error') {
24 // Set a disallowed mimetype.
25 // Set cookie value to 'syntax-error' so the next fetch will work in 'syntax-e rror' mode.
26 header('Content-Type:text/html');
27 setcookie('mode', 'syntax-error');
28 } else if ($mode == 'syntax-error') {
29 // Set cookie value to 'throw-install' so the next fetch will work in 'throw-i nstall' mode.
30 header('Content-Type:application/javascript');
31 setcookie('mode', 'throw-install');
32 $extra_body = 'badsyntax(isbad;';
33 } else if ($mode == 'throw-install') {
34 // Unset and delete cookie to clean up the test setting.
35 header('Content-Type:application/javascript');
36 unset($_COOKIE['mode']);
37 setcookie('mode', '', time() - 3600);
38 $extra_body = "addEventListener('install', function(e) { throw new Error('boom '); });";
39 }
40 // Return a different script for each access.
41 echo '/* ', microtime(), ' */ ', $extra_body;
42 ?>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698