From 2e83db5a4ba62deb7ec9cc977b790c1d49914ba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Wed, 30 Sep 2026 19:54:28 -0400 Subject: [PATCH] test(studio): walk open shadow roots to the preview iframe in the flash controls and input log The previous commit only switched the frame check to the live URL; the iframe walk did not land. --- packages/studio/tests/e2e/edit-accuracy/case.mjs | 8 +++++--- packages/studio/tests/e2e/edit-accuracy/flash.mjs | 7 ++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/studio/tests/e2e/edit-accuracy/case.mjs b/packages/studio/tests/e2e/edit-accuracy/case.mjs index 82f6aea17f..1ac22fb666 100644 --- a/packages/studio/tests/e2e/edit-accuracy/case.mjs +++ b/packages/studio/tests/e2e/edit-accuracy/case.mjs @@ -655,9 +655,11 @@ function injectControl(page) { return ""; } }; - const frames = [...document.querySelectorAll("iframe")].filter((f) => - url(f).includes("/preview"), - ); + const iframes = (root) => + [...root.querySelectorAll("*")].flatMap((el) => + el.tagName === "IFRAME" ? [el] : el.shadowRoot ? iframes(el.shadowRoot) : [], + ); + const frames = iframes(document).filter((f) => url(f).includes("/preview")); const area = (f) => f.offsetWidth * f.offsetHeight; frames.reduce((a, b) => (area(b) > area(a) ? b : a)).contentWindow.location.reload(); }); diff --git a/packages/studio/tests/e2e/edit-accuracy/flash.mjs b/packages/studio/tests/e2e/edit-accuracy/flash.mjs index 14af98cc0e..48b898a184 100644 --- a/packages/studio/tests/e2e/edit-accuracy/flash.mjs +++ b/packages/studio/tests/e2e/edit-accuracy/flash.mjs @@ -21,12 +21,17 @@ function markerOn() { if (e.type === "pointerup" || !MODIFIERS.has(e.key)) marker.inputs.push({ type: e.type, key: e.key ?? null, n: marker.n, t: performance.now() }); }; + // Studio's preview iframe sits in the player's shadow root, out of querySelectorAll's reach. + const iframes = (root) => + [...root.querySelectorAll("*")].flatMap((el) => + el.tagName === "IFRAME" ? [el] : el.shadowRoot ? iframes(el.shadowRoot) : [], + ); const listen = (w) => { for (const type of ["pointerup", "keydown"]) { w.addEventListener(type, log, true); marker.unlisten.push(() => w.removeEventListener(type, log, true)); } - for (const f of w.document.querySelectorAll("iframe")) { + for (const f of iframes(w.document)) { try { listen(f.contentWindow); } catch {