首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在谷歌附加组件的iframe中启用功能/权限策略?

如何在谷歌附加组件的iframe中启用功能/权限策略?
EN

Stack Overflow用户
提问于 2021-06-09 15:46:53
回答 1查看 1.3K关注 0票数 0

我正在尝试在我的google插件中使用一个特性策略,串行策略。我很难在iframe中启用这个特定的特性策略,我认为主要是因为父iframes没有启用它。下面是iframe树的样子。我无法直接访问"sandboxFrame“和"userHtmlFrame”,因此不能更改其允许的功能。即使我在大多数子iframe中设置了“串行”,我也无法在其featurePolicy中找到启用的“串行”功能。

代码语言:javascript
复制
<iframe id="sandboxFrame" allow="accelerometer *; ambient-light-sensor *; autoplay *; camera *; clipboard-read *; clipboard-write *; encrypted-media *; fullscreen *; geolocation *; gyroscope *; magnetometer *; microphone *; midi *; payment *; picture-in-picture *; screen-wake-lock *; speaker *; sync-xhr *; usb *; web-share *; vibrate *; vr *" sandbox="allow-downloads allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts" src="https://...-script.googleusercontent.com/...">
    <iframe id="userHtmlFrame" allow="accelerometer *; ambient-light-sensor *; autoplay 
    *; camera *; clipboard-read *; clipboard-write *; encrypted-media *; fullscreen *; 
    geolocation *; gyroscope *; magnetometer *; microphone *; midi *; payment *; picture- 
    in-picture *; screen-wake-lock *; speaker *; sync-xhr *; usb *; web-share *; vibrate 
    *; vr *" src="/blank" title="">
       <iframe id="myIframe" allow="serial *;" sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts" src="...external website in          
          GitHub Pages">
       ...
       </iframe>
    </iframe>
</iframe>

如果任何熟悉谷歌插件的人都能证明我错了,那就太棒了。任何帮助我都会感激的。

谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-06-09 16:22:45

  1. 是的,如果父上下文授予了该权限,则可以将任何权限传递给嵌套的iframe 。 请记住,在传递权限时,源将相应更改,即:

<iframe scr='https://example.com' allow="fullscreen 'self'">

代码语言:javascript
复制
  `// the permission for fullscreen is 'self' (== http://example.com)`
代码语言:javascript
复制
  `// but main thing is this is that iframe HAS that permission, therefore`
代码语言:javascript
复制
  `// it can grant it to any nested context with ANY origin:`
代码语言:javascript
复制
`<iframe src='https://www.youtube.com' allow="fullscreen https://www.youtube.com">`
代码语言:javascript
复制
  `// will get permission of fullscreen mode for https://www.youtube.com origin`
代码语言:javascript
复制
`</iframe>`

</iframe>

  1. 在父元素iframe中,serial特性策略指令没有在allow='...'属性中指定。这意味着默认值 - 'src'允许使用此特性。因此,父iframe对serial具有隐式权限,因此它可以将其传递给任何嵌套的iframe。
  2. 我没有听到任何关于serial特性策略指令的消息,是它支持
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67907540

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档