can't access source object when window.postMessage in Edge can't access source object when window.postMessage in Edge google-chrome google-chrome

can't access source object when window.postMessage in Edge


I made a test with the following code sample and it can work well in Edge:

Page1.html:

<!DOCTYPE html><html><head>    <title></title>    <meta charset="utf-8" />    <script>        function openChild() {            var childwin = window.open('Page2.html', 'popup', 'height=300px, width=500px');        }        window.addEventListener("message", (event) => {            let txt = document.querySelector('#txtMsg');            txt.value = `Name is ${event.data.pName} Age is  ${event.data.pAge}`;            console.log(event.source);  //update: get event.source        });    </script></head><body>    <form>        <fieldset>            <input type='button' id='btnopen' value='Open child' onclick='openChild();' />            <input type='text' id='txtMsg' />        </fieldset>    </form></body></html>

Page2.html:

<!DOCTYPE html><html><head>    <title></title>    <meta charset="utf-8" />    <script>        function sendMessage() {            let msg = { pName: "Bob", pAge: "35" };            window.opener.postMessage(msg, 'http://domain_name/Page1.html')            window.opener.focus();        }    </script></head><body>    <form>        <fieldset>                        <input type='button' id='btnSendMsg' value='Send Message' onclick='sendMessage();' />        </fieldset>    </form></body></html>

Result:

enter image description here

You could refer to the sample, if still not working, please provide a minimal sample which can reproduce the issue. With only the above code you provide, I can't reproduce the issue.