/sitecore-marketplace:marketplace-sdk-host-frame-testingfrom Sitecore Marketplace
Captures clipped screenshots of a Marketplace app iframe inside its real Sitecore host (Cloud Portal, Pages, Dashboard) for visual regression testing. Requires Playwright MCP browser and interactive auth.
Ships in Sitecore Marketplace. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
A standalone localhost:3000 hit is not an acceptable substitute. Marketplace apps depend on XMC.host, XMC.context, theme, locale, and auth coming from the parent frame — they render blank or in error state outside of the host.
| Input | Example | Purpose |
|---|---|---|
| Host URL | https://xmcloud.sitecore.com/.../pages?context=... | The deep link into the Sitecore surface that embeds the app. |
| App origin | https://localhost:3000 (dev) or the registered Marketplace app URL | Used as the iframe locator pattern (iframe[src*="<origin>"]). |
| Auth confirmation | "I'm logged in" / "I'll log in when the browser opens" | Agent stays interactive; never tries to script SSO. |
If any of the three is missing, ask for it and stop — do not proceed with a fake or guessed host URL.
Do not attempt to script Sitecore SSO. Do not try to inject cookies, tokens, or storage state. The agent's contract:
READY (or equivalent confirmation) before continuing.READY, run a probe — browser_snapshot — and verify the page is not the Sitecore login screen by checking for the host's authenticated chrome (e.g., portal navigation, app launcher). If it still looks like a login page, ask the user to confirm again.No persisted storage state. Each test run starts a fresh browser session and goes through interactive login. This is by explicit preference — do not introduce a "remember me" optimization without asking.
Marketplace apps are always iframed by their extension point. The locator pattern is:
iframe[src*="<app-origin>"]
Use Playwright's locator API — never reach into iframe DOM via raw JS evaluation against an unknown origin.
browser_snapshot to get an accessibility tree of the host page; verify the iframe is visible.page.locator('iframe').filter({ has: ... }) or directly inspect frames via page.frames(). Each frame exposes .url(); pick the one whose URL contains the app origin.Common locator failures and how to recover:
| Symptom | Likely cause | Recovery |
|---|---|---|
| Zero iframes match | App not loaded into this host context yet | Ask user to navigate to the page/panel where the app appears, then retry |
| Multiple iframes match same origin | App is a Page extension AND a ContextPanel extension and both mounted | Pick by extension-point hint in the URL query (e.g. ?placement=context-panel) — ask the user which one to test |
Iframe src is blank or about:blank | Lazy mount; iframe exists but app hasn't booted | browser_wait_for until the src becomes the app origin (timeout 30s) |
Iframe is chrome-error://chromewebdata/ | Self-signed cert rejected (see the marketplace-sdk-testing-debug skill's references/https-traps.md § 2) | Stop and tell the user — this is a local-cert problem, not a test failure |
Once the iframe is located, get its bounding box in the parent page's coordinate space and pass it as the clip rectangle to browser_take_screenshot.
// Use a Playwright locator (not raw page.evaluate) so this works cross-origin.
// boundingBox() returns the iframe's position in the top-level document — exactly
// what we need for screenshot clipping, regardless of the iframe's content origin.
const iframeLocator = page.locator(`iframe[src*="${APP_ORIGIN}"]`).first();
const box = await iframeLocator.boundingBox();
if (!box || box.width === 0 || box.height === 0) {
// App iframe is mounted but invisible (display:none / collapsed) or not present.
// See § 8b for triage.
throw new Error('App iframe has no visible bounding box');
}
await page.screenshot({
path: 'test-evidence/state-<name>.png',
clip: {
x: Math.round(box.x),
y: Math.round(box.y),
width: Math.round(box.width),
height: Math.round(box.height),
},
});
Why this works: screenshot clipping operates on the parent page's pixels — it does not require entering the iframe's content document, so it works equally well for same-origin and cross-origin iframes. This is the core reason this approach holds up even when the app is at localhost:3000 and the host is xmcloud.sitecore.com.
Evidence file naming: test-evidence/<state-name>-<timestamp>.png under the product folder. Embed in the test report via relative markdown image links.
Once you've captured the empty / loaded state, drive the app through PRD acceptance criteria.
Raw JS evaluation cannot reach into the frame's DOM, but Playwright does support cross-origin frame interaction via locators. Use page.frameLocator('iframe[src*="<origin>"]'):
const appFrame = page.frameLocator(`iframe[src*="${APP_ORIGIN}"]`);
await appFrame.getByRole('button', { name: 'Copy Live URL' }).click();
await appFrame.getByRole('status').waitFor({ state: 'visible' });
// ... then re-clip the iframe (§ 4) to capture the new visual state
What does NOT work cross-origin:
document from the parentdocument from the parent contextiframe.contentDocumentWhat DOES work:
getByRole, getByText, getByTestId, locator(selector))For state coverage that genuinely requires DOM read access (e.g., "verify computed background color of element X"), fall back to visual diff against the POC instead — that is the canonical truth path for this skill.
This section applies only if your project produced a POC clickdummy during design (typically at pocs/poc-vN/index.html under the project root). If your workflow does not use POC clickdummies, skip this section — the clipped iframe screenshots from § 4–5 are themselves the run's evidence; record them in the test report and judge against the PRD's acceptance criteria directly.
The winning POC clickdummy is the visual baseline for first-run testing when it exists. The five-axis comparison below grounds visual judgment in something explicit instead of leaving "looks right" to memory.
Open the POC in a second Playwright tab at the same viewport size as the iframe's bounding box (so the POC's rendered width matches the host-frame clip width).
Take a screenshot of the POC at the same logical state (e.g., "default", "after copy", "error state"). The POC must support these states — that's why architecture mandates state coverage.
Place the two images side-by-side in the test report (| Host clip | POC reference | table row per state).
Compare on five axes, scoring PASS / WARN / FAIL with a one-line note each:
@blok/* shapes (no fabricated approximations)Threshold for FAIL: any axis where the host clip and the POC diverge in a way that a Sitecore user would perceive as "not Blok" or "not the agreed design." Subjective judgment is fine — the QA reviewer names what they see.
The POC stays as ground truth across subsequent runs unless the design is intentionally changed. If the user asks for a design change post-implementation:
Do not silently promote a host-frame screenshot to "new baseline" without an explicit POC update — that defeats the design-discipline purpose of the POC.
Embed in your project's test report (e.g. <project>/plans/test-report-<timestamp>.md, or wherever your workflow tracks test evidence):
## Visual Testing — Host-Frame (Marketplace)
**Host URL:** `<URL the user supplied>`
**App origin:** `<origin>`
**POC reference:** `pocs/poc-vN/index.html` (winning variant)
**Auth:** interactive (user logged in at <time>)
**Browser viewport:** <width>x<height>
**Iframe clip box:** x=<x> y=<y> w=<w> h=<h>
### State coverage
| State | Host clip | POC reference | Layout | Typography | Color | Anatomy | State | Verdict |
|-------|-----------|---------------|--------|------------|-------|---------|-------|---------|
| Default |  |  | PASS | PASS | PASS | PASS | PASS | PASS |
| After copy |  |  | PASS | PASS | WARN — chip color slightly off | PASS | PASS | WARN |
| Error |  |  | PASS | PASS | PASS | PASS | FAIL — error ring not red | FAIL |
### Findings carried into the report
- (one row per FAIL or WARN, with severity and a proposed fix)
The user gives a URL into a Sitecore surface that doesn't yet have the test app registered → no iframe matches the origin. Symptom is identical to "app crashed." Always check the marketplace-sdk-testing-debug skill, § 2, first — is the test app actually installed in this environment?
Bounding box has zero width or height. Clip rectangle would be invalid. Check width > 0 && height > 0 before screenshotting; if zero, the app's extension point is registered but not currently displayed — ask the user to navigate to the surface where it appears.
The host iframe might be 320x600 (Context Panel) while the POC was authored at desktop 1280x800. Open the POC at the iframe's clip dimensions when comparing — otherwise spacing and breakpoints will diverge for cosmetic reasons unrelated to implementation quality.
Read the host's applied theme (visible in the host's portal chrome) and toggle the POC to match before comparison. Both POC and host should expose a theme toggle (per architecture's Blok requirements).
Some Marketplace iframe features (downloads, popups, clipboard) are subject to the iframe sandbox attribute (see the marketplace-sdk-testing-debug skill, § 7a). If a state can't be reached because the sandbox blocks it, that's an environmental finding — record it as a sandbox observation, not as a failed test.
When testing a Marketplace app: the canonical visual test target is the clipped iframe inside the host, not a standalone localhost render. Standalone-render testing is acceptable only as a smoke-level sanity check (does the app boot at all?) — it never substitutes for host-frame testing. The winning POC clickdummy is the first-run ground truth; do not promote host-frame screenshots to baselines silently.
When fixing host-frame findings: re-run the same host-frame check (not a localhost re-render) to verify the fix. The user does not need to re-supply the host URL within a single test session — reuse it.
When orchestrating visual testing: before starting, ask the user for the host URL and app origin if the project is a Marketplace app. Do not proceed with visual testing if either is missing. Auth is always interactive — do not persist storage state.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub chris1415/sitecore-skills-pocs --plugin sitecore-marketplace7 skills in this plugin
/marketplace-sdk-aiAPI reference for @sitecore-marketplace-sdk/ai: module vs experimental client, generateBrandReview, payload traps, file inputs. Load when a Marketplace app calls AI skills such as brand review or content compliance./marketplace-sdk-clientAPI reference for @sitecore-marketplace-sdk/client: ClientSDK.init, provider patterns, query, mutate, subscribe, extension points, custom-field values, errors, test stubs. Entry point for any Marketplace app talking to the Cloud Portal./marketplace-sdk-extension-routes