Skip to content

Commit

Permalink
Allow preview browsers in the data structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Elchi3 committed May 6, 2021
1 parent 20bce3b commit 7612337
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions browsers/chrome.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"browsers": {
"chrome": {
"name": "Chrome",
"preview_name": "Canary",
"pref_url": "chrome://flags",
"releases": {
"1": {
Expand Down
1 change: 1 addition & 0 deletions browsers/firefox.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"browsers": {
"firefox": {
"name": "Firefox",
"preview_name": "Nightly",
"pref_url": "about:config",
"releases": {
"1": {
Expand Down
1 change: 1 addition & 0 deletions browsers/safari.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"browsers": {
"safari": {
"name": "Safari",
"preview_name": "TP",
"releases": {
"1": {
"release_date": "2003-06-23",
Expand Down
5 changes: 5 additions & 0 deletions schemas/browsers-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -40,6 +41,10 @@ Underneath, there is a `releases` object which will hold the various releases of

The `name` string is a required property which should use the browser brand name and avoid English words if possible, for example `"Firefox"`, `"Firefox Android"`, `"Safari"`, `"iOS Safari"`, etc.

### `preview_name`

An optional string containing the name of the preview browser. For example, this is "Nightly" for Firefox, "Canary" for Chrome, and "TP" for Safari.

### `pref_url`

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).
Expand Down
4 changes: 4 additions & 0 deletions schemas/browsers.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
"type": "string",
"description": "Browser name, avoid using unnecessary English (e.g. prefer 'Chrome Android' over 'Chrome for Android')."
},
"preview_name": {
"type": "string",
"description": "Preview name, avoid long form names (use 'Nightly' instead of 'Firefox Nightly')."
},
"pref_url": {
"type": "string",
"description": "URL of the page where feature flags can be changed (e.g. 'about:config' or 'chrome://flags')."
Expand Down
9 changes: 9 additions & 0 deletions test/linter/test-consistency.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 13 additions & 0 deletions test/linter/test-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

/**
Expand All @@ -54,6 +57,16 @@ function isValidVersion(browserIdentifier, version) {
function removedAfterAdded(statement) {
const { version_added, version_removed } = statement;

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;
}

if (
!(
compareVersions.validate(version_added.replace('≤', '')) &&
Expand Down
6 changes: 6 additions & 0 deletions types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 7612337

Please sign in to comment.