<!DOCTYPE HTML>
<html>
<head>
<script src="iframe-common.js"></script>
</head>
<script>
function onInnerFrameLoad() {
parent.postMessage('inner frame load', '*');
}
window.addEventListener('message', (event) => {
if (event.data[0] == "clickBody") {
document.getElementById("nested-child").contentWindow.postMessage(event.data, "*");
} else {
parent.postMessage(event.data, '*');
}
});
</script>
<body>
<iframe id="nested-child" src="inner-iframe.html" sandbox="allow-pointer-lock allow-scripts" onload="onInnerFrameLoad()"></iframe>
iframe-allows-inner-iframe.html
</body>
</html>