4 <title>subscribe() is rejected when the service worker is not active yet
</title>
5 <link rel=
"manifest" href=
"resources/push_manifest.json">
6 <script src=
"../resources/testharness.js"></script>
7 <script src=
"../resources/testharnessreport.js"></script>
8 <script src=
"../serviceworker/resources/test-helpers.js"></script>
12 async_test(function(test
) {
13 var workerUrl
= 'resources/empty_worker.js';
14 var workerScope
= 'resources/scope/' + location
.pathname
;
16 service_worker_unregister_and_register(test
, workerUrl
, workerScope
)
17 .then(function(serviceWorkerRegistration
) {
18 swRegistration
= serviceWorkerRegistration
;
19 assert_not_equals(swRegistration
.installing
, null, 'The worker should be installing');
20 assert_equals(swRegistration
.active
, null, 'The worker should not be active yet');
21 // If running manually, grant permission when prompted.
22 if (window
.testRunner
)
23 testRunner
.setPermission('push-messaging', 'granted', location
.origin
, location
.origin
);
24 return swRegistration
.pushManager
.subscribe();
26 .then(function(pushRegistration
) {
27 assert_unreached('subscribe() must not succeed without an active service worker');
29 assert_equals(e
.name
, 'AbortError');
30 assert_equals(e
.message
, 'Subscription failed - no active Service Worker');
31 return service_worker_unregister_and_done(test
, workerScope
);
33 .catch(unreached_rejection(test
));
34 }, 'subscribe() is rejected when the service worker is not active yet');