| <!doctype html> |
| <html> |
| <head> |
| <title>Notifications: ServiceWorkerRegistration.showNotification().</title> |
| <script src="../resources/testharness.js"></script> |
| <script src="../resources/testharnessreport.js"></script> |
| <script src="../serviceworker/resources/test-helpers.js"></script> |
| </head> |
| <body> |
| <script> |
| // Tests that the showNotification() function rejects the returned promise with a |
| // TypeError when the Service Worker is not activated yet. |
| async_test(function(test) { |
| var scope = 'resources/scope/service-worker-show-notification-not-activated', |
| workerUrl = 'resources/empty-worker.js'; |
| |
| if (window.testRunner) |
| testRunner.setPermission('notifications', 'denied', location.origin, location.origin); |
| |
| service_worker_unregister_and_register(test, workerUrl, scope).then(function(registration) { |
| assert_inherits(registration, 'showNotification', 'showNotification() must be exposed.'); |
| registration.showNotification('Title', { |
| body: 'Hello, world!', |
| icon: '/icon.png' |
| }).then(function() { |
| assert_unreached('showNotification() is expected to reject.'); |
| }).catch(function(error) { |
| assert_equals(error.name, 'TypeError'); |
| assert_equals(error.message, "Failed to execute 'showNotification' on 'ServiceWorkerRegistration': No active registration available on the ServiceWorkerRegistration."); |
| test.done(); |
| }); |
| |
| }).catch(unreached_rejection(test)); |
| |
| }, 'showNotification() must reject if there is no active registration on the ServiceWorkerRegistration.'); |
| |
| </script> |
| </body> |
| </html> |