only send postmessage if parent is defined