Assume I want to create an application that enables editing and executing JavaScript code:
- The user starts the Chromium browser and browses a static web server running on localhost
- After browsing localhost, the static web server can (and may) be stopped
- The user can create several "tabs" inside this application with a text editor field, "tabs" are more or less just these text fields, so no actual browser tabs
- The user can execute the code in the "tabs", either all together, individual "tabs", any combination of these "tabs", periodically, you name it
- The JavaScript code in these "tabs" could be any kind of code and should be considered as untrusted
- Communicating between the "tabs" and the application using `postMessage` is absolutely desired. Sending the JavaScript code of these "tabs" to the actual iframes is pretty much the thing I have in mind.
Since I want to consider the codes in the "tabs" as untrusted, I want to encapsulate them in an iframe for each "tab". I also want these iframes to be executed in individual processes. This means when I open the Chromium Task Manager, I want to see a process for each tab. Since neither the number of open "tabs" nor the code in the "tabs" is a priori known, I need to create the iframes and their content (i.e. the code in the "tabs") during the runtime of the application. This is what I understand by "creating iframes dynamically". This means I cannot set the "src" attribute to an existing URL. I need to create the content of each iframe (i.e. each "tab") by manipulating strings etc..
Before you ask, the combination iframe (+sandbox) in their own process is done in order to defend in depth. This means this is one layer in order to protect the main application from the "tabs" and the "tabs" from each other (this is the reason I want to run every "tab" in its own process).
Please consider that I don't actually want to create the mentioned application, but it is IMO an easy to understand example what I actually want to achieve. There is also no option for me to use a different tool or write the application with electron, C++ etc.. It must run in the browser and it should only use specified ECMAScript, HTML etc. features.
Consider it as a thought experiment.
I performed some research and some experiments regarding creating iframes dynamically that run in their own processes. So far I was not successful.
Here are some links I did find regarding site-isolation etc. in Chromium: