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

Side by Side Diff: LayoutTests/http/tests/notifications/serviceworkerregistration-get-close.html

Issue 1097383006: Notifications: use testRunner.setPermission() in addition of grantWebNotificationPermission. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@cleanup
Patch Set: fix expectations Created 5 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 unified diff | Download patch
OLDNEW
1 <!doctype html> 1 <!doctype html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Notifications: ServiceWorkerRegistration.getNotifications() and closi ng notifications.</title> 4 <title>Notifications: ServiceWorkerRegistration.getNotifications() and closi ng notifications.</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 <script src="resources/test-helpers.js"></script> 8 <script src="resources/test-helpers.js"></script>
9 </head> 9 </head>
10 <body> 10 <body>
11 <script> 11 <script>
12 // Tests that the getNotifications() function when used in a document retu rns 12 // Tests that the getNotifications() function when used in a document retu rns
13 // an array of the notifications which were previously displayed, and that closing 13 // an array of the notifications which were previously displayed, and that closing
14 // one of them reflects when getting the notifications again. 14 // one of them reflects when getting the notifications again.
15 async_test(function(test) { 15 async_test(function(test) {
16 var scope = 'resources/scope/' + location.pathname, 16 var scope = 'resources/scope/' + location.pathname,
17 script = 'resources/instrumentation-service-worker.js'; 17 script = 'resources/instrumentation-service-worker.js';
18 18
19 testRunner.setPermission('notifications', 'granted', location.origin, location.origin);
19 testRunner.grantWebNotificationPermission(location.origin, true); 20 testRunner.grantWebNotificationPermission(location.origin, true);
20 21
21 var registration = null; 22 var registration = null;
22 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi on(workerInfo) { 23 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi on(workerInfo) {
23 registration = workerInfo.registration; 24 registration = workerInfo.registration;
24 25
25 return registration.showNotification('Hello, world!', { 26 return registration.showNotification('Hello, world!', {
26 body: 'First notification' 27 body: 'First notification'
27 }); 28 });
28 }).then(function() { 29 }).then(function() {
29 return registration.getNotifications(); 30 return registration.getNotifications();
30 }).then(function(notifications) { 31 }).then(function(notifications) {
31 assert_equals(notifications.length, 1); 32 assert_equals(notifications.length, 1);
32 assert_equals(notifications[0].title, 'Hello, world!'); 33 assert_equals(notifications[0].title, 'Hello, world!');
33 34
34 notifications[0].close(); 35 notifications[0].close();
35 36
36 return registration.getNotifications(); 37 return registration.getNotifications();
37 }).then(function(notifications) { 38 }).then(function(notifications) {
38 assert_equals(notifications.length, 0); 39 assert_equals(notifications.length, 0);
39 test.done(); 40 test.done();
40 }).catch(unreached_rejection(test)); 41 }).catch(unreached_rejection(test));
41 42
42 }, 'ServiceWorkerRegistration.getNotifications() reflects closing notifica tions.'); 43 }, 'ServiceWorkerRegistration.getNotifications() reflects closing notifica tions.');
43 </script> 44 </script>
44 </body> 45 </body>
45 </html> 46 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698