diff --git a/packages/app/src/components/canvas/LiveArtboard.tsx b/packages/app/src/components/canvas/LiveArtboard.tsx index b071710..422cd94 100644 --- a/packages/app/src/components/canvas/LiveArtboard.tsx +++ b/packages/app/src/components/canvas/LiveArtboard.tsx @@ -103,6 +103,23 @@ export function LiveArtboard({ // ── Handle messages from the renderer iframe ────────────────────────────── useEffect(() => { function handleMessage(event: MessageEvent) { + // INIT handshake: the iframe asks us "who am I?". We match by event.source + // (the iframe's window) to confirm the request came from OUR iframe, then + // reply with this artboard's ID. This is the cross-origin-safe replacement + // for the iframe element's name= attribute (which Chrome strips on cross- + // origin loads as a Spectre mitigation). + const data = event.data as { __om_init_request?: boolean } | null; + if (data && data.__om_init_request === true) { + const iframe = iframeRef.current; + if (iframe && iframe.contentWindow === event.source) { + iframe.contentWindow.postMessage( + { __om_init_response: true, artboardId: id }, + '*', + ); + } + return; + } + if (!isRendererEnvelope(event.data)) return; if (event.data.artboardId !== id) return; @@ -244,12 +261,16 @@ export function LiveArtboard({ return (