Iframe Medium embed.ly notifyResize在Safari上不起作用 问题
我们是一个提供商,集成在以在文章中显示小部件。Embed.ly提供了一个函数,它允许iFrame从内部更改其大小。除了Safari之外,它一直在工作,并且在所有浏览器中仍然有效。现在会抛出一个错误: SecurityError:阻止原点为“”的帧访问跨原点帧。协议、域和端口必须匹配 请参见此处的示例: 更新2019-07-10 medium.com显然改变了一些事情。现在:Iframe Medium embed.ly notifyResize在Safari上不起作用 问题,iframe,safari,content-security-policy,oembed,embedly,Iframe,Safari,Content Security Policy,Oembed,Embedly,我们是一个提供商,集成在以在文章中显示小部件。Embed.ly提供了一个函数,它允许iFrame从内部更改其大小。除了Safari之外,它一直在工作,并且在所有浏览器中仍然有效。现在会抛出一个错误: SecurityError:阻止原点为“”的帧访问跨原点帧。协议、域和端口必须匹配 请参见此处的示例: 更新2019-07-10 medium.com显然改变了一些事情。现在: 直接打开*yaeeehi时不会出现所述错误* 当你点击一篇文章时,它仍然会出现* 有一个新的错误,现在嵌入到“根本不工作”
函数notifyResize(高度){
高度=高度?高度:document.documentElement.offsetHeight;
var resized=false;
if(window.aduck&&aduck.resize)
{aduck.resize(高度);resized=true;}
if(父对象和父对象。\u重设帧大小)
{var obj={iframe:window.frameElement,height:height};父对象。_resizeIframe(obj);resized=true;}
if(window.location&&window.location.hash==“#amp=1”&&window.parent&&window.parent.postMessage)
{window.parent.postMessage({sentinel:“amp”,类型:“嵌入大小”,高度:height},“*”;}
if(window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.resize)
{window.webkit.messageHandlers.resize.postMessage(高度);resized=true;}
返回调整大小;
}
这在父级断开。\u resizeIframe-这很奇怪,因为iFrame内容来自并试图访问父级,而父级也是。有什么想法吗
模拟
我尝试在我的环境中复制该错误,但效果良好:
default-src 'self';
connect-src https://localhost https://*.instapaper.com https://*.stripe.com https://glyph.medium.com https://*.paypal.com https://getpocket.com https://medium.com https://*.medium.com https://*.medium.com https://medium.com https://*.medium.com https://*.algolia.net https://cdn-static-1.medium.com https://dnqgz544uhbo8.cloudfront.net https://cdn-videos-1.medium.com https://cdn-audio-1.medium.com https://*.lightstep.com https://*.branch.io https://app.zencoder.com 'self';
font-src data: https://*.amazonaws.com https://*.medium.com https://glyph.medium.com https://medium.com https://*.gstatic.com https://dnqgz544uhbo8.cloudfront.net https://use.typekit.net https://cdn-static-1.medium.com 'self';
frame-src chromenull: https: webviewprogressproxy: medium: 'self';
img-src blob: data: https: 'self';
media-src https://*.cdn.vine.co https://d1fcbxp97j4nb2.cloudfront.net https://d262ilb51hltx0.cloudfront.net https://*.medium.com https://gomiro.medium.com https://miro.medium.com https://pbs.twimg.com 'self' blob:;
object-src 'self';
script-src 'unsafe-eval' 'unsafe-inline' about: https: 'self';
style-src 'unsafe-inline' data: https: 'self';
report-uri https://csp.medium.com
但是没有匹配的报告uri调用
线索二:来源不明
有趣的是,iFrame源:没有出现在webdeveloper网络选项卡中!?但它仍然可以作为控制台中的页面选择。好的,问题如下: 阻止原点为“”的帧访问 带原点“”的框架。正在访问的帧集 “document.domain”到“medium.com”,但请求访问的帧没有 不两者必须将“document.domain”设置为相同的值才能允许 进入 在第一个iFrame中设置
document.domain=“medium.com”
,可以解决此问题。因此,medium/embed.ly必须这样做
好的,问题如下: 阻止原点为“”的帧访问 带原点“”的框架。正在访问的帧集 “document.domain”到“medium.com”,但请求访问的帧没有 不两者必须将“document.domain”设置为相同的值才能允许 进入 在第一个iFrame中设置
document.domain=“medium.com”
,可以解决此问题。因此,medium/embed.ly必须这样做
我刚刚能够确认其他嵌入件存在相同的问题:我刚刚能够确认其他嵌入件存在相同的问题: