diff --git a/src/module.js b/src/module.js index f539fb48..156befe3 100644 --- a/src/module.js +++ b/src/module.js @@ -172,6 +172,8 @@ import { isReactNative, browserVideoSupported_p, getUserAgent, + iframeAllowValue, + isChromeV61, isFullscreenSupported, isScreenSharingSupported, isSfuSupported, @@ -732,6 +734,17 @@ export default class DailyIframe extends EventEmitter { properties.layout = 'browser'; } } + if ( + !(isChromeV61() + ? /(?=.*microphone)(?=.*camera)/.test(iframeish.allow) + : /(?=.*microphone)(?=.*camera)(?=.*autoplay)(?=.*display-capture)/.test( + iframeish.allow + )) + ) { + console.error( + `The iframe's "allow" property should contain the following values: ${iframeAllowValue()}` + ); + } return new DailyIframe(iframeish, properties); } @@ -770,12 +783,7 @@ export default class DailyIframe extends EventEmitter { } let iframeEl = document.createElement('iframe'); - // special-case for old Electron for Figma - if (window.navigator && window.navigator.userAgent.match(/Chrome\/61\./)) { - iframeEl.allow = 'microphone, camera'; - } else { - iframeEl.allow = 'microphone; camera; autoplay; display-capture'; - } + iframeEl.allow = iframeAllowValue(); iframeEl.style.visibility = 'hidden'; parentEl.appendChild(iframeEl); iframeEl.style.visibility = null; diff --git a/src/shared-with-pluot-core/Environment.js b/src/shared-with-pluot-core/Environment.js index 059631df..91c7c2f6 100644 --- a/src/shared-with-pluot-core/Environment.js +++ b/src/shared-with-pluot-core/Environment.js @@ -355,3 +355,14 @@ export function isCurrentDailyJsNearEndOfSupport() { NEARING_EOS_DAILY_JS_VERSION ); } + +export function isChromeV61() { + return window.navigator?.userAgent.match(/Chrome\/61\./); +} + +export function iframeAllowValue() { + // special-case for old Electron for Figma + return isChromeV61() + ? 'microphone, camera' + : 'microphone; camera; autoplay; display-capture'; +}