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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/resources/update-recovery-worker.py

Issue 2415873002: Import w3c tests for the service workers (Closed)
Patch Set: Rebase Created 4 years, 2 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 def main(request, response):
2 # Set mode to 'init' for initial fetch.
3 mode = 'init'
4 if 'update-recovery-mode' in request.cookies:
5 mode = request.cookies['update-recovery-mode'].value
6
7 # no-cache itself to ensure the user agent finds a new version for each upda te.
8 headers = [('Cache-Control', 'no-cache, must-revalidate'),
9 ('Pragma', 'no-cache')]
10
11 extra_body = ''
12
13 if mode == 'init':
14 # Install a bad service worker that will break the controlled
15 # document navigation.
16 response.set_cookie('update-recovery-mode', 'bad')
17 extra_body = "addEventListener('fetch', function(e) { e.respondWith(Prom ise.reject()); });"
18 elif mode == 'bad':
19 # When the update tries to pull the script again, update to
20 # a worker service worker that does not break document
21 # navigation. Serve the same script from then on.
22 response.delete_cookie('update-recovery-mode')
23
24 headers.append(('Content-Type', 'application/javascript'))
25 return headers, '%s' % (extra_body)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698