From 8b84bb9831ab2fa18d769df35ba4ad687ce5551a Mon Sep 17 00:00:00 2001 From: Florian Scholz Date: Thu, 6 May 2021 16:41:27 +0200 Subject: [PATCH] Allow preview browsers in the data structure --- browsers/chrome.json | 1 + browsers/firefox.json | 1 + browsers/safari.json | 1 + schemas/browsers-schema.md | 5 +++++ schemas/browsers.schema.json | 4 ++++ test/linter/test-consistency.js | 9 +++++++++ test/linter/test-versions.js | 13 +++++++++++++ types.d.ts | 6 ++++++ 8 files changed, 40 insertions(+) diff --git a/browsers/chrome.json b/browsers/chrome.json index 64669b19ddda8d..0c3d618de4daa3 100644 --- a/browsers/chrome.json +++ b/browsers/chrome.json @@ -2,6 +2,7 @@ "browsers": { "chrome": { "name": "Chrome", + "preview_name": "Canary", "pref_url": "chrome://flags", "releases": { "1": { diff --git a/browsers/firefox.json b/browsers/firefox.json index 0faccd8230897c..aa0ca7604b8dc6 100644 --- a/browsers/firefox.json +++ b/browsers/firefox.json @@ -2,6 +2,7 @@ "browsers": { "firefox": { "name": "Firefox", + "preview_name": "Nightly", "pref_url": "about:config", "releases": { "1": { diff --git a/browsers/safari.json b/browsers/safari.json index d16eeb94cf5d32..1542001fbd4d50 100644 --- a/browsers/safari.json +++ b/browsers/safari.json @@ -2,6 +2,7 @@ "browsers": { "safari": { "name": "Safari", + "preview_name": "TP", "releases": { "1": { "release_date": "2003-06-23", diff --git a/schemas/browsers-schema.md b/schemas/browsers-schema.md index 75a9101d2d281b..6a79d47c963733 100644 --- a/schemas/browsers-schema.md +++ b/schemas/browsers-schema.md @@ -17,6 +17,7 @@ The file `firefox.json` is structured like this: "browsers": { "firefox": { "name": "Firefox", + "preview_name": "Nightly", "pref_url": "about:config", "releases": { "1.5": { @@ -48,6 +49,10 @@ An optional boolean indicating whether the browser supports flags. This is a hin An optional string containing the URL of the page where feature flags can be changed (e.g. `"about:config"` for Firefox or `"chrome://flags"` for Chrome). +### `preview_name` + +An optional string containing the name of the preview browser. For example, "Nightly" for Firefox, "Canary" for Chrome, and "TP" for Safari. + ### Release objects The release objects consist of the following properties: diff --git a/schemas/browsers.schema.json b/schemas/browsers.schema.json index 136a07fce5aaa1..0c22d965e7a0d6 100644 --- a/schemas/browsers.schema.json +++ b/schemas/browsers.schema.json @@ -38,6 +38,10 @@ "type": "string", "description": "URL of the page where feature flags can be changed (e.g. 'about:config' or 'chrome://flags')." }, + "preview_name": { + "type": "string", + "description": "Preview name, avoid long-form names (use 'Nightly' instead of 'Firefox Nightly')." + }, "releases": { "type": "object", "additionalProperties": { "$ref": "#/definitions/release_statement" } diff --git a/test/linter/test-consistency.js b/test/linter/test-consistency.js index 88f5a52f793550..d029f0bf44af75 100644 --- a/test/linter/test-consistency.js +++ b/test/linter/test-consistency.js @@ -322,6 +322,15 @@ class ConsistencyChecker { if (b_version_added.startsWith('≤')) { return false; } + if (a_version_added === 'preview' && b_version_added === 'preview') { + return false; + } + if (b_version_added === 'preview') { + return true; + } + if (a_version_added === 'preview') { + return false; + } return compareVersions.compare( a_version_added.replace('≤', ''), b_version_added, diff --git a/test/linter/test-versions.js b/test/linter/test-versions.js index f20a6ae1cf0c50..17b2282270bb81 100644 --- a/test/linter/test-versions.js +++ b/test/linter/test-versions.js @@ -33,6 +33,9 @@ for (const browser of Object.keys(browsers)) { if (VERSION_RANGE_BROWSERS[browser]) { validBrowserVersions[browser].push(...VERSION_RANGE_BROWSERS[browser]); } + if (browsers[browser].preview_name) { + validBrowserVersions[browser].push('preview'); + } } /** @@ -63,6 +66,16 @@ function addedBeforeRemoved(statement) { return null; } + if (version_added === 'preview' && version_removed === 'preview') { + return false; + } + if (version_added === 'preview' && version_removed !== 'preview') { + return false; + } + if (version_added !== 'preview' && version_removed === 'preview') { + return true; + } + return compareVersions.compare(added, removed, '<'); } diff --git a/types.d.ts b/types.d.ts index f1b922eafea671..8bfe246e8e6df7 100644 --- a/types.d.ts +++ b/types.d.ts @@ -45,6 +45,12 @@ export interface BrowserStatement { */ name: string; + /** + * The preview browser's name, for example: + * `"Nightly"`, `"Canary"`, `"TP"`, etc. + */ + preview_name: string; + /** * The known versions of this browser. */