2012-08-02 02:43:36 +04:00
|
|
|
import appvalidator.testcases.markup.csstester as csstester
|
2012-08-11 00:57:34 +04:00
|
|
|
from appvalidator.errorbundle import ErrorBundle
|
2012-08-02 02:43:36 +04:00
|
|
|
|
2010-06-16 22:03:31 +04:00
|
|
|
|
|
|
|
def _do_test(path, should_fail=False):
|
2011-05-19 11:21:26 +04:00
|
|
|
|
|
|
|
data = open(path).read()
|
|
|
|
err = ErrorBundle()
|
|
|
|
|
2010-07-15 03:23:47 +04:00
|
|
|
csstester.test_css_file(err, "css.css", data)
|
2010-08-19 01:03:51 +04:00
|
|
|
err.print_summary(True)
|
2011-05-19 11:21:26 +04:00
|
|
|
|
2010-06-16 22:03:31 +04:00
|
|
|
if should_fail:
|
|
|
|
assert err.failed()
|
|
|
|
else:
|
|
|
|
assert not err.failed()
|
2011-05-19 11:21:26 +04:00
|
|
|
|
2010-08-19 01:03:51 +04:00
|
|
|
return err
|
2010-06-16 22:03:31 +04:00
|
|
|
|
2011-05-19 11:21:26 +04:00
|
|
|
|
2010-06-16 22:03:31 +04:00
|
|
|
def test_css_file():
|
|
|
|
"Tests a package with a valid CSS file."
|
2011-05-19 11:21:26 +04:00
|
|
|
|
2010-06-16 22:03:31 +04:00
|
|
|
_do_test("tests/resources/markup/csstester/pass.css")
|
2011-05-19 11:21:26 +04:00
|
|
|
|
|
|
|
|
2011-01-19 22:57:41 +03:00
|
|
|
def test_remote_urls():
|
|
|
|
"Tests the Regex used to detect remote URLs"
|
|
|
|
|
|
|
|
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")')
|
|
|
|
assert not t("url('foo/bar.abc')")
|
|
|
|
|
|
|
|
assert not t("url(chrome://foo/bar)")
|
|
|
|
assert not t("url(resource:asdf)")
|
|
|
|
|
|
|
|
assert t("url(http://abc.def)")
|
|
|
|
assert t("url(https://abc.def)")
|
|
|
|
assert t("url(ftp://abc.def)")
|
|
|
|
assert t("url(//abcdef)")
|
|
|
|
assert not t("url(/abc.def)")
|
|
|
|
|
2011-01-19 23:07:19 +03:00
|
|
|
assert not t("UrL(/abc.def)")
|
|
|
|
assert t("url(HTTP://foo.bar/)")
|