From 11382cfda69e9392f2c32abc3758808f63b67507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Tue, 24 Aug 2021 09:41:49 +0200 Subject: [PATCH] fix(local-storage) use local storage on WebKit when not in an iframe There should be no need to use the workaround when visiting the site normally. --- .../base/jitsi-local-storage/setup.web.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/react/features/base/jitsi-local-storage/setup.web.js b/react/features/base/jitsi-local-storage/setup.web.js index b8577185f..b54342e92 100644 --- a/react/features/base/jitsi-local-storage/setup.web.js +++ b/react/features/base/jitsi-local-storage/setup.web.js @@ -11,6 +11,20 @@ import logger from './logger'; declare var APP: Object; declare var config: Object; +/** + * Checks whether we are loaded in an iframe. + * + * @returns {boolean} Returns {@code true} if loaded in iframe. + * @private + */ + function _inIframe() { + try { + return window.self !== window.top; + } catch (e) { + return true; + } +} + /** * Handles changes of the fake local storage. * @@ -41,7 +55,9 @@ function shouldUseHostPageLocalStorage(urlParams) { return true; } - if (browser.isWebKitBased()) { // Webkit browsers don't persist local storage for third-party iframes. + if (browser.isWebKitBased() && _inIframe()) { + // WebKit browsers don't persist local storage for third-party iframes. + return true; }