w3c / webref

Machine-readable references of terms defined in web browser specifications
https://w3c.github.io/webref/
MIT License
278 stars 69 forks source link

Guarantee that there are events associated with interfaces that inherit from `EventTarget` #1216

Open tidoust opened 2 months ago

tidoust commented 2 months ago

Via https://github.com/w3c/webref/issues/1212#issuecomment-2058877542.

We already use the fact that an interface inherits from EventTarget to find target interfaces for events when we extract them from the specs, but we don't have test in place that checks that:

  1. All interfaces that inherit from EventTarget are targeted by at least one event (for example: there should be events that target CloseWatcher)
  2. We have a suitably named event for all EventHandler attributes in such interfaces (for example: there should a cancel event that targets CloseWatcher because it has an oncancel attribute.

Depending on what research reveals, this test could be turned into a guarantee for the @webref/events package. There may be exceptions to the rule though (such as new interfaces for which the draft spec does not yet correctly define associated events)

tidoust commented 2 months ago

I've been looking into adding a check to Strudy's study-webidl. A couple of things make that slightly painful:

I'll try to prepare something relatively clean for integration in Strudy. In the meantime, the analysis reveals that we could almost guarantee that "all event handlers get targeted by a suitable event", but for the following cases:

[Edit: problems reported and fixed] This also reveals 4 other problems in WebXR Layers, where the redraw event is defined to target the root XRLayer interface, whereas the event handlers are defined on specific interfaces that inherit from XRLayer. I'll report the errors:

While digging into data, I also bumped into the definition of XHR events, which are currently defined with a data-dfn-for="XMLHttpRequest" attribute, while they also fire on XMLHttpRequestUpload. The attribute should rather be data-dfn-for="XMLHttpRequestEventTarget".