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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/fetch-event-within-sw-worker.js
diff --git a/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/fetch-event-within-sw-worker.js b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/fetch-event-within-sw-worker.js
new file mode 100644
index 0000000000000000000000000000000000000000..f3180d776c5b02ed2cf202c298fabfd1e8f8ea11
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/fetch-event-within-sw-worker.js
@@ -0,0 +1,48 @@
+skipWaiting();
+
+addEventListener('fetch', event => {
+ const url = new URL(event.request.url);
+
+ if (url.origin != location.origin) return;
+
+ if (url.pathname.endsWith('/dummy.txt')) {
+ event.respondWith(new Response('intercepted'));
+ return;
+ }
+
+ if (url.pathname.endsWith('/dummy.txt-inner-fetch')) {
+ event.respondWith(fetch('dummy.txt'));
+ return;
+ }
+
+ if (url.pathname.endsWith('/dummy.txt-inner-cache')) {
+ event.respondWith(
+ caches.open('test-inner-cache').then(cache =>
+ cache.add('dummy.txt').then(() => cache.match('dummy.txt'))
+ )
+ );
+ return;
+ }
+
+ if (url.pathname.endsWith('/show-notification')) {
+ // Copy the currect search string onto the icon url
+ const iconURL = new URL('notification_icon.py', location);
+ iconURL.search = url.search;
+
+ event.respondWith(
+ registration.showNotification('test', {
+ icon: iconURL
+ }).then(() => registration.getNotifications()).then(notifications => {
+ for (const n of notifications) n.close();
+ return new Response('done');
+ })
+ );
+ return;
+ }
+
+ if (url.pathname.endsWith('/notification_icon.py')) {
+ new BroadcastChannel('icon-request').postMessage('yay');
+ event.respondWith(new Response('done'));
+ return;
+ }
+});

Powered by Google App Engine
This is Rietveld 408576698