| OLD | NEW |
| 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 <script src="resources/test-helpers.js"></script> | 8 <script src="resources/test-helpers.js"></script> |
| 9 </head> | 9 </head> |
| 10 <body> | 10 <body> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 workerInfo = info; | 24 workerInfo = info; |
| 25 | 25 |
| 26 // (1) Display a Web Notification from the document. | 26 // (1) Display a Web Notification from the document. |
| 27 assert_inherits(workerInfo.registration, 'showNotification', 'show
Notification() must be exposed.'); | 27 assert_inherits(workerInfo.registration, 'showNotification', 'show
Notification() must be exposed.'); |
| 28 return workerInfo.registration.showNotification(scope, { | 28 return workerInfo.registration.showNotification(scope, { |
| 29 body: 'Hello, world!', | 29 body: 'Hello, world!', |
| 30 icon: '/icon.png' | 30 icon: '/icon.png' |
| 31 }); | 31 }); |
| 32 }).then(function() { | 32 }).then(function() { |
| 33 // (2) Simulate a click on the notification that has been displaye
d. | 33 // (2) Simulate a click on the notification that has been displaye
d. |
| 34 testRunner.simulateWebNotificationClick(scope); | 34 testRunner.simulateWebNotificationClick(scope, -1 /* action_index
*/); |
| 35 | 35 |
| 36 workerInfo.port.addEventListener('message', function(event) { | 36 workerInfo.port.addEventListener('message', function(event) { |
| 37 if (typeof event.data != 'object' || !event.data.command) { | 37 if (typeof event.data != 'object' || !event.data.command) { |
| 38 assert_unreached('Received an invalid message from the Ser
vice Worker.'); | 38 assert_unreached('Received an invalid message from the Ser
vice Worker.'); |
| 39 return; | 39 return; |
| 40 } | 40 } |
| 41 | 41 |
| 42 // (3) Verify that the click event was received by the Service
Worker. | 42 // (3) Verify that the click event was received by the Service
Worker. |
| 43 assert_equals(event.data.command, 'click'); | 43 assert_equals(event.data.command, 'click'); |
| 44 assert_equals(event.data.notification.title, scope); | 44 assert_equals(event.data.notification.title, scope); |
| 45 | 45 |
| 46 test.done(); | 46 test.done(); |
| 47 }); | 47 }); |
| 48 }).catch(unreached_rejection(test)); | 48 }).catch(unreached_rejection(test)); |
| 49 | 49 |
| 50 }, 'Clicking on a notification displayed through showNotification() fires
a Service Worker event.'); | 50 }, 'Clicking on a notification displayed through showNotification() fires
a Service Worker event.'); |
| 51 </script> | 51 </script> |
| 52 </body> | 52 </body> |
| 53 </html> | 53 </html> |
| OLD | NEW |