| OLD | NEW |
| 1 <!doctype html> | 1 <!doctype html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Notifications: ServiceWorkerRegistration.getNotifications() within a
Service Worker.</title> | 4 <title>Notifications: ServiceWorkerRegistration.getNotifications() within a
Service Worker.</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 Service Worke
r | 12 // Tests that the getNotifications() function when used in a Service Worke
r |
| 13 // return an array of the notifications which were previously displayed us
ing | 13 // return an array of the notifications which were previously displayed us
ing |
| 14 // the same Service Worker registration id. | 14 // the same Service Worker registration id. |
| 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.setPermission('notifications', 'granted', location.origin,
location.origin); |
| 20 testRunner.grantWebNotificationPermission(location.origin, true); | |
| 21 | 20 |
| 22 var info = null; | 21 var info = null; |
| 23 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi
on(workerInfo) { | 22 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi
on(workerInfo) { |
| 24 info = workerInfo; | 23 info = workerInfo; |
| 25 | 24 |
| 26 // (1) Display two notifications in the Document. | 25 // (1) Display two notifications in the Document. |
| 27 return info.registration.showNotification('Hello, world!', { | 26 return info.registration.showNotification('Hello, world!', { |
| 28 body: 'First notification' | 27 body: 'First notification' |
| 29 }); | 28 }); |
| 30 }).then(function() { | 29 }).then(function() { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 assert_equals(notifications[secondIndex].body, 'Second notific
ation'); | 62 assert_equals(notifications[secondIndex].body, 'Second notific
ation'); |
| 64 | 63 |
| 65 test.done(); | 64 test.done(); |
| 66 }); | 65 }); |
| 67 }).catch(unreached_rejection(test)); | 66 }).catch(unreached_rejection(test)); |
| 68 | 67 |
| 69 }, 'ServiceWorkerRegistration.getNotifications() returns the opened notifi
cations within a Service Worker.'); | 68 }, 'ServiceWorkerRegistration.getNotifications() returns the opened notifi
cations within a Service Worker.'); |
| 70 </script> | 69 </script> |
| 71 </body> | 70 </body> |
| 72 </html> | 71 </html> |
| OLD | NEW |