Open domenic opened 7 years ago
FWIW, I think we actually want to define when new globals are created as we can then also define when agents and agent clusters are created, and how those all relate. That is rather indirect at the moment (in part due to how hard it is to sort out navigation properly).
Class string (cf. #357) is a small thing that would be easy to make imperative. However, doing so in a non-confusing way is blocked on first making iterator prototype objects and async iterator prototype objects imperative, since for those two there's currently no algorithm to slot the "create a @@toStringTag
property" step into.
We've been doing this piecemeal. For example, https://heycam.github.io/webidl/#namespace-object provides a procedure for creating namespace objects given a namespace and realm. We did the same for interface object: https://heycam.github.io/webidl/#interface-object , but did not do it for interface members (like we did for namespace members). This will be a great clarity improvement, consolidating various sprinkled prose which tells you what global properties exist and what their property descriptors are and so on.
Once this is done completely for all initial objects, we can replace
with a procedure that is given a realm and ... a set of all IDL definitions on the web platform? ... and loops over all exposed definitions and creates them on that realm's global object.
Then, I suppose, we can call that procedure from places like https://html.spec.whatwg.org/#creating-a-new-browsing-context as a customization for InitializeHostDefinedRealm(). Although that might be overkill, as the hand-wavey manner in which things currently work allows you to "automatically" get the right set of globals without having to add an explicit step when creating your global. (Thus making it easier to define new globals.) We can cross that bridge when we get there.