This demonstrates a bug in safari when trying to use a service worker with writable streams in a nested iframe. The example works in all other browsers.
To try it out visit https://safaribug.peergos.com/ or run it on localhost.
java Server.java
Navigate to: localhost:8000
service worker + writable streams is a useful mechanism to load generated/decrypted content in response to a request
This is demonstrated on index.html whereby the request to play/seek the video is intercepted via a service worker and data retrieved in main.js.
A writable stream is setup between main.js and sw.js and pipes the data back to the service worker.
To take this one step further, In chrome and firefox (but not safari) it is possible to load content into an iframe inside an iframe via a similar mechanism.
The purpose is to have the inner iframe on a subdomain subdomain.domain.com to provide a secure sandbox to load arbitrary html.
The file Server.java provides a minimal web server that sets additional response headers (ie COOP, COEP, CORP) and is directly executable without compilation.
main.js constructs an iframe and adds it to index.html.
The .src is set to /apps/sandbox/sandbox.html which contains the inner iframe.
The associated file sandbox.js loads a service worker to intercept requests.
And like the video streaming example, the data is ultimately loaded from main.js.
- subdomain.localhost:8000 is not supported (webkit bug from 2016, workaround - deploy to a remote host)
- the iframe inside an iframe does not work. nothing in console to indicate what the problem is.
Note: due to the minimal nature of this example - you will need to clear the cache/hard reset each time loading index.html
Alternative method (doesn't require the hard reset - but is the full app and therefore much more code):
- Create an account on peergos-demo.net
- upload a minimal .html file
- view the html file in the in-built html viewer (view action available from right-click menu)
The file will be viewable in chrome and firefox, but not safari.
Please make sure that you are not in incognito mode.