fix(docs-infra): do not break when cookies are disabled in the browser#33829
fix(docs-infra): do not break when cookies are disabled in the browser#33829ajitsinghkaler wants to merge 1 commit intoangular:masterfrom
Conversation
|
@gkalpak I have issued a pull request can you guide me through the next steps. |
gkalpak
left a comment
There was a problem hiding this comment.
Nice!
The next step would be to add a test for this (something that would fail without your fix and passes with the fix). The unit tests for ScrollService are in aio/src/app/shared/scroll.service.spec.ts, so you could add a test somewhere here:
it('should not break when cookies are disabled in the browser', () => {
// Simulate `window.sessionStorage` being inaccessible, when cookies are disabled.
spyOnProperty(window, 'sessionStorage', 'get').and.throwError('The operation is insecure');
expect(() => {
const platformLoc = platformLocation as PlatformLocation;
const service = new ScrollService(document, platformLoc, viewportScrollerStub, location);
service.updateScrollLocationHref();
expect(service.getStoredScrollLocationHref()).toBeNull();
service.removeStoredScrollInfo();
expect(service.getStoredScrollPosition()).toBeNull();
}).not.toThrow();
});As you probably know already, you can run the tests with yarn test (from inside the aio/ directory). Please, make sure that the test fails without your fix and passes with the fix.
|
@gkalpak can you please look into the request and tell me if there is a problem with my code. |
|
The code looks great, @ajitsinghkaler 👍
|
1def8e9 to
7b75cf1
Compare
|
You can preview 7b75cf1 at https://pr33829-7b75cf1.ngbuilds.io/. |
|
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
1 similar comment
|
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
|
You can preview 4d95ce2 at https://pr33829-4d95ce2.ngbuilds.io/. |
4d95ce2 to
c9b1619
Compare
|
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
|
You can preview c9b1619 at https://pr33829-c9b1619.ngbuilds.io/. |
3ae3f02 to
3e088f5
Compare
|
You can preview 3e088f5 at https://pr33829-3e088f5.ngbuilds.io/. |
3e088f5 to
26d5730
Compare
|
You can preview 26d5730 at https://pr33829-26d5730.ngbuilds.io/. |
|
@gkalpak now I can't understand why all checks are not passing can you please help me |
|
For starters, you need to rebase on master (as mentioned in my previous message). (If you are having trouble rebasing on master, lmk and I can do it for you.) |
|
I've already run git rebase master in my feature branch |
|
Thx for trying that, @ajitsinghkaler. Try the following: # Switch to the master branch.
git checkout master
# Fetch changes from `angular/angular` and
# update your local master.
git pull upstream master
# Push the changes to your remote GitHub repo
# (This is not necessary for rebasing your local feature branch,
# but it is a good idea to keep your repo's master up-to-date.)
git push origin master
# Switch to your local feature branch.
# (Replace `<your-local-branch>` with the name of your branch.)
git checkout <your-local-branch>
# Rebase your feature branch on master.
git rebase master
# Push the updated feature branch to your remote GitHub repo.
# (This will automaticall yupdate the PR.)
git push --force-with-lease(If you get an error about Let me know if these commands don't work for you. |
Whenever cookies are disabled in the browser, `window.sessionStorage` is not avaialable to the app (i.e. even trying to access `window.sessionStorage` throws an error). To avoid breaking the app, we use a no-op `Storage` implementation if `window.sessionStorage` is not available. Fixes angular#33795
26d5730 to
6d3b739
Compare
|
@gkalpak everything is alright I think right now |
gkalpak
left a comment
There was a problem hiding this comment.
LGTM ✨
Thx, @ajitsinghkaler 💯
#33829) Whenever cookies are disabled in the browser, `window.sessionStorage` is not avaialable to the app (i.e. even trying to access `window.sessionStorage` throws an error). To avoid breaking the app, we use a no-op `Storage` implementation if `window.sessionStorage` is not available. Fixes #33795 PR Close #33829
|
@gkalpak No problem. Actually I should thank you for helping me throughout the process. You can assign me any issue that seems fit for my knowledge. I'll try to help the angular team as much as possible. |
|
That's good to know, @ajitsinghkaler, thx! (BTW, I would love some help figuring out why there is a visual difference in different OSes in #33255 (comment), if you happen to fancy looking into that 😉) |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
fix(docs-infra): changed window.sessionStorage to default params when cookies disabled
Whenever cookies are disabled windows.sessionStorage is not available for the app so If it throws an error I give it a default value
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
In the current scenario whenever the browser is configured not to accept cookies, the angular.io homepage shows a blank page without any content because windows.sessionStorage is not defined
Issue Number: #33795
What is the new behavior?
In the new behavior whenever window.sessionStorage is not defined I give it a default value
Does this PR introduce a breaking change?
Other information