Proper handling of localStorage disabled check
Created by: ako977
In angular-storage on line 86 a check is performed for localStorage enabled on the browser by
var localStorageAvailable = !!$window.localStorage;
This check is not adequate enough bc/ at least in chrome, you get an error: Error: Failed to read the 'localStorage' property from 'Window': Access is denied for this document. I recommend removing that line and rather just using the try catch that is performed below as:
try {
$window.localStorage.setItem('testKey', 'test');
$window.localStorage.removeItem('testKey');
var localStorageAvailable = true;
} catch(e) {
var localStorageAvailable = false;
}
This way chrome wouldn't break the script on the site. This code executes before any other check in other app modules can mitigate this (for angularjs apps with localStorage turned off) This would be in order to even show a warning notice to the user.