Skip to content
Browse files

Regex + CSS tests for FX16 (bugs 795423, 795425, 795428)

  • Loading branch information...
1 parent 0825919 commit 09fc2f17927c4fffcb9c55d425393f76acb876d5 @mattbasta committed Oct 2, 2012
View
32 tests/compat/test_gecko16.py
@@ -0,0 +1,32 @@
+from helper import CompatTestCase
+from validator.compat import FX16_DEFINITION
+
+
+class TestFX16Compat(CompatTestCase):
+ """Test that compatibility tests for Gecko 16 are properly executed."""
+
+ VERSION = FX16_DEFINITION
+
+ def test_mozjs_incomplete(self):
+ """Test that `MozWhatever*` is notflagged in Gecko 16."""
+ self.run_script_for_compat("x.MozTransition;")
+ self.assert_silent()
+ self.assert_compat_silent()
+
+ def test_mozjs_full(self):
+ """Test that `MozWhatever*` is flagged in Gecko 16."""
+ self.run_script_for_compat("x.MozTransitionStuff")
+ self.assert_silent()
+ self.assert_compat_warning(type_="warning")
+
+ def test_nsitransferable(self):
+ """Test that `nsITransferable` is flagged in Gecko 16."""
+ self.run_script_for_compat("nsITransferable.foo.bar;")
+ self.assert_silent()
+ self.assert_compat_error()
+
+ def test_mozIndexedDB(self):
+ """Test that `mozIndexedDB` is flagged in Gecko 16."""
+ self.run_script_for_compat("mozIndexedDB.foo.bar;")
+ self.assert_silent()
+ self.assert_compat_error()
View
45 tests/test_markup_csstester.py
@@ -1,3 +1,4 @@
+from validator.compat import FX16_DEFINITION
from validator.constants import PACKAGE_THEME
import validator.testcases.markup.csstester as csstester
from validator.errorbundler import ErrorBundle
@@ -45,7 +46,7 @@ def test_css_identitybox_themes():
def test_remote_urls():
"Tests the Regex used to detect remote URLs"
- t = lambda s:csstester.BAD_URL.match(s) is not None
+ t = lambda s: csstester.BAD_URL.match(s) is not None
assert not t("url(foo/bar.abc)")
assert not t('url("foo/bar.abc")')
@@ -63,3 +64,45 @@ def test_remote_urls():
assert not t("UrL(/abc.def)")
assert t("url(HTTP://foo.bar/)")
+
+def test_unprefixed_patterns():
+ """
+ Test that add-ons that use prefixed CSS descriptors get a compat warning.
+ """
+
+ def test_descriptor(descriptor):
+ err = ErrorBundle(for_appversions=FX16_DEFINITION)
+ csstester.test_css_snippet(err, "x.css", "x {%s: 0;}" % descriptor, 0)
+ assert err.warnings
+ assert any(err.compat_summary.values())
+
+ yield test_descriptor, "-moz-transition-foo"
+ yield test_descriptor, "-moz-keyframes"
+ yield test_descriptor, "-moz-animation-keyframes"
+ yield test_descriptor, "-moz-transform-stuff"
+ yield test_descriptor, "-moz-perspective-stuff"
+ yield test_descriptor, "-moz-backface-visibility"
+ yield test_descriptor, "-moz-super-gradient"
+
+
+def test_unprefixed_moz_calc():
+ err = ErrorBundle(for_appversions=FX16_DEFINITION)
+ csstester.test_css_snippet(
+ err, "x.css", "x {foo: -moz-calc(40% + 100px);}", 0)
+ assert err.warnings
+ assert any(err.compat_summary.values())
+
+
+def test_unprefixed_patterns_unchanged():
+ """
+ Test that patterns that haven't been unprefixed don't get flagged.
+ """
+
+ def test_descriptor(descriptor):
+ err = ErrorBundle(for_appversions=FX16_DEFINITION)
+ csstester.test_css_snippet(err, "x.css", "x {%s: 0;}" % descriptor, 0)
+ assert not err.failed()
+ assert not any(err.compat_summary.values())
+
+ yield test_descriptor, "-moz-gradient"
+ yield test_descriptor, "calc"
View
1 validator/compat.py
@@ -54,4 +54,3 @@ def _build_definition(maj_version_num, firefox=True, fennec=True,
TB13_DEFINITION = _build_definition(13, firefox=False, fennec=False)
TB14_DEFINITION = _build_definition(14, firefox=False, fennec=False)
TB15_DEFINITION = _build_definition(15, firefox=False, fennec=False)
-
View
63 validator/testcases/markup/csstester.py
@@ -1,13 +1,25 @@
import re
-import fnmatch
+from functools import partial
import cssutils
+from validator.compat import FX16_DEFINITION
from validator.constants import PACKAGE_THEME
from validator.contextgenerator import ContextGenerator
+
BAD_URL_PAT = "url\(['\"]?(?!(chrome:|resource:))(\/\/|(ht|f)tps?:\/\/|data:)[a-z0-9\/\-\.#]*['\"]?\)"
BAD_URL = re.compile(BAD_URL_PAT, re.I)
+SKIP_TYPES = ("S", "COMMENT")
+
+UNPREFIXED_LINK1 = ("https://developer.mozilla.org/en-US/docs/"
+ "Firefox_16_for_developers")
+UNPREFIXED_LINK2 = "https://hacks.mozilla.org/2012/07/aurora-16-is-out/"
+UNPREFIXED_MESSAGE = ["Several CSS properties have been unprefixed in Firefox "
+ "16 and no longer work in their prefixed form.",
+ "For more information, see %s and %s" %
+ (UNPREFIXED_LINK1, UNPREFIXED_LINK2)]
+
def test_css_file(err, filename, data, line_start=1):
"Parse and test a whole CSS file."
@@ -54,32 +66,36 @@ def _run_css_tests(err, tokens, filename, line_start=0, context=None):
last_descriptor = None
- skip_types = ("S", "COMMENT")
-
identity_box_mods = []
unicode_errors = []
while True:
try:
- (tok_type, value, line, position) = tokens.next()
+ tok_type, value, line, position = tokens.next()
except UnicodeDecodeError:
unicode_errors.append(str(line + line_start))
continue
except StopIteration:
break
- except Exception, e:
- # Comment me out for debug!
- raise
- print type(e), e
- print filename
- print line + line_start
+ if tok_type in SKIP_TYPES:
continue
# Save the last descriptor for reference.
- if tok_type == "IDENT":
- last_descriptor = value.lower()
+ if tok_type in ("IDENT", "FUNCTION"):
+ value_lower = value.lower()
+ if tok_type == "IDENT":
+ last_descriptor = value_lower
+ else:
+ value_lower = value_lower[:-1]
+
+ reporter = partial(err.warning,
+ description=UNPREFIXED_MESSAGE,
+ filename=filename, line=line, column=position,
+ for_appversions=FX16_DEFINITION, tier=5,
+ compatibility_type="warning")
+ _test_unprefixed_identifier(reporter, value_lower)
elif tok_type == "URI":
@@ -124,3 +140,26 @@ def _run_css_tests(err, tokens, filename, line_start=0, context=None):
"encountered, causing some problems.",
"Lines: %s" % ", ".join(unicode_errors)],
filename)
+
+
+UNPREFIXED_WARNING = "`%s` is no longer prefixed in Gecko 16."
+
+UNPREFIXED_PATTERNS = map(re.compile, ['-moz-[a-z]+-gradient'])
+
+
+def _test_unprefixed_identifier(reporter, identifier):
+ if identifier in ("-moz-keyframes", "-moz-calc",
+ "-moz-backface-visibility"):
+ reporter(
+ err_id=("css", "prefixes", "match"),
+ warning=UNPREFIXED_WARNING % identifier)
+ elif identifier.startswith(("-moz-transition", "-moz-animation",
+ "-moz-animation", "-moz-transform",
+ "-moz-perspective")):
+ reporter(
+ err_id=("css", "prefixes", "startswith"),
+ warning=UNPREFIXED_WARNING % identifier)
+ elif any(pat.match(identifier) for pat in UNPREFIXED_PATTERNS):
+ reporter(
+ err_id=("css", "prefixes", "pattern"),
+ warning=UNPREFIXED_WARNING % identifier)
View
36 validator/testcases/regex.py
@@ -4,11 +4,12 @@
from validator.compat import (FX4_DEFINITION, FX5_DEFINITION, FX6_DEFINITION,
FX7_DEFINITION, FX8_DEFINITION, FX9_DEFINITION,
FX11_DEFINITION, FX12_DEFINITION, FX13_DEFINITION,
- FX14_DEFINITION, FX15_DEFINITION,
+ FX14_DEFINITION, FX15_DEFINITION, FX16_DEFINITION,
TB7_DEFINITION, TB10_DEFINITION, TB11_DEFINITION,
TB12_DEFINITION, TB13_DEFINITION, TB14_DEFINITION,
TB15_DEFINITION)
from validator.contextgenerator import ContextGenerator
+from markup.csstester import UNPREFIXED_MESSAGE
registered_regex_tests = []
@@ -663,6 +664,36 @@ def tests(self):
@register_generator
+class Gecko16RegexTests(CompatRegexTestHelper):
+ """Regex tests for Gecko 16 updates."""
+
+ VERSION = FX16_DEFINITION
+
+ def tests(self):
+
+ yield self.get_test_bug(
+ 722872, "nsITransferable",
+ "`nsITransferable` has been changed in Gecko 16.",
+ "The `nsITransferable` interface has changed to better "
+ "support Private Browsing Mode. After instantiating the "
+ "object, you should call `.init(null)` on it, before any "
+ "other functions are called.", compat_type="error")
+
+ yield self.get_test_bug(
+ 726378, "mozIndexedDB",
+ "`mozIndexedDB` has been unprefixed in Gecko 16.",
+ "The `mozIndexedDB` object has been renamed to `indexedDB` in "
+ "Firefox 16.", compat_type="error")
+
+ def js_tests(self):
+
+ yield self.get_test(
+ "Moz(Transition|Animation|Transform)[a-zA-Z]+",
+ "Some CSS selectors have been unprefixed in Gecko 16.",
+ UNPREFIXED_MESSAGE, compat_type="warning")
+
+
+@register_generator
class Thunderbird7RegexTests(CompatRegexTestHelper):
"""Regex tests for the Thunderbird 7 update."""
@@ -929,7 +960,7 @@ def tests(self):
r"INVALID_ITEM_PURGE_DELAY": 721517,
r"kFeedUrlDelimiter": 721517,
r"get(FeedUrlsInFolder|NodeValue|RDFTargetValue|"
- "ParentTargetForChildResource)": 721517,
+ "ParentTargetForChildResource)": 721517,
r"getSubscriptions(DS|List|File)": 721517,
r"getItems(DS|File)": 721517,
r"(add|delete)Feed": 721517,
@@ -954,4 +985,3 @@ def tests(self):
"been flagged as having changed, removed, or deprecated "
"in Thunderbird 15." % pattern,
compat_type="error", log_function=self.err.notice)
-
View
6 validator/version.py
@@ -7,8 +7,10 @@
from itertools import izip_longest
import re
+
__all__ = 'Version', 'VersionPart'
+
def strcmp(a, b):
# Null string comes after any non-null string
if not a:
@@ -18,6 +20,7 @@ def strcmp(a, b):
return cmp(a, b)
+
class VersionPart(object):
numA = 0
strB = ''
@@ -62,7 +65,9 @@ def _splitnum(self, string):
return (int(match.group(1) or 0),
match.group(2))
+
class Version(object):
+
def __init__(self, version):
self._version = version
self.parts = map(VersionPart, version.split('.'))
@@ -83,4 +88,3 @@ def __cmp__(self, other):
@property
def is_release(self):
return bool(re.match(r'^[\d.]+$', self._version))
-

0 comments on commit 09fc2f1

Please sign in to comment.
Something went wrong with that request. Please try again.