fix(themes): Log validation errors on theme manifests using the deprecated LWT aliases

This commit is contained in:
Luca Greco 2019-07-17 16:21:25 +02:00
Родитель b9e6a82365
Коммит d7e0741101
5 изменённых файлов: 16 добавлений и 23 удалений

Просмотреть файл

@ -133,9 +133,9 @@ Rules are sorted by severity.
| Message code | Severity | Description |
| ------------------------------------ | -------- | ----------------------------------------------------------- |
| `MANIFEST_THEME_LWT_ALIAS` | warning | Theme LWT aliases are deprecated |
| `MANIFEST_THEME_IMAGE_MIME_MISMATCH` | warning | Theme image file extension should match its mime type |
| `MANIFEST_THEME_IMAGE_NOT_FOUND` | error | Theme images must not be missing |
| `MANIFEST_THEME_IMAGE_CORRUPTED` | error | Theme images must not be corrupted |
| `MANIFEST_THEME_IMAGE_WRONG_EXT` | error | Theme images must have one of the supported file extensions |
| `MANIFEST_THEME_IMAGE_WRONG_MIME` | error | Theme images mime type must be a supported format |
| `MANIFEST_THEME_LWT_ALIAS` | error | Theme LWT aliases are deprecated |

Просмотреть файл

@ -128,7 +128,6 @@ export const DEPRECATED_STATIC_THEME_LWT_ALIASES = [
'/theme/images/headerURL',
'/theme/colors/accentcolor',
'/theme/colors/textcolor',
'/theme/colors/toolbar_text',
];
// A list of magic numbers that we won't allow.

Просмотреть файл

@ -300,7 +300,7 @@ export function corruptIconFile({ path }) {
export const MANIFEST_THEME_LWT_ALIAS = {
code: 'MANIFEST_THEME_LWT_ALIAS',
message: i18n._('This theme LWT alias is deprecated.'),
message: i18n._('This theme LWT alias has been removed in Firefox 70.'),
description: i18n._(
'See https://mzl.la/2T11Lkc (MDN Docs) for more information.'
),

Просмотреть файл

@ -241,12 +241,7 @@ export default class ManifestJSONParser extends JSONParser {
_validate() {
// Not all messages returned by the schema are fatal to Firefox, messages
// that are just warnings should be added to this array.
const warnings = [
messages.MANIFEST_PERMISSIONS.code,
// TODO(#2463): Remove the following once the LWT aliases deprecated
// property should become errors on submission.
messages.MANIFEST_THEME_LWT_ALIAS.code,
];
const warnings = [messages.MANIFEST_PERMISSIONS.code];
let validate = validateAddon;
if (this.isStaticTheme) {

Просмотреть файл

@ -2334,7 +2334,7 @@ describe('ManifestJSONParser', () => {
});
describe('deprecated LWT aliases', () => {
it('does add validation warnings for LWT alias manifest properties marked as deprecated', () => {
it('does add validation errors for LWT alias manifest properties marked as deprecated', () => {
const linter = new Linter({ _: ['bar'] });
const manifest = validStaticThemeManifestJSON({
theme: {
@ -2344,6 +2344,9 @@ describe('ManifestJSONParser', () => {
colors: {
accentcolor: '#000',
textcolor: '#000',
// This is not a deprecated property anymore, but it is still
// part of this test to ensure we don't raise linting errors
// for it.
toolbar_text: '#000',
},
},
@ -2358,34 +2361,30 @@ describe('ManifestJSONParser', () => {
expect(manifestJSONParser.isValid).toBeFalsy();
expect(errors).toEqual([]);
expect(warnings).toEqual([]);
const actualWarnings = warnings.map((warn) => {
const { code, dataPath, file, message, description } = warn;
const actualErrors = errors.map((err) => {
const { code, dataPath, file, message, description } = err;
return { code, dataPath, file, message, description };
});
const commonWarnProps = { ...messages.MANIFEST_THEME_LWT_ALIAS };
const expectedWarnings = [
const commonErrorProps = { ...messages.MANIFEST_THEME_LWT_ALIAS };
const expectedErrors = [
{
...commonWarnProps,
...commonErrorProps,
dataPath: '/theme/images/headerURL',
},
{
...commonWarnProps,
...commonErrorProps,
dataPath: '/theme/colors/accentcolor',
},
{
...commonWarnProps,
...commonErrorProps,
dataPath: '/theme/colors/textcolor',
},
{
...commonWarnProps,
dataPath: '/theme/colors/toolbar_text',
},
];
expect(actualWarnings).toEqual(expectedWarnings);
expect(actualErrors).toEqual(expectedErrors);
});
});
});