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

Unified Diff: third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/performance-timeline.https.html

Issue 2610243002: Import wpt@5e1a3b80cea8d36774d2afd78b29a74792e9f15a (Closed)
Patch Set: Rebased Created 3 years, 11 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/imported/wpt/service-workers/service-worker/performance-timeline.https.html
diff --git a/third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/performance-timeline.https.html b/third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/performance-timeline.https.html
index 182076baa9841f1aed31175ff960fa063d6ef0c0..d2ed677e6d011c9cf3aeb22a7bbf8cdb5d5e4b61 100644
--- a/third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/performance-timeline.https.html
+++ b/third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/performance-timeline.https.html
@@ -8,4 +8,45 @@ service_worker_test(
'resources/performance-timeline-worker.js',
'Test Performance Timeline API in Service Worker');
+// The purpose of this test is to verify that service worker overhead
+// is included in the Performance API's timing information.
+promise_test(t => {
+ let script = 'resources/empty-but-slow-worker.js';
+ let scope = 'resources/dummy.txt?slow-sw-timing';
+ let url = new URL(scope, window.location).href;
+ let slowURL = url + '&slow';
+ let frame;
+ return service_worker_unregister_and_register(t, script, scope)
+ .then(reg => wait_for_state(t, reg.installing, 'activated'))
+ .then(_ => with_iframe(scope))
+ .then(f => {
+ frame = f;
+ return Promise.all([
+ // This will get effectively an empty service worker FetchEvent
+ // handler. It should have no additional delay. Note that the
+ // text() call is necessary to complete the response and have the
+ // timings show up in the performance entries.
+ frame.contentWindow.fetch(url).then(r => r && r.text()),
+ // This will cause the service worker to spin for two seconds
+ // in its FetchEvent handler.
+ frame.contentWindow.fetch(slowURL).then(r => r && r.text())
+ ]);
+ })
+ .then(_ => {
+ function elapsed(u) {
+ let entry = frame.contentWindow.performance.getEntriesByName(u);
+ return entry[0] ? entry[0].duration : undefined;
+ }
+ let urlTime = elapsed(url);
+ let slowURLTime = elapsed(slowURL);
+ // Verify the request slowed by the service worker is indeed measured
+ // to be slower. Note, we compare to smaller delay instead of the exact
+ // delay amount to avoid making the test racy under automation.
+ assert_true(slowURLTime >= urlTime + 1500,
+ 'Slow service worker request should measure increased delay.');
+ frame.remove();
+ return service_worker_unregister_and_done(t, scope);
+ })
+}, 'empty service worker fetch event included in performance timings');
+
</script>

Powered by Google App Engine
This is Rietveld 408576698