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.createwhich is able to create the window, but I don't have accese topostMessage(or at least I don't know how to accesspostMessagethis way). - I tried
window.openwhich returns aWindowProxyobject which I can callpostMessageon. However this only works where thewindowcontext is available and this is not the case in Service Worker. - I tried
clients.openWindowhowever 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?