Bug 149474 - Web IDL: DOM "onfoo" attributes should be configurable and enumerable
Summary: Web IDL: DOM "onfoo" attributes should be configurable and enumerable
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL: https://heycam.github.io/webidl/#es-a...
Keywords:
Depends on:
Blocks: 122213 142934
  Show dependency treegraph
 
Reported: 2015-09-22 14:28 PDT by Joseph Pecoraro
Modified: 2015-09-22 15:36 PDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2015-09-22 14:28:30 PDT
* SUMMARY
DOM "onfoo" attributes should be configurable and enumerable
https://heycam.github.io/webidl/#es-attributes

> 4.5.7. Attributes
>
> For each exposed attribute of the interface, whether it was declared on the interface itself
> or one of its consequential interfaces, there must exist a corresponding property.
> The characteristics of this property are as follows:
>
> • The property has attributes { [[Get]]: G, [[Set]]: S, [[Enumerable]]: true, [[Configurable]]: configurable }, where:
>   - configurable is false if the attribute was declared with the [Unforgeable] extended attribute and true otherwise;
>   - G is the attribute getter, defined below; and
>   - S is the attribute setter, also defined below.

* TEST
var descriptor = Object.getOwnPropertyDescriptor(window, "onhashchange");
assert(descriptor.enumerable);
assert(descriptor.configurable);

* NOTES
WebKit : Enumerable(false) Configurable(false)
Firefox: Enumerable(true)  Configurable(true)
Chrome : Enumerable(true)  Configurable(true)  // NOTE: window.__proto__ right now
Comment 1 Joseph Pecoraro 2015-09-22 14:45:20 PDT
Seems like this might only be an issue with particular objects, like `window`. Looking at "onclick" for the Element.prototype, that is configurable.
Comment 2 Chris Dumez 2015-09-22 14:50:08 PDT
Yes, Window is defined with [PrimaryGlobal]:
https://html.spec.whatwg.org/multipage/browsers.html#the-window-object

As per the Web IDL spec [1], if the interface has [Global] or [PrimaryGlobal], the attributes should be on the instance rather than the prototype.

However, our bindings generator currently has an exception that makes attributes that are on the instance non-configurable.

If an attribute is not enumerable, it likely means that it has [NotEnumerable] on it in the WebKit IDL because they should be enumerable by default.

[1] https://heycam.github.io/webidl/#es-attributes
Comment 3 Joseph Pecoraro 2015-09-22 15:36:16 PDT
(In reply to comment #2)
> If an attribute is not enumerable, it likely means that it has
> [NotEnumerable] on it in the WebKit IDL because they should be enumerable by
> default.

That is the case here, WebKit has [NotEnumerable] on these attributes. However it looks like the specification of these attributes should be enumerable:
https://html.spec.whatwg.org/multipage/webappapis.html#windoweventhandlers