Don't allow/record static themes compatibilty information for Firefox for Android (#20759)

* Don't allow/record static themes compatibilty information for Firefox for Android
This commit is contained in:
Mathieu Pillard 2023-05-29 11:40:15 +02:00 коммит произвёл GitHub
Родитель dc7cab4054
Коммит 628c1b2759
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
9 изменённых файлов: 57 добавлений и 41 удалений

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

@ -3097,13 +3097,13 @@ class VersionViewSetCreateUpdateMixin(RequestMixin):
assert response.status_code == 400, response.content
assert response.data == {'compatibility': ['Invalid value']}
response = self.request(compatibility={'firefox': {'min': '65.0'}, 'foo': {}})
response = self.request(compatibility={'firefox': {'min': '61.0'}, 'foo': {}})
assert response.status_code == 400, response.content
assert response.data == {'compatibility': ['Invalid app specified']}
# DEFAULT_STATIC_THEME_MIN_VERSION_ANDROID is 65.0 so it exists
# 61.0 (DEFAULT_WEBEXT_DICT_MIN_VERSION_FIREFOX) should be valid.
response = self.request(
compatibility={'firefox': {'min': '65.0'}, 'android': {}}
compatibility={'firefox': {'min': '61.0'}, 'android': {}}
)
assert response.status_code == self.SUCCESS_STATUS_CODE, response.content
data = response.data
@ -3114,7 +3114,7 @@ class VersionViewSetCreateUpdateMixin(RequestMixin):
# android was specified but with an empty dict, so gets the defaults
'android': {'max': '*', 'min': amo.DEFAULT_WEBEXT_MIN_VERSION_ANDROID},
# firefox max wasn't specified, so is the default max app version
'firefox': {'max': '*', 'min': '65.0'},
'firefox': {'max': '*', 'min': '61.0'},
}
assert list(version.compatible_apps.keys()) == [amo.FIREFOX, amo.ANDROID]
@ -3169,7 +3169,7 @@ class VersionViewSetCreateUpdateMixin(RequestMixin):
with patch('olympia.files.utils.parse_xpi', side_effect=self._parse_xpi_mock):
response = self.request(
compatibility={'firefox': {'min': '65.0'}, 'android': {}}
compatibility={'firefox': {'min': '61.0'}, 'android': {}}
)
assert response.status_code == 400, response.content
assert response.data == {
@ -3212,7 +3212,6 @@ class TestVersionViewSetCreate(UploadMixin, VersionViewSetCreateUpdateMixin, Tes
amo.DEFAULT_WEBEXT_MIN_VERSION_NO_ID,
amo.DEFAULT_WEBEXT_MIN_VERSION_ANDROID,
amo.DEFAULT_STATIC_THEME_MIN_VERSION_FIREFOX,
amo.DEFAULT_STATIC_THEME_MIN_VERSION_ANDROID,
amo.DEFAULT_WEBEXT_DICT_MIN_VERSION_FIREFOX,
amo.DEFAULT_WEBEXT_MAX_VERSION,
amo.DEFAULT_WEBEXT_MIN_VERSION_MV3_FIREFOX,
@ -3631,7 +3630,6 @@ class TestVersionViewSetUpdate(UploadMixin, VersionViewSetCreateUpdateMixin, Tes
amo.DEFAULT_WEBEXT_MIN_VERSION_NO_ID,
amo.DEFAULT_WEBEXT_MIN_VERSION_ANDROID,
amo.DEFAULT_STATIC_THEME_MIN_VERSION_FIREFOX,
amo.DEFAULT_STATIC_THEME_MIN_VERSION_ANDROID,
amo.DEFAULT_WEBEXT_DICT_MIN_VERSION_FIREFOX,
amo.DEFAULT_WEBEXT_MAX_VERSION,
'109.0',

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

@ -901,7 +901,6 @@ def create_default_webext_appversion():
versions = {
amo.DEFAULT_WEBEXT_MIN_VERSION_ANDROID,
amo.DEFAULT_STATIC_THEME_MIN_VERSION_ANDROID,
amo.DEFAULT_WEBEXT_MAX_VERSION,
amo.DEFAULT_WEBEXT_MIN_VERSION_MV3_FIREFOX,
}

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

@ -343,9 +343,6 @@ DEFAULT_WEBEXT_MIN_VERSION_BROWSER_SPECIFIC = '48.0'
# The version of desktop Firefox that first supported static themes.
DEFAULT_STATIC_THEME_MIN_VERSION_FIREFOX = '53.0'
# The version of Android that first minimally supported static themes.
DEFAULT_STATIC_THEME_MIN_VERSION_ANDROID = '65.0'
# The version of Firefox that first supported webext dictionaries.
# Dicts are not compatible with Firefox for Android, only desktop is relevant.
DEFAULT_WEBEXT_DICT_MIN_VERSION_FIREFOX = '61.0'

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

@ -250,7 +250,6 @@ def test_extract_theme_properties(zip_file):
versions = {
amo.DEFAULT_WEBEXT_MAX_VERSION,
amo.DEFAULT_STATIC_THEME_MIN_VERSION_FIREFOX,
amo.DEFAULT_STATIC_THEME_MIN_VERSION_ANDROID,
}
for version in versions:
AppVersion.objects.create(application=amo.FIREFOX.id, version=version)

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

@ -432,7 +432,6 @@ class TestParseXpi(amo.tests.AMOPaths, TestCase):
amo.DEFAULT_WEBEXT_MIN_VERSION_NO_ID,
amo.DEFAULT_WEBEXT_MIN_VERSION_ANDROID,
amo.DEFAULT_STATIC_THEME_MIN_VERSION_FIREFOX,
amo.DEFAULT_STATIC_THEME_MIN_VERSION_ANDROID,
amo.DEFAULT_WEBEXT_DICT_MIN_VERSION_FIREFOX,
amo.DEFAULT_WEBEXT_MAX_VERSION,
amo.DEFAULT_WEBEXT_MIN_VERSION_MV3_FIREFOX,

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

@ -53,7 +53,6 @@ class AppVersionsMixin:
cls.create_appversion('android', amo.DEFAULT_WEBEXT_MIN_VERSION_ANDROID)
cls.create_appversion('android', amo.DEFAULT_WEBEXT_MAX_VERSION)
cls.create_appversion('firefox', amo.DEFAULT_STATIC_THEME_MIN_VERSION_FIREFOX)
cls.create_appversion('android', amo.DEFAULT_STATIC_THEME_MIN_VERSION_ANDROID)
cls.create_appversion('firefox', amo.DEFAULT_WEBEXT_MIN_VERSION_MV3_FIREFOX)
cls.create_appversion('android', amo.DEFAULT_WEBEXT_MIN_VERSION_MV3_ANDROID)
@ -679,34 +678,24 @@ class TestManifestJSONExtractorStaticTheme(TestManifestJSONExtractor):
"""
data = {}
apps = self.parse(data)['apps']
assert len(apps) == 2
assert len(apps) == 1
assert apps[0].appdata == amo.FIREFOX
assert apps[0].min.version == (amo.DEFAULT_STATIC_THEME_MIN_VERSION_FIREFOX)
assert apps[0].max.version == amo.DEFAULT_WEBEXT_MAX_VERSION
assert apps[1].appdata == amo.ANDROID
assert apps[1].min.version == (amo.DEFAULT_STATIC_THEME_MIN_VERSION_ANDROID)
assert apps[1].max.version == amo.DEFAULT_WEBEXT_MAX_VERSION
def test_apps_use_default_versions_if_none_provided(self):
"""Use the default min and max versions if none provided."""
data = {'applications': {'gecko': {'id': 'some-id'}}}
apps = self.parse(data)['apps']
assert len(apps) == 2
assert len(apps) == 1
assert apps[0].appdata == amo.FIREFOX
assert apps[0].min.version == (amo.DEFAULT_STATIC_THEME_MIN_VERSION_FIREFOX)
assert apps[0].max.version == amo.DEFAULT_WEBEXT_MAX_VERSION
assert apps[1].appdata == amo.ANDROID
assert apps[1].min.version == (amo.DEFAULT_STATIC_THEME_MIN_VERSION_ANDROID)
assert apps[1].max.version == amo.DEFAULT_WEBEXT_MAX_VERSION
def test_apps_use_provided_versions(self):
"""Use the min and max versions if provided."""
firefox_min_version = self.create_appversion('firefox', '66.0')
firefox_max_version = self.create_appversion('firefox', '66.*')
android_min_version = self.create_appversion('android', '66.0')
android_max_version = self.create_appversion('android', '66.*')
data = {
'applications': {
@ -718,13 +707,10 @@ class TestManifestJSONExtractorStaticTheme(TestManifestJSONExtractor):
}
}
apps = self.parse(data)['apps']
assert len(apps) == 2
assert len(apps) == 1
assert apps[0].appdata == amo.FIREFOX
assert apps[0].min == firefox_min_version
assert apps[0].max == firefox_max_version
assert apps[1].appdata == amo.ANDROID
assert apps[1].min == android_min_version
assert apps[1].max == android_max_version
def test_theme_json_extracted(self):
# Check theme data is extracted from the manifest and returned.
@ -757,14 +743,31 @@ class TestManifestJSONExtractorStaticTheme(TestManifestJSONExtractor):
}
apps = self.parse(data)['apps']
assert len(apps) == 2
assert len(apps) == 1
assert apps[0].appdata == amo.FIREFOX
assert apps[0].min.version == (amo.DEFAULT_STATIC_THEME_MIN_VERSION_FIREFOX)
assert apps[0].max.version == amo.DEFAULT_WEBEXT_MAX_VERSION
assert apps[1].appdata == amo.ANDROID
assert apps[1].min.version == (amo.DEFAULT_STATIC_THEME_MIN_VERSION_ANDROID)
assert apps[1].max.version == amo.DEFAULT_WEBEXT_MAX_VERSION
def test_strict_min_version_100(self):
# Overridden because static themes are not compatible with Android.
firefox_min_version = self.create_appversion('firefox', '100.0')
firefox_max_version = self.create_appversion('firefox', '100.*')
data = {
'applications': {
'gecko': {
'strict_min_version': '>=100.0',
'strict_max_version': '=100.*',
'id': '@radioactive',
}
}
}
apps = self.parse(data)['apps']
assert len(apps) == 1
assert apps[0].appdata == amo.FIREFOX
assert apps[0].min == firefox_min_version
assert apps[0].max == firefox_max_version
@pytest.mark.parametrize(

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

@ -259,12 +259,10 @@ class ManifestJSONExtractor:
# the default min version here doesn't matter much.
apps = ((amo.FIREFOX, amo.DEFAULT_WEBEXT_MIN_VERSION),)
elif type_ == amo.ADDON_STATICTHEME:
# Static themes are only compatible with Firefox desktop >= 53
# and Firefox for Android >=65.
apps = (
(amo.FIREFOX, amo.DEFAULT_STATIC_THEME_MIN_VERSION_FIREFOX),
(amo.ANDROID, amo.DEFAULT_STATIC_THEME_MIN_VERSION_ANDROID),
)
# Static themes are only compatible with Firefox desktop >= 53.
# They used to be compatible with Android, but that support was
# removed.
apps = ((amo.FIREFOX, amo.DEFAULT_STATIC_THEME_MIN_VERSION_FIREFOX),)
elif type_ == amo.ADDON_DICT:
# WebExt dicts are only compatible with Firefox desktop >= 61.
apps = ((amo.FIREFOX, amo.DEFAULT_WEBEXT_DICT_MIN_VERSION_FIREFOX),)

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

@ -0,0 +1,24 @@
# Generated by Django 3.2.18 on 2023-05-26 13:53
from django.db import migrations
from olympia import amo
def remove_static_themes_android_compatibility(apps, schema_editor):
ApplicationsVersions = apps.get_model('versions', 'ApplicationsVersions')
ApplicationsVersions.objects.filter(
version__addon__type=amo.ADDON_STATICTHEME, application=amo.ANDROID.id
).delete()
class Migration(migrations.Migration):
dependencies = [
('versions', '0040_alter_license_name_and_more'),
]
operations = [
migrations.RunPython(
remove_static_themes_android_compatibility, lambda *args: None
)
]

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

@ -2709,7 +2709,6 @@ class TestStaticThemeFromUpload(UploadMixin, TestCase):
def setUpTestData(cls):
versions = {
amo.DEFAULT_STATIC_THEME_MIN_VERSION_FIREFOX,
amo.DEFAULT_STATIC_THEME_MIN_VERSION_ANDROID,
amo.DEFAULT_WEBEXT_MAX_VERSION,
}
for version in versions: