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

Unified Diff: third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/navigation-preload/resources/resource-timing-worker.js

Issue 2837943006: [WIP] Support PerformanceResourceTiming for Service Worker Navigation Preload (Closed)
Patch Set: clean up Created 3 years, 8 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/navigation-preload/resources/resource-timing-worker.js
diff --git a/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/navigation-preload/resources/resource-timing-worker.js b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/navigation-preload/resources/resource-timing-worker.js
new file mode 100644
index 0000000000000000000000000000000000000000..46af6456aec3d368db3527a8331f4c70f5c84550
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/navigation-preload/resources/resource-timing-worker.js
@@ -0,0 +1,19 @@
+self.addEventListener('activate', event => {
+ event.waitUntil(self.registration.navigationPreload.enable());
+ });
+
+self.addEventListener('fetch', event => {
+ event.respondWith(
+ event.preloadResponse
+ .then(response => {
+ var headers = response.headers;
+ return response.text().then(text =>
+ new Response(
+ JSON.stringify({
+ decodedBodySize: headers.get('X-Decoded-Body-Size'),
+ encodedBodySize: headers.get('X-Encoded-Body-Size'),
+ timingEntries: performance.getEntriesByName(event.request.url)
+ }),
+ {headers: {'Content-Type': 'text/html'}}));
+ }));
+ });

Powered by Google App Engine
This is Rietveld 408576698