summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-color/parsing/color-invalid-rgb.html
blob: 90dd082f2ae9a2024e411669bbbe68a82868fa2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<!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="help" href="https://drafts.csswg.org/css-color-4/#rgb-functions">
<link rel="help" href="https://drafts.csswg.org/css-color-4/#resolving-sRGB-values">
<link rel="help" href="https://drafts.csswg.org/css-color-4/#serializing-sRGB-values">
<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, 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>