popcodeorg / popcodeorg/popcode
Load preview in secure frame
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 191
- Forks
- 143
- Ø Merge
- 4 T. 11 Std.
- Gemergte PRs (30 T.)
- 5
Beschreibung
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.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, das previewSupport-Bundle, den Initialisierungs-Handshake von JS Channel und die Logik zu lokalisieren, die die vorab geladenen Preview-Frames verwaltet. Verfolge, wie das übergeordnete Fenster das Projekt-HTML sendet und wie aufeinanderfolgende kompilierte Iterationen geladen werden, und bestätige anschließend, dass eine statische sichere Seite das initiale Dokument empfangen, ihr DOM ersetzen und Live-Aktualisierungen beibehalten kann.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript
- Bereich
- frontend
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100