Validate spec_urls based on webref ids - #23958
Conversation
I'd say that the good news is that, in most cases, it seems that "something else is going on" ;) Main categories of errors I see:
And then there are actual broken links in BCD, such as https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.timezone. There are also "outdated" URLs, such as https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html#sec-object.prototype.__defineGetter__, which redirects to https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.prototype.__defineGetter__ that appears in Webref. There may be a few other error cases to dig into. |
|
Fantastique François!! 🎉 What I see now:
Something I would like for you to take a look:
|
As far as I can tell, all of them are examples of what I called outdated links: they work, but that's because the HTML spec has logic in place to redirect past fragments to their new page. Each time, the content referenced by the link moved to another page of the HTML spec and would better be targeted using the new fragment to avoid a redirect. For example, clicking on https://html.spec.whatwg.org/multipage/browsing-the-web.html#dom-beforeunloadevent-returnvalue makes you load the |
|
This pull request has merge conflicts that must be resolved before it can be merged. |
1d3fc19 to
9aa29d9
Compare
|
30 more to go.
|
|
OK, I think we're almost at a stage where this PR will pass tests. Final steps:
|
|
This pull request has merge conflicts that must be resolved before it can be merged. |
|
Remaining four issues:
|
|
For For |
|
This is passing for the first time in almost(!) two years 😄 Marking as ready for review. |
Export `processData` and give it an optional `deps` object (`lookup`, `exceptions`) defaulting to the real `xref.lookup` and the loaded `specsExceptions`. This lets unit tests inject fakes instead of depending on the bundled `@webref/xref` data. `check` still calls it with the defaults, so behavior is unchanged.
Add `test-spec-urls.test.js` exercising every branch of `processData` with an injected fake `lookup`/`exceptions`: missing/empty `spec_url`, exception-host skips, fragment-less skips, fragment lookup hits/misses, text-fragment handling, and arrays. Includes one `check` test using the real default dependencies. Reaches 100% coverage of the linter.
caugner
left a comment
There was a problem hiding this comment.
LGTM.
PS: I took the liberty of pushing two commits adding full test coverage for the test-spec-urls linter.
|
I'm merging this. Thanks everyone for your help! See https://github.com/mdn/browser-compat-data/blob/main/docs/data-guidelines/spec_links.md for documentation. |
Draft testing PR for @tidoust :)
Based on w3c/webref#1198 (comment), I wrote a quick test to see if webref ids could be used to (deeply) validate BCD's spec_urls. (that is, we want to check if the fragment ids are valid as well, not just the spec hosts).
It spits out a lot of errors and I would be interested to hear if BCD should be using different fragment ids, or if webref is missing these fragment ids, or if something else is going on. Please see the CI failure for the results.
(This is a draft PR that removes our dependency on web-specs and instead fetches raw webref JSON files, we might not want to fetch the data this way, so consider this PR just a test for now)
Fixes #29065.