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

Handle localStorage logic in case it is blocked #5953

Merged
merged 8 commits into from
Sep 17, 2020

Conversation

anselmbradford
Copy link
Member

@anselmbradford anselmbradford commented Aug 24, 2020

If cookies are completely blocked, an error is thrown Failed to read the 'localStorage' property from 'Window': Access is denied for this document.

Changes

  • Utilize web-storage-proxy utility script where localStorage/sessionStorage is used.
  • Try…catch to see if localStorage is available, and if not, gracefully fall back.

How to test this PR

  1. Go into Chrome settings via Settings > Privacy and Security > Cookies and other site data
  2. Check "Block all cookies (not recommended)"
  3. Visit https://www.consumerfinance.gov/owning-a-home/ and scroll down and see errors in dev console.
  4. Pull branch and build and run locally. Visit http://localhost:8000/owning-a-home/ and scroll down and see that there are no errors in the dev console.

Notes and todos

  • The "orange-explorer" has some direct references to localStorage too, but that page is a large inlined frankenstein monster I'm not going to touch in this PR. EDIT: This tool will be sunset next month!

@anselmbradford anselmbradford requested a review from a team August 24, 2020 17:03
@anselmbradford anselmbradford force-pushed the ans_localstorage_fallback branch 3 times, most recently from 64035a9 to 900d823 Compare August 24, 2020 18:42
@anselmbradford anselmbradford changed the title Fix localStorage logic in case it is blocked Handle localStorage logic in case it is blocked Aug 24, 2020
@willbarton willbarton changed the base branch from master to main September 1, 2020 18:08
Copy link
Member

@wpears wpears left a comment

Choose a reason for hiding this comment

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

Just the one question

cfgov/unprocessed/js/modules/util/email-popup-helpers.js Outdated Show resolved Hide resolved
Copy link
Member

@wpears wpears left a comment

Choose a reason for hiding this comment

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

Giving the rare double approve on this fine piece of work
👍 👍

@anselmbradford anselmbradford merged commit f2a0f62 into main Sep 17, 2020
@anselmbradford anselmbradford deleted the ans_localstorage_fallback branch September 17, 2020 21:14
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.

2 participants