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

Audit host hook points in HTML #3147

Open
syg opened this issue Aug 16, 2023 · 6 comments
Open

Audit host hook points in HTML #3147

syg opened this issue Aug 16, 2023 · 6 comments

Comments

@syg
Copy link
Contributor

syg commented Aug 16, 2023

For the most part, HTML integration into ecma262 is done via host hooks. Host hooks are used very much like an embedder passing custom callbacks to an engine. However, some hook points are more ad-hoc, like realm creation.

We should discuss whether these ad-hoc patterns are acceptable editorially, or if we should introduce more formal hook points.

@michaelficarra
Copy link
Member

If we mark host hook AOs as such, we can also lint for unused AOs.

@jmdyck
Copy link
Collaborator

jmdyck commented Sep 12, 2023

However, some hook points are more ad-hoc, like realm creation.

There are a couple different things that are ad hoc about the realm creation hook:

(1)
HTML invokes InitializeHostDefinedRealm (IHDR) with 'customizations', e.g.:

For the global object, create a new Window object.

IHDR then has ad hoc steps to 'access' these customizations, e.g.:

If the host requires use of an exotic object to serve as realm's global object, let global be such an object created in a host-defined manner.

We could make this less ad hoc by giving IHDR two parameters (e.g., global and thisValue), and have HTML pass its customizations as objects (or *undefined*, to get the default).

Or is there something important about not creating the objects in question until after the first 6 steps of IHDR?


(2)
The spec doesn't invoke IHDR, so it isn't like a callback hook. Instead, the model is that the host invokes it directly. But the circumstances/constraints under which it can/may be invoked aren't spelled out.

If you're thinking that IHDR should be converted to a callback-style hook, I think that might be undoing some of PR #1597. (But maybe not.)

@michaelficarra
Copy link
Member

We could make this less ad hoc by giving IHDR two parameters

This is exactly the kind of thing I wanted an audit to turn up, and this solution sounds like the right direction to me.

the circumstances/constraints under which it can/may be invoked aren't spelled out

Yes, this seems important to elaborate on.

@Ms2ger
Copy link
Contributor

Ms2ger commented Nov 7, 2024

However, some hook points are more ad-hoc, like realm creation.

There are a couple different things that are ad hoc about the realm creation hook:

(1) HTML invokes InitializeHostDefinedRealm (IHDR) with 'customizations', e.g.:

For the global object, create a new Window object.

IHDR then has ad hoc steps to 'access' these customizations, e.g.:

If the host requires use of an exotic object to serve as realm's global object, let global be such an object created in a host-defined manner.

We could make this less ad hoc by giving IHDR two parameters (e.g., global and thisValue), and have HTML pass its customizations as objects (or *undefined*, to get the default).

Or is there something important about not creating the objects in question until after the first 6 steps of IHDR?

At least in the web platform, all objects are expected to be associated with a realm, so creating an object before the realm exists is somewhat inconvenient.

@mhofman
Copy link
Member

mhofman commented Nov 7, 2024

At least in the web platform, all objects are expected to be associated with a realm, so creating an object before the realm exists is somewhat inconvenient.

I'm surprised. I thought engines were not tracking the realm in which objects were created, only functions.

@Ms2ger
Copy link
Contributor

Ms2ger commented Nov 8, 2024

I believe that is technically allowed by ecma-262, but not on the web

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

No branches or pull requests

5 participants