Repository navigation
test(Dialog, Popover): the second-document stories skip only cross-origin style sheets - #9063
Conversation
…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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewNo new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: The accessibility audit did not run on this pull request. It runs after merges to Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
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]
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,
adoptPageStylesskips a sheet only when itshreforigin differs from the page's, and any other error throws. Story code only: no package source changes, so no changeset.Evidence
cssRulesthrows aSecurityErroronly for the cross-origin sheet; same-origin and inline sheets read fine and are copied.Scope
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).--project=webkit(WebKit 26.5): 7 passed, and the 3 Picture-in-Picture cases are skipped, since only Chromium has that window.cssRules.pnpm check:repo, ESLint and Prettier pass. Changeset coverage: nothing here ships to consumers.adoptPageStyles,DialogSecondDocumentA11y.stories.tsxandPopoverSecondDocumentA11y.stories.tsx: none touches either story or the helper.