Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

test(Lightbox): the viewport spec skips only a cross-origin stylesheet (#9064)

Christopher Chedeau9a642cf320a6
diff --git a/packages/core/src/Lightbox/LightboxViewport.a11y.browser.spec.ts b/packages/core/src/Lightbox/LightboxViewport.a11y.browser.spec.ts
index 2ca28e5a2c..0e0061c9ef 100644
--- a/packages/core/src/Lightbox/LightboxViewport.a11y.browser.spec.ts
+++ b/packages/core/src/Lightbox/LightboxViewport.a11y.browser.spec.ts
@@ -57,11 +57,15 @@ test('the viewer is as tall as the dynamic viewport, so a toolbar never covers i
}
};
for (const sheet of Array.from(document.styleSheets)) {
- try {
- walk(sheet.cssRules);
- } catch {
- // A cross-origin stylesheet's rules are unreadable and not ours.
+ // A cross-origin stylesheet's rules are unreadable, and not ours: skip
+ // only such a sheet, so any other error still fails the proof.
+ if (
+ sheet.href != null &&
+ new URL(sheet.href, document.baseURI).origin !== location.origin
+ ) {
+ continue;
}
+ walk(sheet.cssRules);
}
return {heights, supported: CSS.supports('height', '100dvh')};
});