4 <title>Notifications: ServiceWorkerRegistration.showNotification().
</title>
5 <script src=
"../resources/testharness.js"></script>
6 <script src=
"../resources/testharnessreport.js"></script>
7 <script src=
"../serviceworker/resources/test-helpers.js"></script>
11 // Tests that the showNotification() function rejects the returned promise with a
12 // TypeError when the Service Worker is not activated yet.
13 async_test(function(test
) {
14 var scope
= 'resources/scope/service-worker-show-notification-not-activated',
15 workerUrl
= 'resources/empty-worker.js';
17 if (window
.testRunner
)
18 testRunner
.setPermission('notifications', 'denied', location
.origin
, location
.origin
);
20 service_worker_unregister_and_register(test
, workerUrl
, scope
).then(function(registration
) {
21 assert_inherits(registration
, 'showNotification', 'showNotification() must be exposed.');
22 registration
.showNotification('Title', {
23 body
: 'Hello, world!',
26 assert_unreached('showNotification() is expected to reject.');
27 }).catch(function(error
) {
28 assert_equals(error
.name
, 'TypeError');
29 assert_equals(error
.message
, 'No active registration available on the ServiceWorkerRegistration.');
33 }).catch(unreached_rejection(test
));
35 }, 'showNotification() must reject if there is no active registration on the ServiceWorkerRegistration.');