popcodeorg / popcodeorg/popcode

Load preview in secure frame

Abierto
#804 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

enhancement
Lenguaje dominante
JavaScript
Estrellas
191
Forks
143
Merge medio
4 d 11 h
PR fusionados (30 d)
5

Descripción

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.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza localizando el bundle previewSupport, el handshake de inicialización de JS Channel y la lógica que gestiona los frames de preview precargados. Sigue cómo el elemento padre envía el HTML del proyecto y cómo se cargan las iteraciones compiladas sucesivas; después, confirma que una página segura estática puede recibir el documento inicial, reemplazar su DOM y conservar las actualizaciones en vivo.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript
Área
frontend
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.