Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test for outdated spec URLs that aren't in w3c/browser-specs #10681

Merged
merged 4 commits into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"devDependencies": {
"ajv": "~6.12.2",
"better-ajv-errors": "~0.7.0",
"browser-specs": "~1.38.1",
"chalk": "~4.1.0",
"compare-versions": "~3.6.0",
"mdn-confluence": "~2.2.2",
Expand Down
73 changes: 73 additions & 0 deletions test/spec-urls.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
'use strict';
const assert = require('assert');
const specData = require('browser-specs');
const { walk } = require('../utils');

describe('spec_url data', () => {
it('spec_urls only use allow listed hosts by w3c/browser-specs (and our exception list)', () => {
const specURLs = [];

for (const { compat } of walk()) {
const { spec_url } = compat;
const specs = [].concat(spec_url || []); // coerce spec_url to array, or empty array if undefined
specURLs.push(...specs);
}

const specsFromBrowserSpecs = [
...specData.map(spec => spec.url),
...specData.map(spec => spec.nightly.url),
...specData.map(spec => spec.series.nightlyUrl),
];

const specsExceptions = [
'https://wicg.github.io/controls-list/',
'https://w3c.github.io/setImmediate/',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be removed if/when #10746 lands

'https://datatracker.ietf.org/doc/html/rfc2397',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of these will no longer be exceptions if w3c/browser-specs#280 is fixed.

'https://datatracker.ietf.org/doc/html/rfc8942',
'https://datatracker.ietf.org/doc/html/rfc7231',
'https://datatracker.ietf.org/doc/html/rfc7233',
'https://datatracker.ietf.org/doc/html/rfc7234',
'https://datatracker.ietf.org/doc/html/rfc7838',
'https://datatracker.ietf.org/doc/html/rfc8246',
'https://datatracker.ietf.org/doc/html/rfc7230',
'https://datatracker.ietf.org/doc/html/rfc6266',
'https://datatracker.ietf.org/doc/html/rfc7578',
'https://datatracker.ietf.org/doc/html/rfc6265',
'https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-digest-headers-05',
'https://datatracker.ietf.org/doc/html/rfc8470',
'https://datatracker.ietf.org/doc/html/rfc7232',
'https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-expect-ct-08',
'https://datatracker.ietf.org/doc/html/rfc7239',
'https://datatracker.ietf.org/doc/html/draft-thomson-hybi-http-timeout-03',
'https://datatracker.ietf.org/doc/html/rfc6454',
'https://datatracker.ietf.org/doc/html/rfc7235',
'https://datatracker.ietf.org/doc/html/rfc7469',
'https://datatracker.ietf.org/doc/html/rfc6797',
'https://datatracker.ietf.org/doc/html/rfc7540',
'https://datatracker.ietf.org/doc/html/rfc7034',
'https://datatracker.ietf.org/doc/html/rfc7538',
'https://datatracker.ietf.org/doc/html/rfc2324',
'https://datatracker.ietf.org/doc/html/rfc7725',
'https://github.com/tc39/proposal-regexp-legacy-features/',
'https://webassembly.github.io/threads/js-api/',
'https://tc39.es/proposal-hashbang/out.html',
'https://mathml-refresh.github.io/mathml/',
'https://www.w3.org/TR/xpath-31/',
'https://www.w3.org/TR/xslt-30/',
Comment on lines +55 to +56
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two can be removed once we removed XPath and XSLT in #9830

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upon merging, I'll update #9830 to drop these two.

];

const allowList = new Set([...specsFromBrowserSpecs, ...specsExceptions]);
const rejectedSpecs = [];

for (const spec of specURLs) {
if (![...allowList].find(host => spec.startsWith(host)))
rejectedSpecs.push(spec);
}
assert.deepStrictEqual(
rejectedSpecs,
[],
`Invalid specification host(s) found. Try a more current specification URL and/or
check if the specification URL is listed in https://github.com/w3c/browser-specs.`,
);
});
});