| OLD | NEW |
| 1 <!doctype html> | 1 <!doctype html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Notifications: ServiceWorkerRegistration.showNotification() shows not
ification with correct notification direction.</title> | 4 <title>Notifications: ServiceWorkerRegistration.showNotification() shows not
ification with correct notification direction.</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 showNotification() function resolves a promise, and that
the | 12 // Tests that the showNotification() function resolves a promise, and that
the |
| 13 // notificationclick event gets fired with the correct notification direct
ion. | 13 // notificationclick event gets fired with the correct notification direct
ion. |
| 14 // This test requires the test runner. | 14 // This test requires the test runner. |
| 15 | 15 |
| 16 async_test(function(test) { | 16 async_test(function(test) { |
| 17 var scope = 'resources/spec/' + location.pathname, | 17 var scope = 'resources/spec/' + location.pathname, |
| 18 script = 'resources/instrumentation-service-worker.js'; | 18 script = 'resources/instrumentation-service-worker.js'; |
| 19 | 19 |
| 20 testRunner.setPermission('notifications', 'granted', location.origin,
location.origin); | 20 testRunner.setPermission('notifications', 'granted', location.origin,
location.origin); |
| 21 testRunner.grantWebNotificationPermission(location.origin, true); | |
| 22 | 21 |
| 23 var workerInfo = null; | 22 var workerInfo = null; |
| 24 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi
on(info) { | 23 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi
on(info) { |
| 25 workerInfo = info; | 24 workerInfo = info; |
| 26 | 25 |
| 27 // (1) Display a Web Notification from the document. | 26 // (1) Display a Web Notification from the document. |
| 28 return workerInfo.registration.showNotification(scope, { | 27 return workerInfo.registration.showNotification(scope, { |
| 29 dir: 'rtl' | 28 dir: 'rtl' |
| 30 }); | 29 }); |
| 31 }).then(function() { | 30 }).then(function() { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 44 assert_equals(event.data.notification.dir, 'rtl'); | 43 assert_equals(event.data.notification.dir, 'rtl'); |
| 45 | 44 |
| 46 test.done(); | 45 test.done(); |
| 47 }); | 46 }); |
| 48 }).catch(unreached_rejection(test)); | 47 }).catch(unreached_rejection(test)); |
| 49 | 48 |
| 50 }, 'Clicking on a notification displayed through showNotification() fires
a Service Worker event with the correct notification direction'); | 49 }, 'Clicking on a notification displayed through showNotification() fires
a Service Worker event with the correct notification direction'); |
| 51 </script> | 50 </script> |
| 52 </body> | 51 </body> |
| 53 </html> | 52 </html> |
| OLD | NEW |