|
6 | 6 |
|
7 | 7 | <style> |
8 | 8 | @property --some-url { |
| 9 | + syntax: "<url>"; |
| 10 | + inherits: false; |
| 11 | + initial-value: "empty"; |
| 12 | + } |
| 13 | + @property --some-string { |
9 | 14 | syntax: "<string>"; |
10 | 15 | inherits: false; |
11 | 16 | initial-value: "empty"; |
12 | 17 | } |
13 | | - @property --some-url-list { |
| 18 | + @property --some-string-list { |
14 | 19 | syntax: "<string>+"; |
15 | 20 | inherits: false; |
16 | 21 | initial-value: "empty"; |
17 | 22 | } |
18 | 23 | div { |
19 | | - --some-url: attr(data-foo); |
20 | | - --some-url-list: attr(data-foo); |
| 24 | + --some-string: attr(data-foo); |
| 25 | + --some-string-list: "https://does-not-exist2.test/404.png" attr(data-foo); |
21 | 26 | --some-other-url: attr(data-foo); |
| 27 | + --image-set-valid: url("https://does-not-exist.test/404.png") type(attr(data-foo)); |
| 28 | + --image-set-invalid: attr(data-foo type(<url>)) 1x; |
22 | 29 | } |
23 | 30 | </style> |
24 | 31 |
|
|
70 | 77 | 'https://does-not-exist.test/404.png', |
71 | 78 | 'src(url("https://does-not-exist.test/404.png"))'); |
72 | 79 |
|
| 80 | + // The following string() function is under discussion in the working group and does not exist yet. |
73 | 81 | test_attr('--x', |
74 | 82 | 'src(string("https://does-not-exist.test" attr(data-foo)))', |
75 | 83 | '/404.png', |
|
79 | 87 | '/404.png', |
80 | 88 | 'none'); |
81 | 89 | test_attr('background-image', |
82 | | - 'src(string("https://does-not-exist.test/""404.png")))', |
| 90 | + 'src(string("https://does-not-exist.test/""404.png"))', |
83 | 91 | '/404.png', |
84 | 92 | 'src(url("https://does-not-exist.test/404.png"))'); |
85 | 93 |
|
86 | 94 | test_attr('--x', |
87 | | - 'image(attr(data-foo))', |
88 | | - 'https://does-not-exist.test/404.png', |
89 | | - 'image("https://does-not-exist.test/404.png")'); |
| 95 | + 'attr(data-foo type(<url>))', |
| 96 | + 'url(https://does-not-exist.test/404.png)', |
| 97 | + 'url("https://does-not-exist.test/404.png")'); |
| 98 | + test_attr('--some-url', |
| 99 | + 'attr(data-foo type(<url>))', |
| 100 | + 'url(https://does-not-exist.test/404.png)', |
| 101 | + 'none'); |
90 | 102 | test_attr('background-image', |
91 | | - 'image(attr(data-foo))', |
92 | | - 'https://does-not-exist.test/404.png', |
| 103 | + 'attr(data-foo type(<url>))', |
| 104 | + 'url(https://does-not-exist.test/404.png)', |
93 | 105 | 'none'); |
94 | 106 | test_attr('background-image', |
95 | | - 'image("https://does-not-exist.test/404.png")', |
96 | | - 'https://does-not-exist.test/404.png', |
97 | | - 'image(url("https://does-not-exist.test/404.png"))'); |
| 107 | + 'url("https://does-not-exist.test/404.png")', |
| 108 | + 'url(https://does-not-exist.test/404.png)', |
| 109 | + 'url("https://does-not-exist.test/404.png")'); |
| 110 | + |
98 | 111 |
|
99 | 112 | test_attr('--x', |
100 | 113 | 'image(attr(data-foo))', |
|
123 | 136 |
|
124 | 137 | // Test via a registered custom property. |
125 | 138 | test_attr('--x', |
126 | | - 'image-set(var(--some-url))', |
| 139 | + 'image-set(var(--some-string))', |
127 | 140 | 'https://does-not-exist.test/404.png', |
128 | 141 | 'image-set("https://does-not-exist.test/404.png")'); |
129 | 142 | test_attr('background-image', |
130 | | - 'image-set(var(--some-url))', |
| 143 | + 'image-set(var(--some-string))', |
131 | 144 | 'https://does-not-exist.test/404.png', |
132 | 145 | 'none'); |
133 | 146 |
|
134 | 147 | // Test via a registered custom property (list). |
135 | 148 | test_attr('--x', |
136 | | - 'image-set(var(--some-url))', |
| 149 | + 'image-set(var(--some-string-list))', |
137 | 150 | 'https://does-not-exist.test/404.png', |
138 | | - 'image-set("https://does-not-exist.test/404.png")'); |
| 151 | + 'image-set("https://does-not-exist2.test/404.png" "https://does-not-exist.test/404.png")'); |
139 | 152 | test_attr('background-image', |
140 | | - 'image-set(var(--some-url))', |
| 153 | + 'image-set(var(--some-string-list))', |
141 | 154 | 'https://does-not-exist.test/404.png', |
142 | 155 | 'none'); |
143 | 156 |
|
|
150 | 163 | 'image-set(var(--some-other-url))', |
151 | 164 | 'https://does-not-exist.test/404.png', |
152 | 165 | 'none'); |
| 166 | + |
| 167 | + // Test multiple token substitution |
| 168 | + test_attr('background-image', |
| 169 | + 'attr(data-foo type(*))', |
| 170 | + 'url(https://does-not-exist.test/404.png), linear-gradient(black, white)', |
| 171 | + 'none'); |
| 172 | + |
| 173 | + // Test total attr()-tainting for substitution values |
| 174 | + test_attr('background-image', |
| 175 | + 'image-set(var(--image-set-valid))', |
| 176 | + 'image/jpeg', |
| 177 | + 'none'); |
| 178 | + test_attr('background-image', |
| 179 | + 'image-set(var(--image-set-invalid))', |
| 180 | + 'https://does-not-exist.test/404.png', |
| 181 | + 'none'); |
153 | 182 | </script> |
0 commit comments