Suppose you are building a robot simulator in HTML/JavaScript in which you have a robot that is controlled by the user's JavaScript code. You also want the user to be able to interact with the webpage so you send the user's code to a WebWorker where it is executed.
Now everything looks great until you come to a point when you need to control the robot based on the state of the webpage (i.e. is a robot touching some other object). You would like to send this information somehow to the WebWorker but that is not possible, because the user's code runs in infinite loop (using evilish eval) that blocks the worker completely.
So my question is: Is this the wrong approach? Is something I am trying to do technically impossible given the modern web browsers?
Thanks.