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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/fetch-event-within-sw-worker.js

Issue 2695813009: Import wpt@503f5b5f78ec4e87d144f78609f363f0ed0ea8db (Closed)
Patch Set: Skip some tests Created 3 years, 10 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 skipWaiting();
2
3 addEventListener('fetch', event => {
4 const url = new URL(event.request.url);
5
6 if (url.origin != location.origin) return;
7
8 if (url.pathname.endsWith('/dummy.txt')) {
9 event.respondWith(new Response('intercepted'));
10 return;
11 }
12
13 if (url.pathname.endsWith('/dummy.txt-inner-fetch')) {
14 event.respondWith(fetch('dummy.txt'));
15 return;
16 }
17
18 if (url.pathname.endsWith('/dummy.txt-inner-cache')) {
19 event.respondWith(
20 caches.open('test-inner-cache').then(cache =>
21 cache.add('dummy.txt').then(() => cache.match('dummy.txt'))
22 )
23 );
24 return;
25 }
26
27 if (url.pathname.endsWith('/show-notification')) {
28 // Copy the currect search string onto the icon url
29 const iconURL = new URL('notification_icon.py', location);
30 iconURL.search = url.search;
31
32 event.respondWith(
33 registration.showNotification('test', {
34 icon: iconURL
35 }).then(() => registration.getNotifications()).then(notifications => {
36 for (const n of notifications) n.close();
37 return new Response('done');
38 })
39 );
40 return;
41 }
42
43 if (url.pathname.endsWith('/notification_icon.py')) {
44 new BroadcastChannel('icon-request').postMessage('yay');
45 event.respondWith(new Response('done'));
46 return;
47 }
48 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698