I'm trying to implement a replacement for the
eval call in EvalJs that won't be blocked by CSP. To do this, I'm reimplementing the JS wrapper (see the previous link) in C++ and having the ClassicScript run the test-provided JS unmodified without an eval.
This mostly works, but the scoping behavior is different than eval's, which is causing issues. I want vars to be defined in the global scope, but let/const to be scoped to the JS being executed. I tried creating a new Context that shared a global object with the existing one (my understanding is that scopes map to Contexts), but Chrome was unhappy about defining a new Context for the main world, and I'm not sure that would make vars behave correctly.
Is there a way to get the scoping behavior I want, or a better approach to work around CSP?
Thanks!
Robbie