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

Fix IndexedDB check in Firefox with disabled cookies #1831

Merged

Conversation

sheff146
Copy link

This PR is a fix for issue #1825. According to it FF throws a Security Error during IndexedDB check if cookies are disabled.
Simply wrapped these checks in try/catch.

@patrickkettner
Copy link
Member

lgtm! Could you squash down to a single commit? Thanks!

@ma-jahn
Copy link

ma-jahn commented Jan 13, 2016

Hi,

I am afraid this PR will not fix the issue.
If I'm not mistaken, Modernizr already uses try catch for local and session storage access. Security Errors will not be caught by a simple try catch otherwise we wouldn't experience any issues with local and session storage.

@patrickkettner
Copy link
Member

@KK-MarcelJahn did you try the fix? Because I am finding the opposite of your claims

image

@sheff146
Copy link
Author

@KK-MarcelJahn there are no security errors on localStorage and sessionStorage checks in Modernizr v3 unlike v2. The only error is being thrown on IndexedDB check. You can build sources and try.

@sheff146
Copy link
Author

@patrickkettner squashed.

try {
indexeddb = prefixed('indexedDB', window);
} catch (e) {
indexeddb = null;
Copy link
Member

Choose a reason for hiding this comment

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

sorry for not catching before, but this line is unnecessary. can you remove it in both files and squash one more time?

Copy link
Author

Choose a reason for hiding this comment

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

Yep. Done.

Squashed commits:
[a1fd83a] Fix indexedDB blob check
In Firefox it was throwing Security Error when cookies was disabled
[fea8cb6] Fix indexedDB check
In Firefox it was throwing Security Error when cookies was disabled
patrickkettner added a commit that referenced this pull request Jan 13, 2016
Fix IndexedDB check in Firefox with disabled cookies
@patrickkettner patrickkettner merged commit 7152423 into Modernizr:master Jan 13, 2016
@patrickkettner
Copy link
Member

cheers - thanks mate

try {
indexeddb = prefixed('indexedDB', window);
} catch (e) {
}
Copy link
Member

Choose a reason for hiding this comment

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

Put the closing } on the same line

Copy link
Member

Choose a reason for hiding this comment

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

Actually wouldn't we want to return false here since it won't work and to me that's the same as not supported.

Copy link
Member

Choose a reason for hiding this comment

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

we could return, but we aren't inside of an addTest, so I don't think return false would be doing what you think it would be doing

Copy link
Author

Choose a reason for hiding this comment

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

@ryanseddon how to do it technically now when PR is closed? Create new PR?

@ma-jahn
Copy link

ma-jahn commented Jan 13, 2016

Yeah sorry for the (my) confusion!
This fix is working!

Guess i messed up with the versions i used for testing (in prod we are using 2.8).
So we'll update as soon as this fix is merged and a new version is available. Thank you guys!

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.

None yet

4 participants