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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
<!DOCTYPE html>
<meta charset="utf-8">
<title>SVG presentation attributes - special cases</title>
<link rel="help" href="https://svgwg.org/svg2-draft/styling.html#PresentationAttributes">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="presentation-attributes.js"></script>
<svg id="svg"></svg>
<script>
// 1. Test the special cases where presentation attributes are only allowed on
// a specific set of elements.
if (propertiesAreSupported(["cx", "cy"])) {
for (let e of ["circle", "ellipse"]) {
test(function() {
for (let p of ["cx", "cy"]) {
assertPresentationAttributeIsSupported(e, p, "1", p);
}
}, `cx and cy presentation attributes supported on ${e} element`);
}
}
if (propertiesAreSupported(["x", "y", "width", "height"])) {
for (let e of ["foreignObject", "image", "rect", "svg", "symbol", "use"]) {
test(function() {
for (let p of ["x", "y", "width", "height"]) {
assertPresentationAttributeIsSupported(e, p, "1", p);
}
}, `x, y, width, and height presentation attributes supported on ${e} element`);
}
}
if (CSS.supports("r", "initial")) {
test(function() {
assertPresentationAttributeIsSupported("circle", "r", "1", "r");
}, `r presentation attribute supported on circle element`);
}
if (propertiesAreSupported(["rx", "ry"])) {
for (let e of ["ellipse", "rect"]) {
test(function() {
for (let p of ["rx", "ry"]) {
assertPresentationAttributeIsSupported(e, p, "1", p);
}
}, `rx and ry presentation attributes supported on ${e} element`);
}
}
if (CSS.supports("d", "initial")) {
test(function() {
assertPresentationAttributeIsSupported("path", "d", "M0,0 L1,1", "d");
}, `d presentation attribute supported on path element`);
}
// 2. Test that for those presentation attributes only allowed on a specific
// set of elements, that they are not supported on some other SVG element.
// (We use 'g' as that element for testing.)
if (propertiesAreSupported(["cx", "cy"])) {
test(function() {
for (let p of ["cx", "cy"]) {
assertPresentationAttributeIsNotSupported("g", p, "1", p);
}
}, `cx and cy presentation attributes not supported on other elements`);
}
if (propertiesAreSupported(["x", "y", "width", "height"])) {
test(function() {
for (let p of ["x", "y", "width", "height"]) {
assertPresentationAttributeIsNotSupported("g", p, "1", p);
}
}, `x, y, width, and height presentation attributes not supported on other elements`);
}
if (CSS.supports("r", "initial")) {
test(function() {
assertPresentationAttributeIsNotSupported("g", "r", "1", "r");
}, `r presentation attribute not supported on other elements`);
}
if (propertiesAreSupported(["rx", "ry"])) {
test(function() {
for (let p of ["rx", "ry"]) {
assertPresentationAttributeIsNotSupported("g", p, "1", p);
}
}, `rx and ry presentation attributes not supported on other elements`);
}
if (CSS.supports("d", "initial")) {
test(function() {
assertPresentationAttributeIsNotSupported("g", "d", "M0,0 L1,1", "d");
}, `d presentation attribute not supported on other elements`);
}
// 3. Test that the fill presentation attribute is not supported on any
// animation elements.
if (CSS.supports("fill", "initial")) {
for (let e of ["animate", "animateMotion", "animateTransform", "discard", "set"]) {
test(function() {
assertPresentationAttributeIsNotSupported(e, "fill", "blue", "fill");
}, `fill presentation attribute not supported on ${e}`);
}
}
if (CSS.supports("transform", "initial")) {
// 4. Test support for the presentation attributes of the transform property,
// which have a different spelling depending on which element they're on.
test(function() {
assertPresentationAttributeIsSupported("g", "transform", "scale(2)", "transform");
}, `transform presentation attribute supported on g`);
test(function() {
assertPresentationAttributeIsSupported("pattern", "patternTransform", "scale(2)", "transform");
}, `patternTransform presentation attribute supported on pattern`);
for (let e of ["linearGradient", "radialGradient"]) {
test(function() {
assertPresentationAttributeIsSupported(e, "gradientTransform", "scale(2)", "transform");
}, `patternTransform presentation attribute supported on ${e}`);
}
// 5. Test that the wrong spellings of the presentation attributes of the
// transform property are not supported.
test(function() {
for (let e of ["pattern", "linearGradient", "radialGradient"]) {
assertPresentationAttributeIsNotSupported(e, "transform", "scale(2)", "transform");
}
}, `transform presentation attribute not supported on pattern or gradient elements`);
test(function() {
for (let e of ["g", "linearGradient", "radialGradient"]) {
assertPresentationAttributeIsNotSupported(e, "patternTransform", "scale(2)", "transform");
}
}, `patternTransform presentation attribute not supported on g or gradient elements`);
test(function() {
for (let e of ["g", "pattern"]) {
assertPresentationAttributeIsNotSupported(e, "gradientTransform", "scale(2)", "transform");
}
}, `gradientTransform presentation attribute not supported on g or pattern elements`);
}
</script>
|