Setting a realm's global object
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 147
- Forks
- 45
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 4
Description
eshost currently allows for the specification of global bindings during ECMAScript realm creation. These bindings are created as enumerable, writable, and configurable properties of the global object.
The ES2015 specification defines behavior for global object properties with different descriptors. Although some of these can be tested by runtime creation of properties, e.g.
Object.defineProperty(this, 'foo', { value: 0, writable: false });
foo++;
assert.sameValue(foo, 0);
...others cannot. For example the semantics of GlobalDeclarationEvaluation dictate (via CanDeclareGlobalFunction) that if the global object has a property named foo that has the value undefined and the descriptor {[[Configurable]]: false, [[Writable]]: true, [[Enumerable]]: true}, the following code should execute without error:
foo();
function foo() {}
One solution would be to extend the eshost API to respect the property descriptors of the provided object, but the spec also accounts for global objects that are exotic. For example, here's a non-normative note from GlobalDeclarationEvaluation:
13- NOTE: No abnormal terminations occur after this algorithm step if the
global object is an ordinary object. However, if the global object is a
Proxy exotic object it may exhibit behaviours that cause abnormal
terminations in some of the following steps.
So I think we need the ability to specify the global object directly. Does that sound right to you, @bterlson? I'm also interested in this detail as it relates to Test262. If what I've written above is accurate, we will one day need to write tests that dictate a realm's global object value.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue does not identify implementation files, tests, or an entry point. Start by locating the eshost realm-creation API and reviewing how global bindings are currently represented. Done means the API can specify a realm's global object, including property descriptors and exotic-object behavior, with coverage for the described declaration cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100