test-write-and-notify-worker.https.html (893B)
1 <!doctype html> 2 <html> 3 <head> 4 <script> 5 const worker = new Worker("test-write-and-notify.js"); 6 worker.addEventListener("message", e => { 7 console.log("Worker listener received " + JSON.stringify(e.data)); 8 window.parent.postMessage(e.data, document.referrer); 9 }); 10 window.addEventListener("message", e => { 11 console.log("Window listener received " + JSON.stringify(e.data)); 12 worker.postMessage(e.data); 13 }); 14 </script> 15 </head> 16 <title>Executing the test script</title> 17 <body style="background-color: rgb(217, 255, 0)"> 18 <script> 19 const params = new URL(window.location.href).searchParams; 20 const id = params.get("id"); 21 console.log("Worker write frame id " + id); 22 window.parent.postMessage( 23 { id, message: "write loaded" }, 24 document.referrer 25 ); 26 </script> 27 </body> 28 </html>