From 9f867e7c160129be98baaa2d440fd80e7f6be7a8 Mon Sep 17 00:00:00 2001 From: Matyas Albert Nagy Date: Sat, 24 Feb 2018 14:14:39 +0100 Subject: [PATCH] Fix localStorage check when embedded in iframe (firefox) --- dev/Storage/RainLoop.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dev/Storage/RainLoop.js b/dev/Storage/RainLoop.js index 2957c34e1..af0a44ce0 100644 --- a/dev/Storage/RainLoop.js +++ b/dev/Storage/RainLoop.js @@ -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; }