Skip to content

Cross-link cy.origin and injectDocumentDomain #6156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions docs/api/commands/origin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ doc.

Cypress no longer injects `document.domain` by default, which means `cy.origin()`
must now be used to navigate between any two origins in the same test, even if
the two origins are in the same superdomain. This behavior can be disabled by setting
the `injectDocumentDomain` configuration option to `true`, to allow a smooth transition
of tests to the new behavior. This configuration option will be removed in a future version of Cypress.
the two origins are in the same superdomain.
This behavior can be disabled by setting the
[injectDocumentDomain](/app/references/configuration#injectDocumentDomain) configuration option to `true`,
to allow a smooth transition of tests to the new behavior.
This configuration option will be removed in a future version of Cypress.

:::

Expand Down
11 changes: 6 additions & 5 deletions docs/app/references/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -603,17 +603,18 @@ This option is <Badge type="caution">deprecated</Badge>, and will be removed in

Set this configuration option to `true` to instruct Cypress to
[inject document.domain](/app/guides/cross-origin-testing#What-Cypress-does-under-the-hood)
into your test application. This can reduce the need for `cy.origin()` when [navigating
between subdomains](/app/guides/cross-origin-testing), but comes with compatibility
caveats for some sites.
into your test application.
This can reduce the need for [`cy.origin()`](/api/commands/origin)
when [navigating between subdomains](/app/guides/cross-origin-testing),
but comes with compatibility caveats for some sites.

This configuration option is provided to ease the transition between `cy.origin()`'s behavior
This configuration option is provided to ease the transition between [`cy.origin()`](/api/commands/origin)'s behavior
in Cypress 13 and the default behavior in Cypress 14.
[Read the Cypress 14 migration guide](/app/references/migration-guide#Migrating-to-Cypress-140) to understand how to update your tests to remove
the need to set this flag.

This configuration value _must_ be set to true if you are running tests with experimental
WebKit support, as `cy.origin` is not yet supported in WebKit.
WebKit support, as [`cy.origin()`](/api/commands/origin) is not yet supported in WebKit.

:::caution

Expand Down
5 changes: 3 additions & 2 deletions docs/partials/_document-domain-workaround.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ This means you must now use `cy.origin()` when navigating between different _ori
in the same test. Previously, `cy.origin()` was only necessary when navigating between
different [superdomains](/app/guides/cross-origin-testing#Parts-of-a-URL) in the same test.

By setting the `injectDocumentDomain` configuration option to `true`, Cypress will
attempt to inject `document.domain` into `text/html` pages.
By setting the
[injectDocumentDomain](/app/references/configuration#injectDocumentDomain) configuration option to `true`,
Cypress will attempt to inject `document.domain` into `text/html` pages.

A superdomain is comprised of the trailing two elements of the hostname, delimited by
a `.` (period). Given `https://www.cypress.io`, the superdomain is determined to be
Expand Down