blob: cfb2662930461834cded3be33d11eb40c5f4b11d [file] [log] [blame]
<!DOCTYPE HTML><!-- webkit-test-runner [ experimental:WebAnimationsCSSIntegrationEnabled=false ] -->
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<script>
description("Test window.CSS.supports()");
shouldBeTrue('CSS.supports("display: none")');
shouldBeTrue('CSS.supports("(display: none)")');
shouldBeTrue('CSS.supports(" display: none ")');
shouldBeFalse('CSS.supports("(display: deadbeef)")');
shouldBeFalse('CSS.supports("display: deadbeef")');
shouldBeTrue('CSS.supports("(display: none) and ((display: block) or (display: inline))")');
shouldBeTrue('CSS.supports("(not (display: deadbeef)) and (display: block)")');
shouldBeTrue('CSS.supports("top: -webkit-calc(80% - 20px)")');
shouldBeTrue('CSS.supports("background-color: rgb(0, 128, 0)")');
shouldBeTrue('CSS.supports("background: url(\'/blah\')")');
shouldBeFalse('CSS.supports("background: invalid(\'/blah\')")');
shouldBeFalse('CSS.supports("display: none;")');
shouldBeFalse('CSS.supports("display: none; garbage")');
shouldBeFalse('CSS.supports(" display: none ; garbage ")');
// Negation
shouldBeTrue('CSS.supports("not (display: deadbeef)")');
shouldBeFalse('CSS.supports("not (display: none)")');
shouldBeTrue('CSS.supports("not (not (display: none))")');
shouldBeFalse('CSS.supports("not (not (not (display: none)))")');
// Conjunction.
shouldBeTrue('CSS.supports("(display: none) and (display: block)")');
shouldBeTrue('CSS.supports("(display: none) and (display: block) and (display: inline)")');
shouldBeFalse('CSS.supports("(display: none) and (display: block) and (display: deadbeef) and (display: inline)")');
// Disjunction.
shouldBeTrue('CSS.supports("(display: none) or (display: inline)")');
shouldBeTrue('CSS.supports("(display: none) or (display: block) or (display: inline)")');
shouldBeTrue('CSS.supports("(display: none) or (display: deadbeef) or (display: inline)")');
shouldBeFalse('CSS.supports("(display: ohhai) or (display: deadbeef) or (display: rainbows)")');
// Bad syntax. Can't mix operators without a layer of parentheses..
shouldBeFalse('CSS.supports("(display: none) and (display: block) or (display: inline)")');
shouldBeFalse('CSS.supports("not (display: deadbeef) and (display: block)")');
// Mix 'n match.
shouldBeTrue('CSS.supports("(not (border: 1px 1px 1px 1px 1px solid #000)) and (display: block)")');
shouldBeTrue('CSS.supports("(display: block !important) and ((display: inline) or (display: deadbeef))")');
shouldBeTrue('CSS.supports("not ((not (display: block)) or ((display: none) and (deadbeef: 1px)))")');
// Whitespace/Syntax.
shouldBeTrue('CSS.supports("not( display: deadbeef)")');
shouldBeTrue('CSS.supports("(display: none)and ( -webkit-transition: all 1s )")');
shouldBeTrue('CSS.supports("(display: none)or(-webkit-transition: all 1s)")');
shouldBeTrue('CSS.supports("(display: none) or(-webkit-transition: all 1s )")');
shouldBeTrue('CSS.supports("(((((((display: none)))))))")');
shouldBeFalse('CSS.supports("(!important)")');
shouldBeFalse('CSS.supports("!important")');
shouldBeFalse('CSS.supports("not not not not (display: none)")');
// Functions.
shouldBeTrue('CSS.supports("(top: -webkit-calc(80% - 20px))")');
shouldBeTrue('CSS.supports("(background-color: rgb(0, 128, 0))")');
shouldBeTrue('CSS.supports("(background: url(\'/blah\'))")');
shouldBeTrue('CSS.supports("((top: -webkit-calc(80% - 20px)) and (not (background-color: rgb(0, 128, 0)))) or (background: url(\'/blah\'))")');
shouldBeFalse('CSS.supports("(background: invalid(\'/blah\'))")');
// Property/value variant.
shouldBeTrue('CSS.supports("top", "20%")');
shouldBeTrue('CSS.supports("top", " 20px ")');
shouldBeFalse('CSS.supports("top", "20")');
shouldBeFalse('CSS.supports("dis\\nplay", "none")');
shouldBeFalse('CSS.supports("display", "rainbow")');
shouldBeFalse('CSS.supports("display", "url(rainbow.png)")');
shouldBeTrue('CSS.supports(" background ", "url(rainbow.png)")');
shouldBeFalse('CSS.supports("background", "invalid(rainbow.png)")');
shouldBeTrue('CSS.supports("background-color", "#000")');
shouldBeTrue('CSS.supports("background-color", "rgba(0,0,0,0)")');
shouldBeTrue('CSS.supports("background-color", "inherit")');
shouldBeTrue('CSS.supports("display", "none !important")');
shouldBeTrue('CSS.supports("display", "none!important")');
shouldBeFalse('CSS.supports("display", "!important none")');
shouldBeFalse('CSS.supports("display", "none !important ! important ")');
shouldBeTrue('CSS.supports("display", "none ! important")');
shouldBeTrue('CSS.supports("display", "none ! \timportant")');
shouldBeTrue('CSS.supports("display", "none ! \\nimportant")');
shouldBeFalse('CSS.supports("", "")');
shouldBeFalse('CSS.supports(true, "")');
shouldBeFalse('CSS.supports([], "none")');
shouldBeFalse('CSS.supports("display", "")');
shouldBeFalse('CSS.supports("display:", "none")');
shouldBeTrue('CSS.supports("z-index", 1)');
shouldBeFalse('CSS.supports("content", [])');
shouldBeFalse('CSS.supports("content", "!important")');
shouldBeFalse('CSS.supports("(display: none)", undefined)');
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>