From 98d77c4cbd9938029caaab04df9d241e4d99d264 Mon Sep 17 00:00:00 2001 From: Florian Scholz Date: Mon, 31 May 2021 12:17:46 +0200 Subject: [PATCH 1/4] Test for outdated spec URLs not in w3c/browser-specs --- package-lock.json | 6 +++ package.json | 1 + test/spec-urls.test.js | 96 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 test/spec-urls.test.js diff --git a/package-lock.json b/package-lock.json index 66d71e15e1389a..1cb1c48c01f453 100644 --- a/package-lock.json +++ b/package-lock.json @@ -213,6 +213,12 @@ "fill-range": "^7.0.1" } }, + "browser-specs": { + "version": "1.38.1", + "resolved": "https://registry.npmjs.org/browser-specs/-/browser-specs-1.38.1.tgz", + "integrity": "sha512-AlsiRTsTepSTPg6+GaMBh0fKOuwl02np4jBg8oPFrR6K5l+N7f0SsR7daIOGFC36zzB4aeYFcp6rG468EbMYsw==", + "dev": true + }, "browser-stdout": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", diff --git a/package.json b/package.json index 70f13a8fd5692e..7fd9d7f7238ecb 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/spec-urls.test.js b/test/spec-urls.test.js new file mode 100644 index 00000000000000..523cc475eca055 --- /dev/null +++ b/test/spec-urls.test.js @@ -0,0 +1,96 @@ +'use strict'; +const assert = require('assert'); +const specData = require('browser-specs'); +const { visit } = require('../utils'); + +describe('spec_url data', () => { + it('spec_url specifications only use allow listed hosts by w3c/browser-specs (and those we allow list for now)', () => { + const toVisit = [ + 'api', + 'css', + 'html', + 'http', + 'javascript', + 'mathml', + 'svg', + 'webdriver', + ]; + + let specURLs = []; + for (const key of toVisit) { + visit( + (path, feature) => { + if (feature.spec_url) { + if (Array.isArray(feature.spec_url)) { + specURLs.push(...feature.spec_url); + } else { + specURLs.push(feature.spec_url); + } + } + }, + { + entryPoint: key, + }, + ); + } + + let specsNotInBrowserSpecs = []; + specURLs.forEach(url => { + let spec = specData.find( + spec => + url.startsWith(spec.url) || + url.startsWith(spec.nightly.url) || + url.startsWith(spec.series.nightlyUrl), + ); + if (!spec) { + specsNotInBrowserSpecs.push(url.split('#')[0]); + } + }); + + let uniqueSpecsNotInBrowserSpecs = [ + ...new Set(specsNotInBrowserSpecs.sort()), + ]; + + let temporaryAllowList = [ + 'https://wicg.github.io/controls-list/', + 'https://w3c.github.io/webrtc-extensions/', + 'https://w3c.github.io/setImmediate/', + 'https://datatracker.ietf.org/doc/html/rfc2397', + '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://tc39.es/proposal-pipeline-operator/', + 'https://mathml-refresh.github.io/mathml/', + ].sort(); + + // Ideally browser-specs has all relevant specs included + // and so uniqueSpecsNotInBrowserSpecs should be [] + // However, for the moment we need an allow list + assert.deepStrictEqual(uniqueSpecsNotInBrowserSpecs, temporaryAllowList); + }); +}); From a5ac5be7a16d67491819277441fb963ad7927b37 Mon Sep 17 00:00:00 2001 From: Florian Scholz Date: Wed, 2 Jun 2021 14:37:53 +0200 Subject: [PATCH 2/4] Address feedback --- test/spec-urls.test.js | 77 +++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 49 deletions(-) diff --git a/test/spec-urls.test.js b/test/spec-urls.test.js index 523cc475eca055..ff21b53b8bf18f 100644 --- a/test/spec-urls.test.js +++ b/test/spec-urls.test.js @@ -1,57 +1,25 @@ 'use strict'; const assert = require('assert'); const specData = require('browser-specs'); -const { visit } = require('../utils'); +const { walk } = require('../utils'); describe('spec_url data', () => { - it('spec_url specifications only use allow listed hosts by w3c/browser-specs (and those we allow list for now)', () => { - const toVisit = [ - 'api', - 'css', - 'html', - 'http', - 'javascript', - 'mathml', - 'svg', - 'webdriver', - ]; + it('spec_urls only use allow listed hosts by w3c/browser-specs (and our exception list)', () => { + const specURLs = []; - let specURLs = []; - for (const key of toVisit) { - visit( - (path, feature) => { - if (feature.spec_url) { - if (Array.isArray(feature.spec_url)) { - specURLs.push(...feature.spec_url); - } else { - specURLs.push(feature.spec_url); - } - } - }, - { - entryPoint: key, - }, - ); + 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); } - let specsNotInBrowserSpecs = []; - specURLs.forEach(url => { - let spec = specData.find( - spec => - url.startsWith(spec.url) || - url.startsWith(spec.nightly.url) || - url.startsWith(spec.series.nightlyUrl), - ); - if (!spec) { - specsNotInBrowserSpecs.push(url.split('#')[0]); - } - }); - - let uniqueSpecsNotInBrowserSpecs = [ - ...new Set(specsNotInBrowserSpecs.sort()), + const specsFromBrowserSpecs = [ + ...specData.map(spec => spec.url), + ...specData.map(spec => spec.nightly.url), + ...specData.map(spec => spec.series.nightlyUrl), ]; - let temporaryAllowList = [ + const specsExceptions = [ 'https://wicg.github.io/controls-list/', 'https://w3c.github.io/webrtc-extensions/', 'https://w3c.github.io/setImmediate/', @@ -86,11 +54,22 @@ describe('spec_url data', () => { 'https://tc39.es/proposal-hashbang/out.html', 'https://tc39.es/proposal-pipeline-operator/', 'https://mathml-refresh.github.io/mathml/', - ].sort(); + 'https://www.w3.org/TR/xpath-31/', + 'https://www.w3.org/TR/xslt-30/', + ]; - // Ideally browser-specs has all relevant specs included - // and so uniqueSpecsNotInBrowserSpecs should be [] - // However, for the moment we need an allow list - assert.deepStrictEqual(uniqueSpecsNotInBrowserSpecs, temporaryAllowList); + 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.`, + ); }); }); From d0c1e09bf9791c43f3017e62243294bd17d914a6 Mon Sep 17 00:00:00 2001 From: Florian Scholz Date: Wed, 2 Jun 2021 14:49:34 +0200 Subject: [PATCH 3/4] Remove pipeline operator spec --- test/spec-urls.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/spec-urls.test.js b/test/spec-urls.test.js index ff21b53b8bf18f..207c48a5b32d00 100644 --- a/test/spec-urls.test.js +++ b/test/spec-urls.test.js @@ -52,7 +52,6 @@ describe('spec_url data', () => { 'https://github.com/tc39/proposal-regexp-legacy-features/', 'https://webassembly.github.io/threads/js-api/', 'https://tc39.es/proposal-hashbang/out.html', - 'https://tc39.es/proposal-pipeline-operator/', 'https://mathml-refresh.github.io/mathml/', 'https://www.w3.org/TR/xpath-31/', 'https://www.w3.org/TR/xslt-30/', From 28ad4cb6d905734b4c12281f83209475a10cdd3c Mon Sep 17 00:00:00 2001 From: Florian Scholz Date: Thu, 3 Jun 2021 09:20:12 +0200 Subject: [PATCH 4/4] Remove WebRTC extension spec --- test/spec-urls.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/spec-urls.test.js b/test/spec-urls.test.js index 207c48a5b32d00..947535e9cca548 100644 --- a/test/spec-urls.test.js +++ b/test/spec-urls.test.js @@ -21,7 +21,6 @@ describe('spec_url data', () => { const specsExceptions = [ 'https://wicg.github.io/controls-list/', - 'https://w3c.github.io/webrtc-extensions/', 'https://w3c.github.io/setImmediate/', 'https://datatracker.ietf.org/doc/html/rfc2397', 'https://datatracker.ietf.org/doc/html/rfc8942',