Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Color Level 4: Parsing and serialization of colors using invalid RGB notation</title>
<link rel="author" title="Chris Nardi" href="mailto:csnardi1@gmail.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/parsing-testcommon.js"></script>
</head>
<body>
<script>
tests = [
["rgb(none, none, none)", "The none keyword is invalid in legacy color syntax"],
["rgba(none, none, none, none)", "The none keyword is invalid in legacy color syntax"],
["rgb(128, 0, none)", "The none keyword is invalid in legacy color syntax"],
["rgb(255, 255, 255, none)", "The none keyword is invalid in legacy color syntax"],
["rgb(10%, 50%, 0)", "Values must be all numbers or all percentages"],
["rgb(255, 50%, 0%)", "Values must be all numbers or all percentages"],
["rgb(0, 0 0)", "Comma optional syntax requires no commas at all"],
["rgb(,0, 0, 0)", "Leading commas are invalid"],
["rgb(0, 0,, 0)", "Double commas are invalid"],
["rgb(0, 0, 0deg)", "Angles are not accepted in the rgb function"],
["rgb(0, 0, light)", "Keywords are not accepted in the rgb function"],
["rgb()", "The rgb function requires 3 or 4 arguments"],
["rgb(0)", "The rgb function requires 3 or 4 arguments"],
["rgb(0, 0)", "The rgb function requires 3 or 4 arguments"],
["rgb(0%)", "The rgb function requires 3 or 4 arguments"],
["rgb(0%, 0%)", "The rgb function requires 3 or 4 arguments"],
["rgba(10%, 50%, 0, 1)", "Values must be all numbers or all percentages"],
["rgba(255, 50%, 0%, 1)", "Values must be all numbers or all percentages"],
["rgba(0, 0, 0 0)", "Comma optional syntax requires no commas at all"],
["rgba(0, 0, 0, 0deg)", "Angles are not accepted in the rgb function"],
["rgba(0, 0, 0, light)", "Keywords are not accepted in the rgb function"],
["rgba()", "The rgba function requires 3 or 4 arguments"],
["rgba(0)", "The rgba function requires 3 or 4 arguments"],
["rgba(0, 0, 0, 0, 0)", "The rgba function requires 3 or 4 arguments"],
["rgba(0%)", "The rgba function requires 3 or 4 arguments"],
["rgba(0%, 0%)", "The rgba function requires 3 or 4 arguments"],
["rgba(0%, 0%, 0%, 0%, 0%)", "The rgba function requires 3 or 4 arguments"],
["rgb(257, 0, 5 / 0)", "Cannot mix legacy and non-legacy formats"],
];
for (const test of tests) {
test_invalid_value("color", test[0]);
}
</script>
</body>
</html>