Bug 149474 - Web IDL: DOM "onfoo" attributes should be configurable and enumerable
Summary: Web IDL: DOM "onfoo" attributes should be configurable and enumerable
Status: RESOLVED FIXED
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: 2022-09-06 16:51 PDT (History)
8 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
Comment 4 Ahmad Saleem 2022-09-03 04:50:39 PDT
I searched for 'es-attributes' and it seems that following WPT test covers it:

https://wpt.fyi/results/html/browsers/the-window-object/window-properties.https.html?label=master&label=experimental&aligned&view=subtest&q=window-properties.https.html

Safari Technology Preview 152 only fail in single test, is anything else needed here or we can create separate bug for the particular bug failure? Ignore me, if I am wrong. Thanks!
Comment 5 Alexey Shvayka 2022-09-06 16:51:13 PDT
(In reply to Ahmad Saleem from comment #4)
> I searched for 'es-attributes' and it seems that following WPT test covers
> it:
> 
> https://wpt.fyi/results/html/browsers/the-window-object/window-properties.
> https.html?label=master&label=experimental&aligned&view=subtest&q=window-
> properties.https.html
> 
> Safari Technology Preview 152 only fail in single test, is anything else
> needed here or we can create separate bug for the particular bug failure?
> Ignore me, if I am wrong. Thanks!

Thank you Ahmad, that last failing test is due to WebKit no longer (or never did) supports obsolete window.external (https://html.spec.whatwg.org/multipage/obsolete.html#external).

The WPT is rightfully testing it, since just like document.all, browsers must expose it with dummy functions.

However, given Safari is mainstream and no web compat issues were reported due to lack of External, maybe it's even possible to remove it from the spec, and consequently loosen up the tests.

Anyway, "onfoo" attributes were fixed long time ago, so I'm marking this as FIXED.