Listening to window message event

We are trying to listen the window message event, but keep getting a ‘RPC: request rejected error’.

Basically, we are opening a window that post a message to the ‘opener’ (Our Jira), the posting code was tested and works well, but we still cannot get the event (keep getting the error).

Here’s the a sample of our code:

<body onload="onLoad()">
    <button onclick="openWindow()"></button>
</body>
<script>
    function onLoad(){
        window.addEventListener('message', function (event) {
            console.log(event);
        })
    }
    function openWindow(){
        window.open('http://someurl')
    }
</script>

We tested this code outside of Jira and it works.

Any ideas?

Thanks.