Skip to content

Conversation

@jmdyck
Copy link
Contributor

@jmdyck jmdyck commented Nov 26, 2025

... that I proposed in tc39/ecma262#3728.

(Creating this as a draft because that one hasn't been approved.)


/document-lifecycle.html ( diff )
/document-sequences.html ( diff )
/infrastructure.html ( diff )
/webappapis.html ( diff )
/workers.html ( diff )
/worklets.html ( diff )

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

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

We'll also have to change Service Workers which calls creating a new realm.

I guess we should have a follow-up issue on actually using realm to allocate the various global objects. I think Web IDL does allow for it now.

@jmdyck
Copy link
Contributor Author

jmdyck commented Nov 28, 2025

I guess we should have a follow-up issue on actually using realm to allocate the various global objects. I think Web IDL does allow for it now.

I'm wondering if there's a problem there. I gather that (e.g.) "a new Window object" is a shorthand for "a new object implementing the interface Window", which is a reference to this Web IDL algorithm, which then invokes the internally create a new object implementing the interface algorithm, which makes several references to its realm parameter, and calls other algorithms that also use realm. The thing is, in this scenario, that realm isn't complete, so it's possible that some of those uses of realm are ill-defined. E.g., step 1 invokes the exposed algorithm, which refers to realm.[[GlobalObject]], which hasn't been set yet.

@annevk
Copy link
Member

annevk commented Nov 28, 2025

Nice catch! I filed whatwg/webidl#1547. I think it might be beneficial if we could set realm.[[GlobalObject]] ourselves while we are building the global object, but it seems there's further issues as well that will need a different kind of change.

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.

2 participants