fix(iframe) don't register service worker when in an iframe

Fixes: https://github.com/jitsi/jitsi-meet/issues/9712
This commit is contained in:
Saúl Ibarra Corretgé 2021-08-24 09:52:45 +02:00 committed by Saúl Ibarra Corretgé
parent 605ce9db62
commit 5bc424459f
1 changed files with 9 additions and 1 deletions

View File

@ -25,8 +25,16 @@
Component: JitsiMeetJS.app.entryPoints.APP Component: JitsiMeetJS.app.entryPoints.APP
}) })
const inIframe = () => {
try {
return window.self !== window.top;
} catch (e) {
return true;
}
};
const isElectron = navigator.userAgent.includes('Electron'); const isElectron = navigator.userAgent.includes('Electron');
const shouldRegisterWorker = !isElectron && 'serviceWorker' in navigator; const shouldRegisterWorker = !isElectron && !inIframe() && 'serviceWorker' in navigator;
if (shouldRegisterWorker) { if (shouldRegisterWorker) {
navigator.serviceWorker navigator.serviceWorker