Creating Sandbox Window from Service Worker

Viewed 333

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 to postMessage (or at least I don't know how to access postMessage this way).
  • I tried window.open which returns a WindowProxy object which I can call postMessage on. However this only works where the window 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?

0 Answers
Related