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

Create exceptions and promises in the correct realm #251

Merged
merged 5 commits into from
Oct 6, 2021

Conversation

domenic
Copy link
Member

@domenic domenic commented Sep 12, 2021

Closes #242 by superseding it.

This approach moves the ctorRegistry back to being mostly for the registration of WebIDL2JS-generated constructors. We use the globalObject variable to pass to webidl-conversions and to find our Promise and TypeError constructors.

Needs testing with jsdom before merging.

Since 9260316 jsdom has not worked, seemingly due to some weird interaction between Symbol.for and VM context objects. This seems to fix things, and it's not clear why we used a cross-realm symbol for this anyway.
@domenic
Copy link
Member Author

domenic commented Sep 12, 2021

Review appreciated if either of you have time, @TimothyGu @ExE-Boss. 8faa068 in particular I am unsure what is going on.


// This only contains the intrinsic names that are referenced from the `ctorRegistry`:
const intrinsicConstructors = ["Array"];
const ctorRegistrySymbol = Symbol("[webidl2js] constructor registry");
Copy link
Contributor

Choose a reason for hiding this comment

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

We used a global symbol in #140 so that the constructor registry would be shared between jsdom, domexception, whatwg‑url, and eventually cssstyle (once jsdom/cssstyle#116 is merged).

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, I see. Probably then the problem is that I was testing only upgrading webidl2js for jsdom, but not domexception and whatwg-url. I will have to test upgrading all three. Or maybe it would be best to add a major version number to the symbol description so that if we do mix versions it doesn't cause problems.

const ctorRegistrySymbol = Symbol.for("[webidl2js] constructor registry");

// This only contains the intrinsic names that are referenced from the `ctorRegistry`:
const intrinsicConstructors = ["Array"];
Copy link
Contributor

@ExE-Boss ExE-Boss Sep 14, 2021

Choose a reason for hiding this comment

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

Storing these in the constructor registry was done to correctly implement the parts of WebIDL that use intrinsic objects, and to allow using extends ctorRegistry.<base‑name> instead of extends globalObject.<base‑name>, the former of which also requires that all code using WebIDL2JS uses the same ctorRegistry object.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we still implement the parts Web IDL that use intrinsic objects correctly. And I don't see the value of extends ctorRegistry. instead of extend globalObject.; indeed requiring everything to use the same ctorRegistry seems subpar instead of using the global as the coordination point.

lib/output/utils.js Show resolved Hide resolved
@domenic domenic merged commit 90ba8b1 into master Oct 6, 2021
@domenic domenic deleted the promise-error-realm branch October 6, 2021 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants