popcodeorg / popcodeorg/popcode
Load preview in secure frame
还没有人认领这个 Issue。
- 主要语言
- JavaScript
- 星标
- 191
- 派生
- 143
- 平均合并
- 4 天 11 小时
- 30 天内合并 PR
- 5
描述
Certain features, such as the camera API, don’t work properly in the preview iframe because it is not considered secure. This is odd to me, since it’s a srcdoc iframe in a secure parent frame, but it is what it is.
One idea: create a static HTML page whose job is to render the preview. That page would basically be a blank document with the previewSupport JavaScript bundle loaded in. In addition to the current previewSupport functionality, we’d listen for an initial message from the parent document containing the full HTML document that is to be previewed, and then use a document.open() followed by a document.write() to replace the entire DOM with the project preview. I think it would be most sensible for this hook to just be part of the initial JS Channel initialization handshake.
Live-updating of the preview should work pretty well out of the box, since we already load each successive compiled project iteration in a fresh iframe. The main thing to look out for is that we preload the on-deck iframe, with the preview support bundle loaded and ready. I think the current logic for managing the preview frames should naturally produce this behavior, but itʼs worth confirming.
Worth noting that this would considerably simplify the bundling and loading of previewSupport, which is currently quite hacky.
Original bug report
Submitter: Z
Email: zwilkinson@westinghousehs.org
I can’t use the browser’s Camera API from inside the preview window, because the preview is a data: URI that is not considered secure.
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先定位 previewSupport bundle、JS Channel 初始化握手,以及管理预加载 preview frame 的逻辑。跟踪 parent 如何发送项目 HTML,以及连续的已编译迭代如何加载,然后确认静态安全页面能够接收初始文档、替换其 DOM,并保留实时更新。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript
- 领域
- frontend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100