[heycam/webidl] Named properties object: allow symbols in [[DefineOwnProperty]] and [[Delete]] (#963)

Given that `X` is [named properties object](https://heycam.github.io/webidl/#named-properties-object) for `Window`, the following code:

```js
Object.defineProperty(X, Symbol.toStringTag,
  Object.getOwnPropertyDescriptor(X, Symbol.toStringTag));
```

should throw `TypeError` per current spec. While being compliant with [invariants of EIM](https://tc39.es/ecma262/#sec-invariants-of-the-essential-internal-methods), this behavior is very weird.

The same snippet for `X` that is [module namespace object](https://tc39.es/ecma262/#sec-module-namespace-exotic-objects) doesn't throw, even though the namespace is non-extensible and its `Symbol.toStringTag` is non-configurable.

While we could just special-case `Symbol.toStringTag` or own properties that are symbols, I suggest we treat symbols in [`[[DefineOwnProperty]]`](https://heycam.github.io/webidl/#named-properties-object-defineownproperty) and [`[[Delete]]`](https://heycam.github.io/webidl/#named-properties-object-delete) the same way as ordinary methods do. To prevent clashes with [supported property names](https://html.spec.whatwg.org/multipage/window-object.html#named-access-on-the-window-object), it's critical for `WindowProperties` to prohibit expando properties that are strings, but not symbols.

Proposed change feels like an expected behavior, reducing divergence with ordinary methods, and aligns [named properties object](https://heycam.github.io/webidl/#named-properties-object) with [legacy platforms objects](https://heycam.github.io/webidl/#legacy-platform-object-defineownproperty) & [module namespace object](https://tc39.es/ecma262/#sec-module-namespace-exotic-objects-defineownproperty-p-desc). It is already implemented in **Blink** and also, with [bug #222918](https://bugs.webkit.org/show_bug.cgi?id=222918), in **WebKit**.

Currently, no browser features spec-perfect `WindowProperties` object, so this change can be implemented along with [fixing current spec incompatibilities](https://github.com/web-platform-tests/wpt/pull/27970#issue-588774871).

Tests: https://github.com/web-platform-tests/wpt/pull/27970.

_cc_ @domenic @evilpie
You can view, comment on, or merge this pull request online at:

  https://github.com/heycam/webidl/pull/963

-- Commit Summary --

  * Named properties object: allow symbols in [[DefineOwnProperty]] and [[Delete]]

-- File Changes --

    M index.bs (14)

-- Patch Links --

https://github.com/heycam/webidl/pull/963.patch
https://github.com/heycam/webidl/pull/963.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/pull/963

Received on Thursday, 11 March 2021 00:34:07 UTC