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

Normative: Clarify text about host added properties #301

Merged
merged 3 commits into from
May 5, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,25 @@ <h1>Runtime Semantics: HostInitializeSyntheticRealm ( _realm_ )</h1>
operation used to inform the host of any newly created realms from
the Realm constructor. Its return value is not used, though it may
throw an exception. The idea of this hook is to initialize host
data structures related to the Realm, e.g., for module loading. It
is not expected that this hook would add properties to the Realm's
global object.
data structures related to the Realm, e.g., for module loading.
</p>
<p>
The host may use this hook to add properties to the Realm's global
object. Those properties must each be configurable to provide
platform capabilities with no authority to cause side effects such
as I/O or mutation of values that are shared across different
realms within the same host environment.
Comment on lines +365 to +367
Copy link
Member

@Jack-Works Jack-Works May 4, 2021

Choose a reason for hiding this comment

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

with no authority to cause side effects such as I/O or mutation of values that are shared across different realms

This is not enough for the SES requirement.

Imagine the host provide a counter { [[Get]]: () => #counter, [[Set]]: (val) => #counter = val } property on the Realm's global object, this provides a shared global state within the Realm (not shared across different realms). It provides a communication channel in the different compartments within the same realm.

Copy link
Member

Choose a reason for hiding this comment

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

I guess I read the text to cover that case--I see the code sample as a value shared across realms, at a high level. I guess we just need to iterate on the wording so that it's maximally clear.

Copy link
Member

Choose a reason for hiding this comment

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

If #counter is a host-defined pre-realm internal state, it will be a mutable state within the Realm and passes the current spec text but violate the SES requirement.

</p>
<emu-note>
<p>
This specification does not recommend any specific addition.
In the Web embedding, HTML and WebIDL will specify which
interfaces are included. The Web Platform and Web-like
environments may decide to include `setTimeout`, `EventTarget`,
Copy link
Member

Choose a reason for hiding this comment

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

AFAIK setTimeout is IO. And as I explained in #284 I strongly against the host being able to add things into the realm without being able to have a clean version. This also hurts the API to be cross-platform safe.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is just an editorial note and we can remove the example.

Anyway, please keep the discussion to the respective issue.

`atob`, `TextEncoder`, `URL`, etc. while at the same time not
including `HTMLElement`, `console`, `localStorage`, `fetch`, etc..
</p>
</emu-note>
</emu-clause>

<emu-clause id="sec-hostimportmodulebindingdynamically" aoid="HostImportModuleBindingDynamically">
Expand Down