Browser & Web Performance · Middle · Question 59 of 75

What must a message event handler check before trusting event.data?

window.addEventListener("message", (event) => {
  // ...
});

Explanation

Any window can post messages to yours. When sending, set the exact targetOrigin instead of * too.

Further reading

Problem with a question

Browser & Web Performance · Middle · question 59

Test yourself

Take the Browser & Web Performance · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz