4 ms·
An answer on StackOverflow https://stackoverflow.com/a/26488003 https://stackoverflow.com/a/26488003 claims that web workers count as same origin, but you can t
by geofft 8y ago
An answer on StackOverflow https://stackoverflow.com/a/26488003 https://stackoverflow.com/a/26488003 claims that web workers count as same origin, but you can totally solve this use case with <iframe sandbox>. (And other answers say that sites like JSFiddle do exactly this.)
There's an example of using this for untrusted eval in the linked HTML5Rocks post: https://www.html5rocks.com/en/tutorials/security/sandboxed-iframes/ https://www.html5rocks.com/en/tutorials/security/sandboxed-i... The amount of code involved is pretty minimal and doesn't involve opaque regexes, so something like that is probably the actual best option for someone who wants safe eval.
That StackOverflow user also has their own library that does this using a sandboxed iframe and a web worker: https://github.com/asvd/jailed https://github.com/asvd/jailed