Merge pull request #1648 from albertmatyi/patch-1

Fix localStorage check when embedded in iframe (firefox)
This commit is contained in:
RainLoop Team 2019-03-28 01:28:20 +03:00 committed by GitHub
commit 1bd4cdbd2e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,7 +10,13 @@ const TIME_KEY = '__rlT';
*/
export function isStorageSupported(storageName)
{
if (storageName in window && window[storageName] && window[storageName].setItem)
let storageIsAvailable = false;
try {
storageIsAvailable = storageName in window && window[storageName] && window[storageName].setItem;
}
catch(e) {} // at: window[storageName] firefox throws SecurityError: The operation is insecure. when in iframe
if (storageIsAvailable)
{
const
s = window[storageName],
@ -28,6 +34,7 @@ export function isStorageSupported(storageName)
catch (e) {} // eslint-disable-line no-empty
}
return false;
}