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

Side by Side Diff: LayoutTests/http/tests/notifications/service-worker-show-notification-click.html

Issue 789643003: The Service Worker notificationclick event should carry a notification. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years 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 | Annotate | Revision Log
OLDNEW
1 <!doctype html> 1 <!doctype html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Notifications: ServiceWorkerRegistration.showNotification().</title> 4 <title>Notifications: ServiceWorkerRegistration.showNotification().</title>
5 <script src="../resources/testharness.js"></script> 5 <script src="../resources/testharness.js"></script>
6 <script src="../resources/testharnessreport.js"></script> 6 <script src="../resources/testharnessreport.js"></script>
7 <script src="../serviceworker/resources/test-helpers.js"></script> 7 <script src="../serviceworker/resources/test-helpers.js"></script>
8 </head> 8 </head>
9 <body> 9 <body>
10 <script> 10 <script>
11 // Tests that the showNotification() function resolves a promise, and that the 11 // Tests that the showNotification() function resolves a promise, and that the
12 // notificationclick event gets fired on the Service Worker when we simula te a 12 // notificationclick event gets fired on the Service Worker when we simula te a
13 // click on it. This test requires the test runner. 13 // click on it. This test requires the test runner.
14
14 async_test(function (test) { 15 async_test(function (test) {
15 var scope = 'resources/scope/service-worker-show-notification-click', 16 var scope = 'resources/scope/service-worker-show-notification-click',
16 workerUrl = 'resources/click-forward-service-worker.js'; 17 workerUrl = 'resources/click-forward-service-worker.js';
17 18
18 testRunner.grantWebNotificationPermission(location.origin, true); 19 testRunner.grantWebNotificationPermission(location.origin, true);
19 20
20 var registration = null, 21 var registration = null,
21 messagePort = null; 22 messagePort = null;
22 service_worker_unregister_and_register(test, workerUrl, scope).then(fu nction (swRegistration) { 23 service_worker_unregister_and_register(test, workerUrl, scope).then(fu nction (swRegistration) {
23 registration = swRegistration; 24 registration = swRegistration;
(...skipping 13 matching lines...) Expand all
37 messagePort.start(); 38 messagePort.start();
38 }); 39 });
39 }).then(function () { 40 }).then(function () {
40 assert_inherits(registration, 'showNotification', 'showNotificatio n() must be exposed.'); 41 assert_inherits(registration, 'showNotification', 'showNotificatio n() must be exposed.');
41 return registration.showNotification(scope, { 42 return registration.showNotification(scope, {
42 body: 'Hello, world!', 43 body: 'Hello, world!',
43 icon: '/icon.png' 44 icon: '/icon.png'
44 }); 45 });
45 }).then(function () { 46 }).then(function () {
46 messagePort.addEventListener('message', function(event) { 47 messagePort.addEventListener('message', function(event) {
47 assert_equals(event.data, 'The notification has been clicked o n.'); 48 assert_equals(event.data, 'Clicked on Notification: ' + scope) ;
48 test.done(); 49 service_worker_unregister_and_done(test, scope);
49 }); 50 });
50 51
51 testRunner.simulateWebNotificationClick(scope); 52 testRunner.simulateWebNotificationClick(scope);
52 53
53 }).catch(unreached_rejection(test)); 54 }).catch(unreached_rejection(test));
54 55
55 }, 'Clicking on a notification displayed through showNotification() fires a Service Worker event.'); 56 }, 'Clicking on a notification displayed through showNotification() fires a Service Worker event.');
56 </script> 57 </script>
57 </body> 58 </body>
58 </html> 59 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698