2 <script src=
"../resources/testharness.js"></script>
3 <script src=
"../resources/testharnessreport.js"></script>
4 <script src=
"resources/test-helpers.js"></script>
6 async_test(function(t
) {
7 var documentURL
= 'no-such-worker';
8 navigator
.serviceWorker
.getRegistration(documentURL
)
9 .then(function(value
) {
10 assert_equals(value
, undefined,
11 'getRegistration should resolve with undefined');
14 .catch(unreached_rejection(t
));
15 }, 'getRegistration');
17 async_test(function(t
) {
18 var scope
= 'resources/scope/getregistration/normal';
20 service_worker_unregister_and_register(t
, 'resources/empty-worker.js',
24 return navigator
.serviceWorker
.getRegistration(scope
);
26 .then(function(value
) {
27 assert_registration_equals(value
, registration
);
30 'getRegistration should resolve to a new registration object');
31 service_worker_unregister_and_done(t
, scope
);
33 .catch(unreached_rejection(t
));
34 }, 'Register then getRegistration');
36 async_test(function(t
) {
37 var scope
= 'resources/scope/getregistration/url-with-fragment';
38 var documentURL
= scope
+ '#ref';
40 service_worker_unregister_and_register(t
, 'resources/empty-worker.js',
44 return navigator
.serviceWorker
.getRegistration(documentURL
);
46 .then(function(value
) {
47 assert_registration_equals(value
, registration
);
48 service_worker_unregister_and_done(t
, scope
);
50 .catch(unreached_rejection(t
));
51 }, 'Register then getRegistration with a URL having a fragment');
53 async_test(function(t
) {
54 var documentURL
= 'http://example.com/';
55 navigator
.serviceWorker
.getRegistration(documentURL
)
58 'getRegistration with an out of origin URL should fail');
61 reason
.name
, 'SecurityError',
62 'getRegistration with an out of origin URL should fail');
65 .catch(unreached_rejection(t
));
66 }, 'getRegistration with a cross origin URL');
68 async_test(function(t
) {
69 var scope
= 'resources/scope/getregistration/register-unregister';
70 service_worker_unregister_and_register(t
, 'resources/empty-worker.js',
72 .then(function(registration
) {
73 return registration
.unregister();
76 return navigator
.serviceWorker
.getRegistration(scope
);
78 .then(function(value
) {
79 assert_equals(value
, undefined,
80 'getRegistration should resolve with undefined');
83 .catch(unreached_rejection(t
));
84 }, 'Register then Unregister then getRegistration');