Skip to content
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

visiting https then http of same subdomain fails saying you can only visit a single unique domain per test #6048

Closed
mingyixu opened this issue Dec 26, 2019 · 6 comments · Fixed by #6118
Labels
pkg/driver This is due to an issue in the packages/driver directory type: error message

Comments

@mingyixu
Copy link

mingyixu commented Dec 26, 2019

what_it_does:

CypressError: cy.visit() failed because you are attempting to visit a second unique domain.

You may only visit a single unique domain per test.

Different subdomains are okay, but unique domains are not.

The previous domain you visited was: 'https://www.sina.com.cn'

You're attempting to visit this new domain: 'http://sports.sina.com.cn'

http://sports.sina.com.cn is subdomain , but error.
https://sports.sina.com.cn is ok.

Current behavior:

Desired behavior:

Steps to reproduce: (app code and test code)

Versions

Cypress: 3.8.0 │
Browser: Electron 78 (headless)

@hieutrandn9889
Copy link

That is the same my problem

@jennifer-shehane
Copy link
Member

Visiting an http subdomain after visiting a https subdomain fails. This should not fail.

I thought this may be a regression, but this happens all the way back to Cypress version 2 even.

it('visit https after http subdomain', () => {
  cy.visit('https://www.cypress.io')
  cy.visit('http://docs.cypress.io') // fails
})

it('visit http after https subdomain', () => {
  cy.visit('http://www.cypress.io')
  cy.visit('https://docs.cypress.io') // passes
})

https then visit http subdomain

Screen Shot 2019-12-30 at 5 01 09 PM

http then visit https subdomain

Screen Shot 2019-12-30 at 5 11 28 PM

@cypress-bot cypress-bot bot added the stage: needs investigating Someone from Cypress needs to look at this label Dec 30, 2019
@jennifer-shehane jennifer-shehane added type: bug stage: needs investigating Someone from Cypress needs to look at this and removed stage: needs investigating Someone from Cypress needs to look at this labels Dec 30, 2019
@jennifer-shehane jennifer-shehane changed the title http, https visit a single unique domain per test visiting https then http of same subdomain fails saying you can only visit a single unique domain per test Dec 30, 2019
@jennifer-shehane
Copy link
Member

Why

Ok, so, after discussing this with the team, this is actually expected behavior.

The rules for what we have been calling a 'single unique domain per test' are technically following the rules of Same Origin Policy as outlined here: https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy

Two URLs have the same origin if the protocol, port (if specified), and host are the same for both.

So visiting a different protocol (http to https) is not considered the same protocol.

The reason the http to https often works is because of the websites rerouting rules.

Next steps

  1. The error message we are throwing in the Test Runner is completely confusing in this regard. We only mention a 'single domain' policy and should be more specific to call out same origin policy. This error message should be updated.
  2. The documentation is just wrong. We talk about superdomain and then even mention http and https specifically being the same and following the rules. https://on.cypress.io/trade-offs#Same-origin I've created an issue to update this here: Update mention of 'single domain' to be more specific about 'cross-origin' cypress-documentation#2364

@cypress-bot cypress-bot bot added stage: ready for work The issue is reproducible and in scope and removed stage: needs investigating Someone from Cypress needs to look at this labels Jan 8, 2020
@jennifer-shehane jennifer-shehane added pkg/driver This is due to an issue in the packages/driver directory external: documentation labels Jan 8, 2020
@jennifer-shehane
Copy link
Member

There's a pull request to update the messaging of this error. The behavior is not in error nor a bug. This is expected behavior, but the messaging needs updating. #6118

@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review stage: work in progress and removed stage: ready for work The issue is reproducible and in scope stage: needs review The PR code is done & tested, needs review stage: work in progress labels Feb 3, 2020
@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: needs review The PR code is done & tested, needs review stage: work in progress labels Feb 11, 2020
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: work in progress labels Feb 18, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Feb 24, 2020

The code for this is done in cypress-io/cypress#6118, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot cypress-bot bot removed the stage: needs review The PR code is done & tested, needs review label Feb 24, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Feb 28, 2020

Released in 4.1.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v4.1.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Feb 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pkg/driver This is due to an issue in the packages/driver directory type: error message
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants