Incorrect document.domain
See original GitHub issueCurrent behavior:
When running Cypress against a subdomain (e.g. sub.example.com), document.domain
is reported as example.com
.
Desired behavior:
document.domain
should be the full domain name sub.example.com
.
Steps to reproduce:
Run a Cypress test against a subdomain:
cy.visit("https://en.m.wikipedia.org/wiki/Main_Page")
Then run document.domain
in the dev console. Expected output: "en.m.wikipedia.org"
.
Versions
Latest Cypress using Chrome Canary.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Document.domain - Web APIs - MDN Web Docs
The domain property of the Document interface gets/sets the domain portion of the origin of the current document, as used by the same-origin ......
Read more >Chrome solution for document.domain - Stack Overflow
domain = "foo.com" // Still ok document.domain = "bar.foo.com" // Invalid, you can't change it back to a more specific domain.
Read more >What is document domain, and how do I change it?
Changing domains. To change your domain/document type in the Grammarly Editor, select Goals on the right. In the window that opens next, ...
Read more >Problem with document.domain - CodeRanch
I am working with popup windows which are stored in two different domains(say server1 and server2). Hence I try to set the document.domain=" ......
Read more >15313 – Same-origin check wrong when document.domain set
Internet Explorer 6: Protocol mismatch, document.domain set: Denied. ... its document.domain, the old code "worked" because it incorrectly ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We reviewed this as a team and have decided that while this is unexpected behavior, we won’t be changing this behavior in Cypress today.
With the way Cypress works today, we have to set the
document.domain
in this way to avoid issues with visiting other subdomains. If this is causing problems within your testing, we suggest updating your application code, so that when visiting during testing, within a testing environment, it removes any limitations around thedocument.domain
issue.To more directly address @tdelphi, in this case, from the information you provided, we would recommend turning off the OWASP CSRFGuard restrictions during testing.
A simple way to check if your application is running while being visited within Cypress can be found here. I’d suggest a combination of detecting Cypress and also knowing that the tests are being run from within your own development team - then changing the application logic in this instance.
@nicojs I’m not sure about the issue you are encountering exactly, since you never described it, so let us know if there is some limitations to our suggestion.
We’re always welcome to reconsider fixing this or offering a better workaround or errors in the future. So, please comment if you have objections to our suggestion.
We have the same situation with a very old application. This is preventing us from using cypress for testing…We were hoping to move from Selenium to Cypress…
Why can’t this be configurable?