2 postMessage calls in the test: 1 using an asterisk for targetOrigin, one using the same https url of both the parent and child documents.
button 1:
$(\
The problem is created by the itself, with its sandbox attribute:
As per the Mozilla Developer Network documentation on this element, the following gives a problem about same-origin policy:
allow-same-origin: If this token is not used, the resource is treated as being from a special origin that always fails the same-origin policy.
You didn't specified allow-same-origin, that means the frame is treated as being from a special origin, and postMessage calls to that frame will fail.
To solve the problem, just add allow-same-origin to the sandbox attribute, like this:
That's it!