From 9dbf68cf10663361582f2d890ba7084144aec974 Mon Sep 17 00:00:00 2001 From: Andrii Konosov Date: Fri, 20 Nov 2026 12:00:01 -0600 Subject: [PATCH 1/2] #159: UI frame allow attribute is not extensible --- e2e/guest-app/src/ExtentionStuck.jsx | 51 ++++++++++++++ e2e/host-app/src/HostAppRteNoExtensions.jsx | 55 +++++++++++++++ e2e/host-app/src/HostAppRteStuck.jsx | 61 ++++++++++++++++ e2e/tests/tests/rte-no-extensions.js | 39 +++++++++++ e2e/tests/tests/rte-stuck-loading.js | 69 +++++++++++++++++++ .../src/components/GuestUIFrame.test.tsx | 34 +++++++-- .../src/components/GuestUIFrame.tsx | 22 +++++- .../src/dom-utils/iframe-normalizers.test.ts | 31 ++++++++- .../src/dom-utils/iframe-normalizers.ts | 41 ++++++++++- 9 files changed, 393 insertions(+), 10 deletions(-) create mode 100644 e2e/guest-app/src/ExtentionStuck.jsx create mode 100644 e2e/host-app/src/HostAppRteNoExtensions.jsx create mode 100644 e2e/host-app/src/HostAppRteStuck.jsx create mode 100644 e2e/tests/tests/rte-no-extensions.js create mode 100644 e2e/tests/tests/rte-stuck-loading.js diff --git a/e2e/guest-app/src/ExtentionStuck.jsx b/e2e/guest-app/src/ExtentionStuck.jsx new file mode 100644 index 0000000..273ef5b --- /dev/null +++ b/e2e/guest-app/src/ExtentionStuck.jsx @@ -0,0 +1,51 @@ +import React, { useEffect } from 'react'; +import { connectParentWindow } from '@adobe/uix-core'; + +/** + * A guest that reproduces the extensibility flaw behind the CF Editor RTE + * "stuck on loading skeleton" incident (SITES-49454). + * + * A normal guest (`register()`) does two things when it connects: + * 1. Completes the low-level tunnel handshake + API exchange with the host. + * This is what makes the host's `Port.connect()` -> `attachFrame()` resolve + * and capture the guest SDK version. + * 2. AFTER that, posts a one-shot `window.parent.postMessage({ type: + * 'guest-ready' })`. Since guest SDK >= 1.1.4, the host waits for this + * message (with a `timeout` ms deadline) before marking the guest loaded. + * + * This guest does step 1 but deliberately SKIPS step 2. The extension therefore + * "connects" but never reports as finally loaded, so the host's guest-ready wait + * hangs for the full `timeout` before rejecting. Because the host only fires + * `loadallguests` / clears `host.loading` after ALL guests settle, this single + * never-ready guest stalls the whole extension point -- exactly what stalled the + * RTE's `beforeLoad` readiness gate in production. + */ +export default function ExtensionStuck() { + useEffect(() => { + const hashSearch = window.location.hash.split('?')[1] || ''; + const extensionId = + new URLSearchParams(hashSearch).get('id') || 'ext-stuck'; + + // Same tunnel handshake `register()` performs internally, minus the final + // `guest-ready` postMessage. A large timeout keeps the guest side of the + // tunnel alive well past the host's (shorter) guest-ready deadline. + connectParentWindow( + { targetOrigin: '*', timeout: 60000 }, + { + apis: { + extensionNamespace: { + getMessage: async () => 'Message from stuck guest', + setMessage: async () => 'Success', + }, + }, + emit: async () => {}, + metadata: { id: extensionId, extensions: [] }, + } + ).catch(() => { + // The host tears the tunnel down after its guest-ready timeout; swallow + // the resulting rejection so it doesn't surface as an unhandled error. + }); + }, []); + + return

Guest app stuck view (connects but never reports ready)

; +} diff --git a/e2e/host-app/src/HostAppRteNoExtensions.jsx b/e2e/host-app/src/HostAppRteNoExtensions.jsx new file mode 100644 index 0000000..8045d24 --- /dev/null +++ b/e2e/host-app/src/HostAppRteNoExtensions.jsx @@ -0,0 +1,55 @@ +import { useState, useEffect } from 'react'; +import { useHost } from '@adobe/uix-host-react'; + +/** + * Emulates the CF Editor Rich Text Editor's load gate when the `cf-editor` + * extension point resolves to ZERO extensions (e.g. every candidate was + * filtered out for not being PUBLISHED -- see App Registry status filtering). + * + * Mirrors `useRTEBeforeLoad`'s `ready` derivation exactly + * (aem-headless-ui-commons: RichTextEditor/BeforeLoad.ts): + * - no host yet -> not ready + * - host exists, !loading -> ready immediately + * - host exists, loading -> wait for `loadallguests` + * + * Unlike the #/rte-stuck scenario (one guest connects but never reports + * ready, so the host eventually times it out and fires `loadallguests`), + * an empty extensions list never even creates a `Host` (see Extensible.tsx). + * `host` therefore stays `undefined` forever and `ready` can never become + * true -- a permanent hang, not a bounded delay. + */ +export default function HostAppRteNoExtensions() { + const { host } = useHost(); + const [ready, setReady] = useState(false); + + useEffect(() => { + if (!host) { + setReady(false); + return undefined; + } + + if (!host.loading) { + setReady(true); + return undefined; + } + + const onGuestsLoaded = () => setReady(true); + host.addEventListener('loadallguests', onGuestsLoaded); + return () => host.removeEventListener('loadallguests', onGuestsLoaded); + }, [host]); + + return ( +
+

RTE no-extensions scenario

+

{ready ? 'ready' : 'waiting'}

+ + {ready ? ( +
+ Description field is editable +
+ ) : ( +
Loading rich text editor…
+ )} +
+ ); +} diff --git a/e2e/host-app/src/HostAppRteStuck.jsx b/e2e/host-app/src/HostAppRteStuck.jsx new file mode 100644 index 0000000..c3b7ef9 --- /dev/null +++ b/e2e/host-app/src/HostAppRteStuck.jsx @@ -0,0 +1,61 @@ +import { useState, useEffect } from 'react'; +import { useHost } from '@adobe/uix-host-react'; + +/** + * Emulates the CF Editor Rich Text Editor's load gate (SITES-49454). + * + * In the real editor, `RichTextEditorTipTap` keeps `contentLoading = true` and + * renders the loading skeleton until `useRTEBeforeLoad().ready` becomes true. + * That `ready` signal is derived ENTIRELY from the extensibility host: it only + * flips once the host has finished handshaking every guest -- i.e. once + * `host.loading` goes false / the `loadallguests` event fires. There is no + * independent fallback timeout on the editor side. + * + * This component reproduces that gate exactly: `ready` starts false (skeleton + * shown) and only becomes true when the host emits `loadallguests`. When one + * guest connects but never reports ready (see ExtentionStuck), the host cannot + * fire `loadallguests` until that guest's connection times out, so the skeleton + * stays up for the full timeout even though the healthy RTE extension connected + * almost immediately. + */ +export default function HostAppRteStuck() { + const { host } = useHost(); + const [ready, setReady] = useState(false); + const [loadedCount, setLoadedCount] = useState(0); + const [failedCount, setFailedCount] = useState(0); + + useEffect(() => { + if (!host) return; + + const onLoadAll = (event) => { + const { loaded = [], failed = [] } = event.detail || {}; + setLoadedCount(loaded.length); + setFailedCount(failed.length); + setReady(true); + }; + + host.addEventListener('loadallguests', onLoadAll); + return () => host.removeEventListener('loadallguests', onLoadAll); + }, [host]); + + return ( +
+

RTE stuck-loading scenario

+

{ready ? 'ready' : 'waiting'}

+

{loadedCount}

+

{failedCount}

+ + {ready ? ( +
+ Description field is editable +
+ ) : ( +
Loading rich text editor…
+ )} +
+ ); +} diff --git a/e2e/tests/tests/rte-no-extensions.js b/e2e/tests/tests/rte-no-extensions.js new file mode 100644 index 0000000..0902b4f --- /dev/null +++ b/e2e/tests/tests/rte-no-extensions.js @@ -0,0 +1,39 @@ +import { fixture, test, Selector } from "testcafe"; + +/** + * Reproduces the regression introduced by uix-sdk commit d645b96 + * ("Update host render", PR #94, host-rerenders-update): host creation was + * moved inside the `if (!extensions || !Object.keys(extensions).length) return;` + * guard in `Extensible.tsx` -- a guard that previously only skipped calling + * `host.load()`. As a result, when the extension point resolves to ZERO + * extensions, `Host` is never instantiated at all, `useHost()` returns + * `host: undefined` forever, and anything gating readiness on the host + * (like the RTE's `useRTEBeforeLoad`) can never flip to `ready`. + * + * This differs from #/rte-stuck (SITES-49454): there, a non-empty guest + * list means a `Host` IS created and `loadallguests` eventually fires once + * the stuck guest's connection times out (bounded delay). Here, with zero + * extensions, there is nothing to time out -- the hang is permanent. + * + * Setup (#/rte-no-extensions): the extensions provider resolves to `{}`. + */ +fixture("RTE with zero extensions").page("http://localhost:3000/#/rte-no-extensions"); + +test("RTE clears the loading skeleton when there are no extensions to load", async (t) => { + const skeleton = Selector("#rte-skeleton"); + const editor = Selector("#rte-editor"); + const readyFlag = Selector("#ready-flag"); + + // There is nothing to connect to and nothing to wait for, so readiness + // should resolve almost immediately. Currently it never resolves, so this + // assertion times out and the test fails. + await t + .expect(editor.exists) + .ok("RTE editor should be available since there are no extensions to wait for", { + timeout: 5000, + }) + .expect(skeleton.exists) + .notOk("Skeleton must not still be showing once zero extensions is confirmed") + .expect(readyFlag.innerText) + .eql("ready", "Readiness should resolve to true when the extension point has zero extensions"); +}); diff --git a/e2e/tests/tests/rte-stuck-loading.js b/e2e/tests/tests/rte-stuck-loading.js new file mode 100644 index 0000000..676dead --- /dev/null +++ b/e2e/tests/tests/rte-stuck-loading.js @@ -0,0 +1,69 @@ +import { fixture, test, Selector } from "testcafe"; + +/** + * Reproduces the CF Editor RTE "stuck on loading skeleton" incident + * (SITES-49454) at the extensibility-SDK level. + * + * Setup (#/rte-stuck): + * - `ext-ok` : a healthy RTE extension, connects and reports ready instantly. + * - `ext-stuck` : completes the tunnel handshake but NEVER posts `guest-ready`. + * + * The host component gates its "editor" on the host's `loadallguests` event -- + * exactly how the real RTE gates `contentLoading` on `beforeLoadReady`. Because + * the host waits for ALL guests to settle before firing `loadallguests`, the + * never-ready guest stalls the whole extension point: the skeleton stays up for + * the entire guest-ready timeout even though `ext-ok` was ready immediately. + * + * Guest-ready timeout for this scenario is 5000ms (App.js guestOptionsMap), + * standing in for the 20s production default. + */ +fixture("RTE stuck loading").page("http://localhost:3000/#/rte-stuck"); + +test("RTE stays on the loading skeleton while an extension never reports ready", async (t) => { + const skeleton = Selector("#rte-skeleton"); + const editor = Selector("#rte-editor"); + const readyFlag = Selector("#ready-flag"); + + // Give the host time to create iframes and finish the tunnel handshake for + // both guests, but stay well under the 5000ms guest-ready timeout. During + // this window the healthy `ext-ok` has already connected, yet readiness is + // still blocked by `ext-stuck` -- the bug. + await t.wait(3000); + + await t + .expect(skeleton.exists) + .ok("RTE should still show the loading skeleton while a guest is never-ready") + .expect(editor.exists) + .notOk("RTE editor must not be available while the host is still loading") + .expect(readyFlag.innerText) + .eql("waiting", "Readiness signal from the host has not fired yet"); +}); + +test("RTE recovers only after the never-ready guest times out", async (t) => { + const skeleton = Selector("#rte-skeleton"); + const editor = Selector("#rte-editor"); + const readyFlag = Selector("#ready-flag"); + const loadedCount = Selector("#loaded-count"); + const failedCount = Selector("#failed-count"); + + // The RTE only clears its skeleton once the host finally fires + // `loadallguests` -- which cannot happen until `ext-stuck` times out at + // ~5s. This is the "would have loaded after 20-30s" behaviour from the + // incident, compressed to the 5s test timeout. + await t + .expect(editor.exists) + .ok("RTE editor should eventually appear once the host times out the stuck guest", { + timeout: 15000, + }) + .expect(skeleton.exists) + .notOk("Skeleton should be gone once the editor is ready") + .expect(readyFlag.innerText) + .eql("ready", "Host readiness signal has fired"); + + // The healthy extension loaded; the stuck one is reported as failed. + await t + .expect(loadedCount.innerText) + .eql("1", "Exactly the healthy extension should be reported as loaded") + .expect(failedCount.innerText) + .eql("1", "The never-ready extension should be reported as failed"); +}); diff --git a/packages/uix-host-react/src/components/GuestUIFrame.test.tsx b/packages/uix-host-react/src/components/GuestUIFrame.test.tsx index 6b37241..6e36f4a 100644 --- a/packages/uix-host-react/src/components/GuestUIFrame.test.tsx +++ b/packages/uix-host-react/src/components/GuestUIFrame.test.tsx @@ -106,7 +106,7 @@ describe("GuestUIFrame", () => { expect(iframe?.getAttribute("name")).toBe("uix-guest-guest-1"); }); - it('always sets allow="local-network-access", even if a custom allow prop is passed', () => { + it("keeps the required local-network-access directive even if a custom allow prop overrides it", () => { const guest = createGuest("guest-1"); mockedUseHost.mockReturnValue({ host: mockHostWithGuest(guest), @@ -114,13 +114,37 @@ describe("GuestUIFrame", () => { }); const { container } = render( - + ); const iframe = container.querySelector("iframe"); - // required props win over any custom `allow`, same as the other - // required iframe props (data-uix-guest, role, referrerPolicy) - expect(iframe?.getAttribute("allow")).toBe("local-network-access"); + expect(iframe?.getAttribute("allow")).toBe( + "local-network-access; fullscreen" + ); + }); + + it("merges a custom allow prop with the required allow directives", () => { + const guest = createGuest("guest-1"); + mockedUseHost.mockReturnValue({ + host: mockHostWithGuest(guest), + error: undefined, + }); + + const { container } = render( + + ); + + expect(container.querySelector("iframe")?.getAttribute("allow")).toBe( + "local-network-access; microphone; autoplay" + ); }); it("attaches the UI and invokes onConnect once connected", async () => { diff --git a/packages/uix-host-react/src/components/GuestUIFrame.tsx b/packages/uix-host-react/src/components/GuestUIFrame.tsx index 4778fc0..54aeff6 100644 --- a/packages/uix-host-react/src/components/GuestUIFrame.tsx +++ b/packages/uix-host-react/src/components/GuestUIFrame.tsx @@ -14,8 +14,16 @@ import { CrossRealmObject, UIFrameRect, VirtualApi } from "@adobe/uix-core"; import React, { useEffect, useRef } from "react"; import type { IframeHTMLAttributes } from "react"; import { useHost } from "../hooks/useHost.js"; -import type { AttrTokens, SandboxToken } from "@adobe/uix-host"; -import { makeSandboxAttrs, requiredIframeProps } from "@adobe/uix-host"; +import type { + AllowDirectives, + AttrTokens, + SandboxToken, +} from "@adobe/uix-host"; +import { + makeAllowAttrs, + makeSandboxAttrs, + requiredIframeProps, +} from "@adobe/uix-host"; /** * @internal @@ -25,7 +33,7 @@ type ReactIframeProps = IframeHTMLAttributes; /** * @public */ -type FrameProps = Omit; +type FrameProps = Omit; /** @public */ export interface GuestUIProps extends FrameProps { @@ -50,6 +58,12 @@ export interface GuestUIProps extends FrameProps { * Additional sandbox attributes GuestUIFrame might need. */ sandbox?: AttrTokens; + /** + * Additional Permissions Policy directives for the iframe "allow=" attribute + * (e.g. `"microphone; autoplay"` or `["microphone", "autoplay"]`). Merged + * with the directives the SDK requires. + */ + allow?: AllowDirectives; /** * Optional custom URL or path. */ @@ -90,6 +104,7 @@ export const GuestUIFrame = ({ methods, privateMethods, sandbox = "", + allow = "", style, ...customIFrameProps }: GuestUIProps) => { @@ -178,6 +193,7 @@ export const GuestUIFrame = ({ } {...customIFrameProps} {...requiredIframeProps} + allow={makeAllowAttrs(requiredIframeProps.allow, allow).join("; ")} /> ); }; diff --git a/packages/uix-host/src/dom-utils/iframe-normalizers.test.ts b/packages/uix-host/src/dom-utils/iframe-normalizers.test.ts index d1a0547..64cf95f 100644 --- a/packages/uix-host/src/dom-utils/iframe-normalizers.test.ts +++ b/packages/uix-host/src/dom-utils/iframe-normalizers.test.ts @@ -1,4 +1,8 @@ -import { makeSandboxAttrs, normalizeIframe } from "./iframe-normalizers"; +import { + makeAllowAttrs, + makeSandboxAttrs, + normalizeIframe, +} from "./iframe-normalizers"; describe("makeSandboxAttrs", () => { it("merges and dedupes sandbox attributes", () => @@ -13,7 +17,32 @@ describe("makeSandboxAttrs", () => { )); }); +describe("makeAllowAttrs", () => { + it("merges directives from strings and arrays, first feature wins", () => + expect( + makeAllowAttrs( + "local-network-access", + " microphone ; autoplay 'self' ;", + ["Microphone 'none'", "camera https://example.com"] + ) + ).toEqual([ + "local-network-access", + "microphone", + "autoplay 'self'", + "camera https://example.com", + ])); +}); + describe("normalizeIframe", () => { + it("merges required allow directives with existing ones", () => { + const frame = document.createElement("iframe"); + frame.setAttribute("allow", "microphone; autoplay"); + normalizeIframe(frame); + expect(frame.getAttribute("allow")).toBe( + "local-network-access; microphone; autoplay" + ); + }); + it("applies required attributes and default sandbox to iframe", () => { const frame = document.createElement("iframe"); normalizeIframe(frame); diff --git a/packages/uix-host/src/dom-utils/iframe-normalizers.ts b/packages/uix-host/src/dom-utils/iframe-normalizers.ts index 5821dd4..7f94f33 100644 --- a/packages/uix-host/src/dom-utils/iframe-normalizers.ts +++ b/packages/uix-host/src/dom-utils/iframe-normalizers.ts @@ -41,6 +41,38 @@ export type SandboxToken = `allow-${SandboxPermission}`; export const makeSandboxAttrs = (...sandboxes: AttrTokens[]) => mergeAttrValues(...sandboxes); +/** + * Permissions Policy directives for an iframe "allow=" attribute. Either a + * semicolon-separated string (e.g. `"microphone; autoplay 'self'"`) or an + * array of individual directives (e.g. `["microphone", "autoplay 'self'"]`). + * @public + */ +export type AllowDirectives = string | string[]; + +const tokenizeAllowDirectives = (directives: AllowDirectives) => + (typeof directives === "string" ? directives.split(";") : directives) + .map((directive) => directive.trim().replace(/\s+/g, " ")) + .filter(Boolean); + +/** + * Merge and deduplicate Permissions Policy directives for an iframe "allow=" + * attribute. Directives are keyed by feature name; when the same feature + * appears more than once, the first occurrence wins. + * @internal + */ +export const makeAllowAttrs = (...allowLists: AllowDirectives[]) => { + const byFeature = new Map(); + for (const allowList of allowLists) { + for (const directive of tokenizeAllowDirectives(allowList)) { + const feature = directive.split(" ")[0].toLowerCase(); + if (!byFeature.has(feature)) { + byFeature.set(feature, directive); + } + } + } + return [...byFeature.values()]; +}; + /** * Limit provided set of "sandbox" attributes to a list of legal ones. * @internal @@ -57,14 +89,21 @@ export const requiredIframeProps = { allow: "local-network-access", }; -const requiredIframeAttrEntries = Object.entries(requiredIframeProps); +const { allow: requiredAllow, ...requiredIframeAttrs } = requiredIframeProps; +const requiredIframeAttrEntries = Object.entries(requiredIframeAttrs); /** * Set and/or verify the required properties for use with uix-sdk on an iframe. + * Required "allow=" directives are merged into any existing ones rather than + * replacing them, so host-granted permissions are preserved. * @internal */ export const normalizeIframe = (iframe: HTMLIFrameElement) => { for (const [attr, value] of requiredIframeAttrEntries) { iframe.setAttribute(attr, value); } + iframe.setAttribute( + "allow", + makeAllowAttrs(requiredAllow, iframe.getAttribute("allow") || "").join("; ") + ); }; From 193be4dc7efe809e77abe5643c1b1318e98a24e1 Mon Sep 17 00:00:00 2001 From: Andrii Konosov Date: Fri, 20 Nov 2026 12:21:10 -0600 Subject: [PATCH 2/2] #159: removed AI slop --- e2e/guest-app/src/ExtentionStuck.jsx | 51 --------------- e2e/host-app/src/HostApp.jsx | 1 + e2e/host-app/src/HostAppRteNoExtensions.jsx | 55 ---------------- e2e/host-app/src/HostAppRteStuck.jsx | 61 ------------------ e2e/tests/tests/check-button.js | 33 +++++++++- e2e/tests/tests/rte-no-extensions.js | 39 ------------ e2e/tests/tests/rte-stuck-loading.js | 69 --------------------- 7 files changed, 33 insertions(+), 276 deletions(-) delete mode 100644 e2e/guest-app/src/ExtentionStuck.jsx delete mode 100644 e2e/host-app/src/HostAppRteNoExtensions.jsx delete mode 100644 e2e/host-app/src/HostAppRteStuck.jsx delete mode 100644 e2e/tests/tests/rte-no-extensions.js delete mode 100644 e2e/tests/tests/rte-stuck-loading.js diff --git a/e2e/guest-app/src/ExtentionStuck.jsx b/e2e/guest-app/src/ExtentionStuck.jsx deleted file mode 100644 index 273ef5b..0000000 --- a/e2e/guest-app/src/ExtentionStuck.jsx +++ /dev/null @@ -1,51 +0,0 @@ -import React, { useEffect } from 'react'; -import { connectParentWindow } from '@adobe/uix-core'; - -/** - * A guest that reproduces the extensibility flaw behind the CF Editor RTE - * "stuck on loading skeleton" incident (SITES-49454). - * - * A normal guest (`register()`) does two things when it connects: - * 1. Completes the low-level tunnel handshake + API exchange with the host. - * This is what makes the host's `Port.connect()` -> `attachFrame()` resolve - * and capture the guest SDK version. - * 2. AFTER that, posts a one-shot `window.parent.postMessage({ type: - * 'guest-ready' })`. Since guest SDK >= 1.1.4, the host waits for this - * message (with a `timeout` ms deadline) before marking the guest loaded. - * - * This guest does step 1 but deliberately SKIPS step 2. The extension therefore - * "connects" but never reports as finally loaded, so the host's guest-ready wait - * hangs for the full `timeout` before rejecting. Because the host only fires - * `loadallguests` / clears `host.loading` after ALL guests settle, this single - * never-ready guest stalls the whole extension point -- exactly what stalled the - * RTE's `beforeLoad` readiness gate in production. - */ -export default function ExtensionStuck() { - useEffect(() => { - const hashSearch = window.location.hash.split('?')[1] || ''; - const extensionId = - new URLSearchParams(hashSearch).get('id') || 'ext-stuck'; - - // Same tunnel handshake `register()` performs internally, minus the final - // `guest-ready` postMessage. A large timeout keeps the guest side of the - // tunnel alive well past the host's (shorter) guest-ready deadline. - connectParentWindow( - { targetOrigin: '*', timeout: 60000 }, - { - apis: { - extensionNamespace: { - getMessage: async () => 'Message from stuck guest', - setMessage: async () => 'Success', - }, - }, - emit: async () => {}, - metadata: { id: extensionId, extensions: [] }, - } - ).catch(() => { - // The host tears the tunnel down after its guest-ready timeout; swallow - // the resulting rejection so it doesn't surface as an unhandled error. - }); - }, []); - - return

Guest app stuck view (connects but never reports ready)

; -} diff --git a/e2e/host-app/src/HostApp.jsx b/e2e/host-app/src/HostApp.jsx index 7844185..dea1d57 100644 --- a/e2e/host-app/src/HostApp.jsx +++ b/e2e/host-app/src/HostApp.jsx @@ -59,6 +59,7 @@ export default function Component() { id="iframe-for-guest" key={Math.random()} guestId={extensions[0].id} + allow="microphone; autoplay" src={extensions[0].url.href ? extensions[0].url.href.replace('register', '') : ''} /> diff --git a/e2e/host-app/src/HostAppRteNoExtensions.jsx b/e2e/host-app/src/HostAppRteNoExtensions.jsx deleted file mode 100644 index 8045d24..0000000 --- a/e2e/host-app/src/HostAppRteNoExtensions.jsx +++ /dev/null @@ -1,55 +0,0 @@ -import { useState, useEffect } from 'react'; -import { useHost } from '@adobe/uix-host-react'; - -/** - * Emulates the CF Editor Rich Text Editor's load gate when the `cf-editor` - * extension point resolves to ZERO extensions (e.g. every candidate was - * filtered out for not being PUBLISHED -- see App Registry status filtering). - * - * Mirrors `useRTEBeforeLoad`'s `ready` derivation exactly - * (aem-headless-ui-commons: RichTextEditor/BeforeLoad.ts): - * - no host yet -> not ready - * - host exists, !loading -> ready immediately - * - host exists, loading -> wait for `loadallguests` - * - * Unlike the #/rte-stuck scenario (one guest connects but never reports - * ready, so the host eventually times it out and fires `loadallguests`), - * an empty extensions list never even creates a `Host` (see Extensible.tsx). - * `host` therefore stays `undefined` forever and `ready` can never become - * true -- a permanent hang, not a bounded delay. - */ -export default function HostAppRteNoExtensions() { - const { host } = useHost(); - const [ready, setReady] = useState(false); - - useEffect(() => { - if (!host) { - setReady(false); - return undefined; - } - - if (!host.loading) { - setReady(true); - return undefined; - } - - const onGuestsLoaded = () => setReady(true); - host.addEventListener('loadallguests', onGuestsLoaded); - return () => host.removeEventListener('loadallguests', onGuestsLoaded); - }, [host]); - - return ( -
-

RTE no-extensions scenario

-

{ready ? 'ready' : 'waiting'}

- - {ready ? ( -
- Description field is editable -
- ) : ( -
Loading rich text editor…
- )} -
- ); -} diff --git a/e2e/host-app/src/HostAppRteStuck.jsx b/e2e/host-app/src/HostAppRteStuck.jsx deleted file mode 100644 index c3b7ef9..0000000 --- a/e2e/host-app/src/HostAppRteStuck.jsx +++ /dev/null @@ -1,61 +0,0 @@ -import { useState, useEffect } from 'react'; -import { useHost } from '@adobe/uix-host-react'; - -/** - * Emulates the CF Editor Rich Text Editor's load gate (SITES-49454). - * - * In the real editor, `RichTextEditorTipTap` keeps `contentLoading = true` and - * renders the loading skeleton until `useRTEBeforeLoad().ready` becomes true. - * That `ready` signal is derived ENTIRELY from the extensibility host: it only - * flips once the host has finished handshaking every guest -- i.e. once - * `host.loading` goes false / the `loadallguests` event fires. There is no - * independent fallback timeout on the editor side. - * - * This component reproduces that gate exactly: `ready` starts false (skeleton - * shown) and only becomes true when the host emits `loadallguests`. When one - * guest connects but never reports ready (see ExtentionStuck), the host cannot - * fire `loadallguests` until that guest's connection times out, so the skeleton - * stays up for the full timeout even though the healthy RTE extension connected - * almost immediately. - */ -export default function HostAppRteStuck() { - const { host } = useHost(); - const [ready, setReady] = useState(false); - const [loadedCount, setLoadedCount] = useState(0); - const [failedCount, setFailedCount] = useState(0); - - useEffect(() => { - if (!host) return; - - const onLoadAll = (event) => { - const { loaded = [], failed = [] } = event.detail || {}; - setLoadedCount(loaded.length); - setFailedCount(failed.length); - setReady(true); - }; - - host.addEventListener('loadallguests', onLoadAll); - return () => host.removeEventListener('loadallguests', onLoadAll); - }, [host]); - - return ( -
-

RTE stuck-loading scenario

-

{ready ? 'ready' : 'waiting'}

-

{loadedCount}

-

{failedCount}

- - {ready ? ( -
- Description field is editable -
- ) : ( -
Loading rich text editor…
- )} -
- ); -} diff --git a/e2e/tests/tests/check-button.js b/e2e/tests/tests/check-button.js index f326830..43f4c1f 100644 --- a/e2e/tests/tests/check-button.js +++ b/e2e/tests/tests/check-button.js @@ -13,9 +13,40 @@ test("Check if guest is loaded", async (t) => { .expect(iframe.getAttribute("src")) .contains("http://localhost:3002", "Iframe src should point to guest app", { timeout: 10000 }); + // HostApp passes allow="microphone; autoplay"; it must be merged with, not + // replaced by, the required directive -- including after attachUI() runs + // normalizeIframe() on the mounted frame. await t .expect(iframe.getAttribute("allow")) - .eql("local-network-access", "Guest UI iframe should allow local-network-access", { timeout: 10000 }); + .eql( + "local-network-access; microphone; autoplay", + "Guest UI iframe should merge custom allow directives with local-network-access", + { timeout: 10000 } + ); +}); + +test("Custom allow directives are granted inside the guest UI frame", async (t) => { + await t + .expect(Selector(iframeSelector).exists) + .ok("Iframe should exist", { timeout: 10000 }); + await t.switchToIframe(iframeSelector); + + const allowsFeature = (feature) => + t.eval( + () => { + const policy = document.permissionsPolicy || document.featurePolicy; + return policy ? policy.allowsFeature(feature) : null; + }, + { dependencies: { feature } } + ); + + await t + .expect(await allowsFeature("microphone")) + .ok("Cross-origin guest UI frame should be granted microphone") + .expect(await allowsFeature("autoplay")) + .ok("Cross-origin guest UI frame should be granted autoplay") + .expect(await allowsFeature("camera")) + .notOk("Features not listed in allow must stay blocked"); }); test("Guest server iframe allows local-network-access", async (t) => { diff --git a/e2e/tests/tests/rte-no-extensions.js b/e2e/tests/tests/rte-no-extensions.js deleted file mode 100644 index 0902b4f..0000000 --- a/e2e/tests/tests/rte-no-extensions.js +++ /dev/null @@ -1,39 +0,0 @@ -import { fixture, test, Selector } from "testcafe"; - -/** - * Reproduces the regression introduced by uix-sdk commit d645b96 - * ("Update host render", PR #94, host-rerenders-update): host creation was - * moved inside the `if (!extensions || !Object.keys(extensions).length) return;` - * guard in `Extensible.tsx` -- a guard that previously only skipped calling - * `host.load()`. As a result, when the extension point resolves to ZERO - * extensions, `Host` is never instantiated at all, `useHost()` returns - * `host: undefined` forever, and anything gating readiness on the host - * (like the RTE's `useRTEBeforeLoad`) can never flip to `ready`. - * - * This differs from #/rte-stuck (SITES-49454): there, a non-empty guest - * list means a `Host` IS created and `loadallguests` eventually fires once - * the stuck guest's connection times out (bounded delay). Here, with zero - * extensions, there is nothing to time out -- the hang is permanent. - * - * Setup (#/rte-no-extensions): the extensions provider resolves to `{}`. - */ -fixture("RTE with zero extensions").page("http://localhost:3000/#/rte-no-extensions"); - -test("RTE clears the loading skeleton when there are no extensions to load", async (t) => { - const skeleton = Selector("#rte-skeleton"); - const editor = Selector("#rte-editor"); - const readyFlag = Selector("#ready-flag"); - - // There is nothing to connect to and nothing to wait for, so readiness - // should resolve almost immediately. Currently it never resolves, so this - // assertion times out and the test fails. - await t - .expect(editor.exists) - .ok("RTE editor should be available since there are no extensions to wait for", { - timeout: 5000, - }) - .expect(skeleton.exists) - .notOk("Skeleton must not still be showing once zero extensions is confirmed") - .expect(readyFlag.innerText) - .eql("ready", "Readiness should resolve to true when the extension point has zero extensions"); -}); diff --git a/e2e/tests/tests/rte-stuck-loading.js b/e2e/tests/tests/rte-stuck-loading.js deleted file mode 100644 index 676dead..0000000 --- a/e2e/tests/tests/rte-stuck-loading.js +++ /dev/null @@ -1,69 +0,0 @@ -import { fixture, test, Selector } from "testcafe"; - -/** - * Reproduces the CF Editor RTE "stuck on loading skeleton" incident - * (SITES-49454) at the extensibility-SDK level. - * - * Setup (#/rte-stuck): - * - `ext-ok` : a healthy RTE extension, connects and reports ready instantly. - * - `ext-stuck` : completes the tunnel handshake but NEVER posts `guest-ready`. - * - * The host component gates its "editor" on the host's `loadallguests` event -- - * exactly how the real RTE gates `contentLoading` on `beforeLoadReady`. Because - * the host waits for ALL guests to settle before firing `loadallguests`, the - * never-ready guest stalls the whole extension point: the skeleton stays up for - * the entire guest-ready timeout even though `ext-ok` was ready immediately. - * - * Guest-ready timeout for this scenario is 5000ms (App.js guestOptionsMap), - * standing in for the 20s production default. - */ -fixture("RTE stuck loading").page("http://localhost:3000/#/rte-stuck"); - -test("RTE stays on the loading skeleton while an extension never reports ready", async (t) => { - const skeleton = Selector("#rte-skeleton"); - const editor = Selector("#rte-editor"); - const readyFlag = Selector("#ready-flag"); - - // Give the host time to create iframes and finish the tunnel handshake for - // both guests, but stay well under the 5000ms guest-ready timeout. During - // this window the healthy `ext-ok` has already connected, yet readiness is - // still blocked by `ext-stuck` -- the bug. - await t.wait(3000); - - await t - .expect(skeleton.exists) - .ok("RTE should still show the loading skeleton while a guest is never-ready") - .expect(editor.exists) - .notOk("RTE editor must not be available while the host is still loading") - .expect(readyFlag.innerText) - .eql("waiting", "Readiness signal from the host has not fired yet"); -}); - -test("RTE recovers only after the never-ready guest times out", async (t) => { - const skeleton = Selector("#rte-skeleton"); - const editor = Selector("#rte-editor"); - const readyFlag = Selector("#ready-flag"); - const loadedCount = Selector("#loaded-count"); - const failedCount = Selector("#failed-count"); - - // The RTE only clears its skeleton once the host finally fires - // `loadallguests` -- which cannot happen until `ext-stuck` times out at - // ~5s. This is the "would have loaded after 20-30s" behaviour from the - // incident, compressed to the 5s test timeout. - await t - .expect(editor.exists) - .ok("RTE editor should eventually appear once the host times out the stuck guest", { - timeout: 15000, - }) - .expect(skeleton.exists) - .notOk("Skeleton should be gone once the editor is ready") - .expect(readyFlag.innerText) - .eql("ready", "Host readiness signal has fired"); - - // The healthy extension loaded; the stuck one is reported as failed. - await t - .expect(loadedCount.innerText) - .eql("1", "Exactly the healthy extension should be reported as loaded") - .expect(failedCount.innerText) - .eql("1", "The never-ready extension should be reported as failed"); -});