register-wait-forever-in-install-worker.https.html (2311B)
1 <!DOCTYPE html> 2 <title>Service Worker: Register wait-forever-in-install-worker</title> 3 <script src="/resources/testharness.js"></script> 4 <script src="resources/testharness-helpers.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="resources/test-helpers.sub.js"></script> 7 <script> 8 9 promise_test(function(t) { 10 var bad_script = 'resources/wait-forever-in-install-worker.js'; 11 var good_script = 'resources/empty-worker.js'; 12 var scope = 'resources/wait-forever-in-install-worker'; 13 var other_scope = 'resources/wait-forever-in-install-worker-other'; 14 var registration; 15 var registerPromise; 16 17 return navigator.serviceWorker.register(bad_script, {scope: scope}) 18 .then(function(r) { 19 t.add_cleanup(function() { 20 return service_worker_unregister(t, scope); 21 }); 22 23 registration = r; 24 assert_equals(registration.installing.scriptURL, 25 normalizeURL(bad_script)); 26 27 // This register job should not start until the first 28 // register for the same scope completes. 29 registerPromise = 30 navigator.serviceWorker.register(good_script, {scope: scope}); 31 32 // In order to test that the above register does not complete 33 // we will perform a register() on a different scope. The 34 // assumption here is that the previous register call would 35 // have completed in the same timeframe if it was able to do 36 // so. 37 return navigator.serviceWorker.register(good_script, 38 {scope: other_scope}); 39 }) 40 .then(function(swr) { 41 return swr.unregister(); 42 }) 43 .then(function() { 44 assert_equals(registration.installing.scriptURL, 45 normalizeURL(bad_script)); 46 registration.installing.postMessage('STOP_WAITING'); 47 return registerPromise; 48 }) 49 .then(function(swr) { 50 assert_equals(registration.installing.scriptURL, 51 normalizeURL(good_script)); 52 return wait_for_state(t, registration.installing, 'activated'); 53 }) 54 }, 'register worker that calls waitUntil with a promise that never ' + 55 'resolves in oninstall'); 56 57 </script>