Repository navigation
Create new objects with a Realm #793
Description
Activity
Any time we do "a new Thing" or implicitly create a new object (like "return a TypeError" or "reject promise with...") from "in parallel" steps, steps queued against another task source, or timeline, then we absolutely need to specify the realm. Examples in the current spec where that isn't done include:
- createContext() - ".. .then queue an ML task with global to reject promise with a "NotSupportedError" DOMException ..."
- build() - "... then queue an ML task with global to reject promise with an "OperationError" DOMException ..."
I'm less clear about instances where an exception is thrown or promise is rejected with a new exception during synchronous steps of a method. e.g. in Web IDL it says "When an algorithm says to throw a SomethingError then this means to construct a new JavaScript SomethingError object in the current realm and to throw it, just as the algorithms in ECMA-262 do."
That implies that we can infer the realm in simple cases. Certainly, lots and lots of specs use realms sparingly, even when they do use them for more interesting cases. Perhaps that's just a lack of rigor, though. We should ask around.
- changed the title
[-]Create promises with a Realm[/-][+]Create new objects with a Realm[/+]on Nov 23, 2024 Any time we do "a new Thing" or implicitly create a new object
Updated the title and description to reflect this
See also: whatwg/webidl#135
@jyasskin points out:
https://webidl.spec.whatwg.org/#js-creating-throwing-exceptions says to use the "current realm" to create exceptions. https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-global-task will set that via the "global's relevant agent's event loop", where "relevant agent" gets the global's realm.
- added a commit that references this issue
on Jan 29, 2025 - added 7 commits that reference this issue
on Feb 6, 2025
From #787 (comment). For example, we need to do this everywhere: