Skip to content

Latest commit

 

History

History
21 lines (14 loc) · 948 Bytes

require-post-message-target-origin.md

File metadata and controls

21 lines (14 loc) · 948 Bytes

Enforce using the targetOrigin argument with window.postMessage()

When calling window.postMessage() without the targetOrigin argument, the message cannot be received by any window.

This rule cannot distinguish between window.postMessage() and other calls like Worker#postMessage(), MessagePort#postMessage(), Client#postMessage(), and BroadcastChannel#postMessage(). Use on your own risk.

Fail

window.postMessage(message);

Pass

window.postMessage(message, 'https://example.com');
window.postMessage(message, '*');