node/test/fixtures/wpt/web-locks/resources/iframe-parent.html
ishabi 062e8b5a74 worker: add web locks api
PR-URL: https://github.com/nodejs/node/pull/58666
Fixes: https://github.com/nodejs/node/pull/36502
Refs: https://w3c.github.io/web-locks
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2025-07-18 07:55:10 -07:00

37 lines
1.2 KiB
HTML

<!DOCTYPE html>
<title>Helper IFrame</title>
<script>
'use strict';
async function onLoad() {
// Nested Step 5: wpt/web-locks/partitioned-web-locks.tentative.https.html
// Load the innermost child iframe and its content.
const params = new URLSearchParams(self.location.search);
const frame = document.createElement('iframe');
frame.src = params.get('target');
document.body.appendChild(frame);
self.addEventListener('message', evt => {
// Nested Step 6: wpt/web-locks/partitioned-web-locks.tentative.https.html
// Pass any operations request messages to the
// innermost child iframe.
if (evt.data.op){
// Ensure that the iframe has loaded before passing
// on the message.
frame.addEventListener('load', function(){
frame.contentWindow.postMessage(evt.data, '*');
});
}
// Nested Step 8: wpt/web-locks/partitioned-web-locks.tentative.https.html
else {
// All other messages, should be sent back to the
// top-level site.
if (self.opener)
self.opener.postMessage(evt.data, '*');
else
self.top.postMessage(evt.data, '*');
}
});
}
self.addEventListener('load', onLoad);
</script>