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>
    function onLoad(){
        window.addEventListener('message', function (event) {
    function openWindow(){'http://someurl')

We tested this code outside of Jira and it works.

Any ideas?