Skip to content

Commit

Permalink
iOS private browsing also makes localStorage detection fun. Super.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Oct 21, 2011
1 parent 2cc2e44 commit 5e2fa0e
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions modernizr.js
Original file line number Diff line number Diff line change
Expand Up @@ -696,17 +696,15 @@ window.Modernizr = (function( window, document, undefined ) {
};


// Firefox has made these tests rather unfun.

// In FF4, if disabled, window.localStorage should === null.

// Normally, we could not test that directly and need to do a
// `('localStorage' in window) && ` test first because otherwise Firefox will
// throw http://bugzil.la/365772 if cookies are disabled

// However, in Firefox 4 betas, if dom.storage.enabled == false, just mentioning
// the property will throw an exception. http://bugzil.la/599479
// This looks to be fixed for FF4 Final.
// Also in iOS5 Private Browsing mode, attepting to use localStorage
// will throw the exception:
// QUOTA_EXCEEDED_ERRROR DOM Exception 22.

// Because we are forced to try/catch this, we'll go aggressive.

Expand All @@ -716,7 +714,7 @@ window.Modernizr = (function( window, document, undefined ) {

tests['localstorage'] = function() {
try {
return !!localStorage.getItem;
return !!localStorage.getItem('getItem');
} catch(e) {
return false;
}
Expand Down

0 comments on commit 5e2fa0e

Please sign in to comment.