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 {