1 of 6

ShadowRealm

Implementer Feedback and Demotion to Stage 2

Daniel Minor

SpiderMonkey / Mozilla

2 of 6

What are ShadowRealms?

  • Provides a mechanism to execute JavaScript code within the context of a new global object and set of JavaScript built-ins
  • Goal is integrity, by isolating code into separate realms with controlled interactions
  • Advanced to Stage 3 at the July 2021 TC39 meeting

3 of 6

Current Status in Firefox

Initial implementation landed in Firefox 104 (August 2022)

  • Default to off behind javascript.options.experimental.shadow_realms pref

Implementation of JavaScript parts of the ShadowRealm proposal

Work on the HTML integration is stalled:

  • Insufficient tests available
  • Potentially large impact on DOM code

4 of 6

HTML Integration

  • Likely a substantial amount of work!
  • Need to carefully audit existing code for assumptions that globals are either `Document` or a worker
  • Requires coordination between DOM and JavaScript engine teams, as a lot of work could end up being on the DOM side

5 of 6

Not Implementable

SpiderMonkey’s position is that the proposal is not implementable without:

  • Review of which DOM APIs are exposed to ShadowRealms
  • Sufficient tests to ensure the correct behaviour of these APIs in ShadowRealms

6 of 6

Next Steps

I see three ways ahead –

  • Remove the HTML integration, and keep the proposal at Stage 3
  • Demotion to Stage 2 pending more work on HTML integration
  • Withdraw the proposal completely

We shouldn’t just leave this at Stage 3, that sends the wrong message to the community.