registration-basic.https.html (1506B)
1 <!DOCTYPE html> 2 <title>Service Worker: Registration (basic)</title> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="resources/test-helpers.sub.js"></script> 6 <script> 7 const script = 'resources/registration-worker.js'; 8 9 promise_test(async (t) => { 10 const scope = 'resources/registration/normal'; 11 const registration = await navigator.serviceWorker.register(script, {scope}); 12 t.add_cleanup(() => registration.unregister()); 13 assert_true( 14 registration instanceof ServiceWorkerRegistration, 15 'Successfully registered.'); 16 }, 'Registering normal scope'); 17 18 promise_test(async (t) => { 19 const scope = 'resources/registration/scope-with-fragment#ref'; 20 const registration = await navigator.serviceWorker.register(script, {scope}); 21 t.add_cleanup(() => registration.unregister()); 22 assert_true( 23 registration instanceof ServiceWorkerRegistration, 24 'Successfully registered.'); 25 assert_equals( 26 registration.scope, 27 normalizeURL('resources/registration/scope-with-fragment'), 28 'A fragment should be removed from scope'); 29 }, 'Registering scope with fragment'); 30 31 promise_test(async (t) => { 32 const scope = 'resources/'; 33 const registration = await navigator.serviceWorker.register(script, {scope}) 34 t.add_cleanup(() => registration.unregister()); 35 assert_true( 36 registration instanceof ServiceWorkerRegistration, 37 'Successfully registered.'); 38 }, 'Registering same scope as the script directory'); 39 </script>