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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/notifications/serviceworkerregistration-service-worker-fetch-resources.html

Issue 1909043003: Tests that notification resource requests are handled by onfetch. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@NotificationTestsUsePromises
Patch Set: Created 4 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/http/tests/notifications/serviceworkerregistration-service-worker-fetch-resources.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/notifications/serviceworkerregistration-service-worker-fetch-resources.html b/third_party/WebKit/LayoutTests/http/tests/notifications/serviceworkerregistration-service-worker-fetch-resources.html
new file mode 100644
index 0000000000000000000000000000000000000000..41992aec4f78df9fc6ce5805ecaf15bdbfbe1b5c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/notifications/serviceworkerregistration-service-worker-fetch-resources.html
@@ -0,0 +1,46 @@
+<!doctype html>
+<html>
+ <head>
+ <title>Notifications: the fetch handler handles the request for the icon.</title>
+ <script src="../resources/testharness.js"></script>
+ <script src="../resources/testharnessreport.js"></script>
+ <script src="../serviceworker/resources/test-helpers.js"></script>
+ <script src="resources/test-helpers.js"></script>
+ </head>
+ <body>
+ <script>
+ // Tests that the request for the notification icon is handled by the fetch event handler.
+
+ async_test(test => {
+ var scope = './';
+ var script = 'instrumentation-service-worker.js';
+ var port;
+ var registration;
+ var iconPath = '/resources/square20.png';
+
+ testRunner.setPermission('notifications', 'granted', location.origin, location.origin);
+
+ getActiveServiceWorkerWithMessagePort(test, script, scope).then(info => {
+ port = info.port;
+ registration = info.registration;
+ assert_true(!!navigator.serviceWorker.controller, 'The page must be controlled.');
+ // (1) Display a persistent notification from a service worker context.
+ return sendCommand(port, {
+ command: 'show',
+ title: 'Title',
+ options: { icon: iconPath }
+ });
+ }).then(data => {
+ assert_true(data.success);
+ return sendCommand(port, { command: 'get-fetch-history' });
+ }).then(data => {
+ // (2) Verify that the icon request passed through the fetch event handler.
+ // TODO(mvanouwerkerk): The fetch should go through the service worker.
Peter Beverloo 2016/04/21 17:27:00 ++bug reference?
Michael van Ouwerkerk 2016/04/22 13:24:09 Done.
+ assert_equals(data.fetchHistory.length, 0);
+ test.done();
+ }).catch(unreached_rejection(test));
+
+ }, 'The request for the notification icon is handled by the fetch event handler.');
+ </script>
+ </body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698