Why is this not working?

I am trying to broadcast a message to an HTML file and don’t understand why it is not working
Message Broadcast:

top.postMessage('question set', 'play.js')

Message Interpretation:

let questionNameDisplay = document.getElementById('question-name-display')
  window.addEventListener('message', function (event) {
  if (event.origin === 'play.js') {
    if (event.data === 'question set') {
      questionNameDisplay.innerHTML = `QUESTION SET`

Can anybody identify any errors? Thanks!

is top identified as the window?

yes, it is. Top is another keyword for window

can you share more of your code? do you have a sandbox open with your code? using something like codepen.io will make it easy for others to see the full implementation and then we can take a closer look.