diff --git a/.changeset/rotten-rats-carry.md b/.changeset/rotten-rats-carry.md new file mode 100644 index 00000000000..3e15355ba88 --- /dev/null +++ b/.changeset/rotten-rats-carry.md @@ -0,0 +1,5 @@ +--- +'@clerk/clerk-js': patch +--- + +Fix Cypress setting cookies as third-party diff --git a/packages/clerk-js/src/utils/runtime.ts b/packages/clerk-js/src/utils/runtime.ts index fbd7d7a8d5d..06a40433579 100644 --- a/packages/clerk-js/src/utils/runtime.ts +++ b/packages/clerk-js/src/utils/runtime.ts @@ -10,8 +10,14 @@ export function usesHttps() { return inBrowser() && window.location.protocol === 'https:'; } +function isCypress() { + return typeof window !== 'undefined' && typeof (window as any).Cypress !== 'undefined'; +} + export function inIframe() { - return inBrowser() && window.self !== window.top; + // checks if the current window is an iframe + // excludes the case where the current window runs in a Cypress test + return inBrowser() && window.self !== window.top && !isCypress(); } export function inCrossOriginIframe() {