after-worker-termination.https.html (704B)
1 <!DOCTYPE html> 2 <html class="test-wait"> 3 <meta charset="utf-8"> 4 <script> 5 const script = ` 6 postMessage("hi"); 7 // This line runs until worker.terminate() happens, which terminates this function too. 8 self.reportError(new Int16Array(2147483648)) 9 // And thus this line runs after the termination. 10 navigator.locks.request("weblock_0", () => {}); 11 `; 12 const worker = new Worker(URL.createObjectURL(new Blob([script]))); 13 worker.onmessage = () => { 14 worker.terminate(); 15 16 // We want to wait for the full termination but there is no API for that 17 // So, just wait for a random time 18 setTimeout(() => document.documentElement.classList.remove("test-wait"), 100); 19 } 20 </script>