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

Update error message to be more specific about same-origin policy #6118

Merged
merged 31 commits into from
Feb 24, 2020

Conversation

jennifer-shehane
Copy link
Member

@jennifer-shehane jennifer-shehane commented Jan 8, 2020

User facing changelog

The error messages displayed when rerouting to a non same-origin domain has been updated to more accurately reflect the rules around same-origin policy.

Additional details

The test below fails in Cypress (this is as designed). The problem is that the error message says you can only visit the same superdomain, so users are like....uh....these are the same superdomain.

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

The actual same-origin policy qualifies that two URLs have the same origin if the protocol, port (if specified), and host are the same. So the error message is now more specific about this and will link to a better written doc also.

How has the user experience changed?

Before (cross origin error)

Screen Shot 2020-02-12 at 11 02 35 AM

After (cross origin error)

Screen Shot 2020-02-12 at 11 00 39 AM

Before (visit error)

Screen Shot 2020-01-08 at 3 25 26 PM

After (visit error)

When different protocol

Screen Shot 2020-02-24 at 1 19 42 PM

When different port

Screen Shot 2020-02-24 at 1 20 08 PM

When different superdomain

Screen Shot 2020-02-24 at 1 20 23 PM

When all different

Screen Shot 2020-02-24 at 1 20 39 PM

PR Tasks

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jan 8, 2020

Thanks for the contribution! Below are some guidelines Cypress uses when doing PR reviews.

  • Please write [WIP] in the title of your Pull Request if your PR is not ready for review - someone will review your PR as soon as the [WIP] is removed.
  • Please familiarize yourself with the PR Review Checklist and feel free to make updates on your PR based on these guidelines.

PR Review Checklist

If any of the following requirements can't be met, leave a comment in the review selecting 'Request changes', otherwise 'Approve'.

User Experience

  • The feature/bugfix is self-documenting from within the product.
  • The change provides the end user with a way to fix their problem (no dead ends).

Functionality

  • The code works and performs its intended function with the correct logic.
  • Performance has been factored in (for example, the code cleans up after itself to not cause memory leaks).
  • The code guards against edge cases and invalid input and has tests to cover it.

Maintainability

  • The code is readable (too many nested 'if's are a bad sign).
  • Names used for variables, methods, etc, clearly describe their function.
  • The code is easy to understood and there are relevant comments explaining.
  • New algorithms are documented in the code with link(s) to external docs (flowcharts, w3c, chrome, firefox).
  • There are comments containing link(s) to the addressed issue (in tests and code).

Quality

  • The change does not reimplement code.
  • There's not a module from the ecosystem that should be used instead.
  • There is no redundant or duplicate code.
  • There are no irrelevant comments left in the code.
  • Tests are testing the code’s intended functionality in the best way possible.

Internal

  • The original issue has been tagged with a release in ZenHub.

@cypress
Copy link

cypress bot commented Jan 8, 2020



Test summary

6946 0 97 0


Run details

Project cypress
Status Passed
Commit a75221a
Started Feb 24, 2020 7:22 AM
Ended Feb 24, 2020 7:27 AM
Duration 05:25 💡
OS Linux Debian - 9.11
Browser Multiple

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@jennifer-shehane jennifer-shehane changed the title update error message to be more specific about same-origin policy [WIP] update error message to be more specific about same-origin policy Jan 8, 2020
@jennifer-shehane jennifer-shehane changed the title [WIP] update error message to be more specific about same-origin policy Update error message to be more specific about same-origin policy Feb 3, 2020
# Conflicts:
#	packages/driver/src/cypress/error_messages.coffee
#	packages/server/__snapshots__/6_web_security_spec.coffee.js
@jennifer-shehane jennifer-shehane requested review from a team, flotwig and chrisbreiding and removed request for a team February 3, 2020 09:18
@flotwig
Copy link
Contributor

flotwig commented Feb 3, 2020

The actual same-origin policy qualifies that two URLs have the same origin if the protocol, port (if specified), and host are the same. So the error message is now more specific about this and will link to a better written doc also.

Can we mention this in the error somehow? I feel like this is the most important information for the user to understand the error, and yet it is not mentioned anywhere in the error.

packages/driver/src/cypress/error_messages.coffee Outdated Show resolved Hide resolved
packages/driver/src/cypress/error_messages.coffee Outdated Show resolved Hide resolved
packages/driver/src/cypress/error_messages.coffee Outdated Show resolved Hide resolved
packages/driver/src/cypress/error_messages.coffee Outdated Show resolved Hide resolved
packages/driver/src/cypress/error_messages.coffee Outdated Show resolved Hide resolved
jennifer-shehane and others added 6 commits February 4, 2020 21:50
Co-Authored-By: Zach Bloomquist <github@chary.us>
Co-Authored-By: Zach Bloomquist <github@chary.us>
Co-Authored-By: Zach Bloomquist <github@chary.us>
Co-Authored-By: Zach Bloomquist <github@chary.us>
Co-Authored-By: Zach Bloomquist <github@chary.us>
Copy link
Contributor

@flotwig flotwig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual same-origin policy qualifies that two URLs have the same origin if the protocol, port (if specified), and host are the same. So the error message is now more specific about this and will link to a better written doc also.

Can we mention this in the error somehow? I feel like this is the most important information for the user to understand the error, and yet it is not mentioned anywhere in the error.

@jennifer-shehane jennifer-shehane changed the title Update error message to be more specific about same-origin policy [WIP] Update error message to be more specific about same-origin policy Feb 12, 2020
@jennifer-shehane
Copy link
Member Author

@flotwig OK! I updated this again off of Brian's suggestion. A new specific error will show for each scenario - so different messages for if different port, protocol, or superdomain.

@jennifer-shehane jennifer-shehane changed the title [WIP] Update error message to be more specific about same-origin policy Update error message to be more specific about same-origin policy Feb 13, 2020
packages/driver/src/cypress/error_messages.coffee Outdated Show resolved Hide resolved
packages/driver/src/cypress/error_messages.coffee Outdated Show resolved Hide resolved
packages/driver/src/cypress/error_messages.coffee Outdated Show resolved Hide resolved
packages/driver/src/cypress/error_messages.coffee Outdated Show resolved Hide resolved
packages/driver/src/cypress/error_messages.coffee Outdated Show resolved Hide resolved
packages/driver/src/cypress/error_messages.coffee Outdated Show resolved Hide resolved
packages/driver/src/cypress/error_messages.coffee Outdated Show resolved Hide resolved
packages/driver/src/cy/commands/navigation.coffee Outdated Show resolved Hide resolved
packages/driver/src/cy/commands/navigation.coffee Outdated Show resolved Hide resolved
packages/driver/src/cypress/error_messages.coffee Outdated Show resolved Hide resolved
jennifer-shehane and others added 8 commits February 18, 2020 23:39
Co-Authored-By: Zach Bloomquist <github@chary.us>
Co-Authored-By: Zach Bloomquist <github@chary.us>
Co-Authored-By: Zach Bloomquist <github@chary.us>
Co-Authored-By: Zach Bloomquist <github@chary.us>
Co-Authored-By: Zach Bloomquist <github@chary.us>
Co-Authored-By: Zach Bloomquist <github@chary.us>

You may only visit a single unique domain per test.
The new URL is considered a different origin because the following parts of the URL are different: {{differences}}
Copy link
Contributor

@flotwig flotwig Feb 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this could be improved to be a little more natural-sounding with 1 item, but eh, this is probably clear enough. what do you think? here's what i mean, with 1 list item it sounds like this:

The new URL is considered a different origin because the following parts of the URL are different: port

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error messages aren't great to work with as are and need the error improvements PR to make this a function which could actually be manipulated easier to write this more natural. So, this is good as is.

flotwig
flotwig previously approved these changes Feb 18, 2020
Copy link
Contributor

@flotwig flotwig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

Co-Authored-By: Zach Bloomquist <github@chary.us>
flotwig
flotwig previously approved these changes Feb 18, 2020
@chrisbreiding chrisbreiding removed their request for review February 19, 2020 03:12
@jennifer-shehane
Copy link
Member Author

Updated the 'differences' to be indented as well as the urls for better readability off of @brian-mann suggestions.

@jennifer-shehane jennifer-shehane merged commit 844a1bd into develop Feb 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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