Skip to content

test(Dialog, Popover): the second-document stories skip only cross-origin style sheets - #9063

Merged
cixzhang merged 1 commit into
meta:mainfrom
vjeux:dialog-story-cross-origin-skip
Oct 31, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
vjeux:dialog-story-cross-origin-skip

Conversation

@vjeux

@vjeux vjeux commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

The Dialog and Popover second-document stories' style copy now skips only stylesheets from another origin, which the browser won't let them read, and lets any other error throw, so a real failure isn't hidden. Found in a review of error handling and split out of #8381 so it could merge as is.

Maintainer impact

Both stories copy the page's style sheets into a same-origin iframe and a Document Picture-in-Picture window, where the second-document browser specs run. The copy wrapped each sheet in a catch that ignored every error, so a broken copy would fail silently and leave those frames unstyled.

Intended invariant

The stories copy every same-origin and inline sheet, as before. A cross-origin sheet, which the browser forbids reading, is still skipped. The specs that use these stories behave the same.

Change

In both stories, adoptPageStyles skips a sheet only when its href origin differs from the page's, and any other error throws. Story code only: no package source changes, so no changeset.

Evidence

  • Failure before the change: any error while copying a sheet was swallowed, with nothing reported.
  • Success after the change: in Chromium 149 and WebKit 26.5, reading cssRules throws a SecurityError only for the cross-origin sheet; same-origin and inline sheets read fine and are copied.
  • Product/runtime behavior verified unchanged: the Dialog and Popover second-document specs pass.

Scope

  • No intended public API, product behavior, visual direction, or policy change.
  • Product changes discovered during the work were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

Local gates at a2492d4 (on main d48bca5):

  • pnpm exec playwright test packages/core/src/Dialog/__tests__/DialogSecondDocument.a11y.browser.spec.ts packages/core/src/Popover/__tests__/PopoverSecondDocument.a11y.chromium.spec.ts --project=chromium: 27 passed (10 Dialog, 17 Popover).
  • The Dialog spec with --project=webkit (WebKit 26.5): 7 passed, and the 3 Picture-in-Picture cases are skipped, since only Chromium has that window.
  • A page with a same-origin, a cross-origin and an inline sheet, in Chromium and WebKit: only the cross-origin sheet throws on cssRules.
  • The story typecheck (no errors in either story), the Storybook build, pnpm check:repo, ESLint and Prettier pass. Changeset coverage: nothing here ships to consumers.
  • Prior art: searched all 596 open pull requests for changes to adoptPageStyles, DialogSecondDocumentA11y.stories.tsx and PopoverSecondDocumentA11y.stories.tsx: none touches either story or the helper.

…igin style sheets

The Dialog and Popover second-document stories copy the page's style sheets
into the iframe and the Picture-in-Picture window. Their catch swallowed every
error in that copy, so a real failure there would pass unseen. They now skip
only a sheet from another origin, which the browser does not let a page read,
and let any other error throw.
@vercel

vercel Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 30, 2026 10:21pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 30, 2026
@astracat-bot

astracat-bot Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 30, 2026, 10:37 PM UTC

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

No new or modified components detected.

Bundle Size Summary

No component packages changed.

Accessibility Audit

Status: The accessibility audit did not run on this pull request. It runs after merges to main and before each release; pull requests that touch components run it with the ci:heavy-lanes label.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks ready: both second-document stories still copy every style sheet they hold into the iframe, and the Dialog and Popover second-document specs give the same results before and after the change. CI has not run on the draft, and its browser-spec job, which would pick up the Dialog spec for this story, runs only with the ci:heavy-lanes label.

Optional: the guard decides by URL origin rather than readability, so a cross-origin sheet served with CORS would now be skipped and a same-origin URL that redirects to another origin would throw; neither occurs in this Storybook, and catching only SecurityError would match the code comment exactly.

[Automated review]

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Oct 31, 2026
@cixzhang
cixzhang marked this pull request as ready for review October 31, 2026 01:01
@cixzhang
cixzhang merged commit 4413083 into meta:main Oct 31, 2026
136 of 140 checks passed
@vjeux
vjeux deleted the dialog-story-cross-origin-skip branch October 31, 2026 01:38

This branch was successfully deployed

1 active deployment
Preview — a2492d44 Deployed Oct 30, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants