Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
npm run test
通过详细描述
对于一些使用了
iframe
的主应用/子应用,可能会通过修改document.domain
的方式指定二级域以放宽“同源限制”,从而操作iframe
内的文档。然而这个方式会对
wujie
的同域iframe
产生影响:在创建iframe
后的极短时间内移除掉注入到iframeWindow
上的属性,从而导致子应用加载失败。我怀疑这与iframe错误文档陷阱有关。
在验证的过程中发现以下细节:
1、不管是否修改过
domain
,如果是在iframe
的document
真正准备好之后往iframeWindow
上注入属性,则不会被移除。2、不管是否修改过
domain
,iframe
错误文档陷阱都存在,但如果主应用修改过domain
,错误文档停留的时间明显更长。3、不修改
domain
场景下,没有移除iframeWindow
属性的现象因此,这个PR尝试兼容
domain
的修改,兼容后与iframe
对domain
的要求基本一致:1、如果是主应用希望修改
domain
放宽“同源限制”主应用中原来
iframe
的用法不变。主应用可正常使用
wujie
加载子应用,且子应用的domain
自动变为主应用修改的domain
2、如果是
wujie
加载的某个子应用希望修改domain
,并在子应用内使用iframe
应该改为在
wujie
主应用中修改domain
,子应用则可以不改(会继承主应用的)。domain引起的Uncaught DOMException: Blocked a frame with origin "https://xxx.tencent.com" from accessing a cross-origin frame #245 DOMException: Blocked a frame with origin from accessing a cross-origin frame 报错 #71