Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaScript ShadowRealm proposal integration #9893

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open

Conversation

Ms2ger
Copy link
Member

@Ms2ger Ms2ger commented Oct 30, 2023

To replace #5339. Draft because I still need to iron out a few issues around module loading, and need to change what the global object looks like.

  • At least two implementers are interested (and none opposed):
  • Tests are written and can be reviewed and commented upon at:
  • Implementation bugs are filed:
    • Chromium: …
    • Gecko: …
    • WebKit: …
    • Deno (only for timers, structured clone, base64 utils, channel messaging, module resolution, web workers, and web storage): …
    • Node.js (only for timers, structured clone, base64 utils, channel messaging, and module resolution): …
  • MDN issue is filed: …
  • The top of this comment includes a clear commit message to use.

(See WHATWG Working Mode: Changes for more details.)


/browsing-the-web.html ( diff )
/dom.html ( diff )
/embedded-content.html ( diff )
/form-elements.html ( diff )
/index.html ( diff )
/infrastructure.html ( diff )
/media.html ( diff )
/nav-history-apis.html ( diff )
/references.html ( diff )
/scripting.html ( diff )
/structured-data.html ( diff )
/timers-and-user-prompts.html ( diff )
/webappapis.html ( diff )
/workers.html ( diff )

This patch gives the TC39 JavaScript ShadowRealm proposal semantics in HTML.
ShadowRealms are given an environment settings object; in general,
ShadowRealms inherit their settings from the outer environment.

When modules are used in ShadowRealms, module specifiers are interpreted with
respect to the base URL of the surrounding environment, but when a module is
imported within a ShadowRealm, it is a separate copy from what may be loaded
in the surrounding environment or other ShadowRealms.

This patch implements the plan described earlier at
<tc39/proposal-shadowrealm#225 (comment)>.

The ShadowRealm proposal is currently at Stage 2. Once this PR has been approved,
it should be able to advance to Stage 3.
Copy link
Contributor

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes to the module loading algorithms look ok.

For the record, we (people working on modules in TC39) have some ideas for splitting the stateless and stateful parts of Module Records in ECMA-262. If/once that will happen, it would be great to share a module map for the stateless parts across principal realms and shadow realms, so that basically in this case:

import "/foo";
new ShadowRealm().importValue("/foo", "bar");

we only call into fetch once (to get the stateless part) and then we create the stateful part twice in both realms.

source Outdated Show resolved Hide resolved
@Ms2ger Ms2ger marked this pull request as ready for review February 2, 2024 15:10
@Ms2ger
Copy link
Member Author

Ms2ger commented Feb 2, 2024

I think this could benefit from review at this point

ptomato added a commit to ptomato/whatwg-dom that referenced this pull request Feb 7, 2024
Delete the Exposed attribute from AbortSignal.timeout, letting it
inherit [Exposed=*] from AbortSignal.

Cf. whatwg/html#9893 where other timers are
being exposed in ShadowRealm global contexts.
@littledan
Copy link
Contributor

littledan commented Feb 7, 2024

ShadowRealms reached 2.7 in TC39. Acceptance of this PR by WHATWG editors is a blocking requirement for Stage 3, though it probably shouldn't be landed until the Web API set is finalized.

@domenic @annevk @zcorpan Any thoughts/concerns?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants