I have a Chrome extension which requires a sandbox so that I can use a custom content security policy and also requires a Service Worker so I have a script running that is persistent. I would like the Service Worker to open a new (sandbox) window, and then be able to communicate with this sandbox by using postMessage
.
I have tried three methods to create this window but none of them quite work for me:
- I tried
chrome.windows.create
which is able to create the window, but I don't have accese topostMessage
(or at least I don't know how to accesspostMessage
this way). - I tried
window.open
which returns aWindowProxy
object which I can callpostMessage
on. However this only works where thewindow
context is available and this is not the case in Service Worker. - I tried
clients.openWindow
however I ended up with an error "Not allowed to open a window".
Is there anyway to create a (sandboxed) window which allows me to use postMessage
from a Service Worker in a chrome extension?