Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 0734aaa

Browse files
tursunovamoz-wptsync-bot
authored andcommitted
Bug 1932855 [wpt PR 49330] - Clean up wpt tests for attr() security, a=testonly
Automatic update from web-platform-tests Clean up wpt tests for attr() security Clean up wpt tests for attr() security violations, add tests for url() function and tests reflecting the following spec changes [0]. [0] w3c/csswg-drafts#11218 Bug: 40320391 Change-Id: I05d73f4ee78aff1ccd0ae7f90584f5f5a9353b09 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6020647 Reviewed-by: Anders Hartvoll Ruud <[email protected]> Commit-Queue: Munira Tursunova <[email protected]> Cr-Commit-Position: refs/heads/main@{#1386745} -- wpt-commits: 5f258ba9dcd1e9c6fad46cac100a6036a9ec11bb wpt-pr: 49330
1 parent fd47ec9 commit 0734aaa

File tree

1 file changed

+46
-17
lines changed

1 file changed

+46
-17
lines changed

testing/web-platform/tests/css/css-values/attr-security.html

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,26 @@
66

77
<style>
88
@property --some-url {
9+
syntax: "<url>";
10+
inherits: false;
11+
initial-value: "empty";
12+
}
13+
@property --some-string {
914
syntax: "<string>";
1015
inherits: false;
1116
initial-value: "empty";
1217
}
13-
@property --some-url-list {
18+
@property --some-string-list {
1419
syntax: "<string>+";
1520
inherits: false;
1621
initial-value: "empty";
1722
}
1823
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);
2126
--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;
2229
}
2330
</style>
2431

@@ -70,6 +77,7 @@
7077
'https://does-not-exist.test/404.png',
7178
'src(url("https://does-not-exist.test/404.png"))');
7279

80+
// The following string() function is under discussion in the working group and does not exist yet.
7381
test_attr('--x',
7482
'src(string("https://does-not-exist.test" attr(data-foo)))',
7583
'/404.png',
@@ -79,22 +87,27 @@
7987
'/404.png',
8088
'none');
8189
test_attr('background-image',
82-
'src(string("https://does-not-exist.test/""404.png")))',
90+
'src(string("https://does-not-exist.test/""404.png"))',
8391
'/404.png',
8492
'src(url("https://does-not-exist.test/404.png"))');
8593

8694
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');
90102
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)',
93105
'none');
94106
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+
98111

99112
test_attr('--x',
100113
'image(attr(data-foo))',
@@ -123,21 +136,21 @@
123136

124137
// Test via a registered custom property.
125138
test_attr('--x',
126-
'image-set(var(--some-url))',
139+
'image-set(var(--some-string))',
127140
'https://does-not-exist.test/404.png',
128141
'image-set("https://does-not-exist.test/404.png")');
129142
test_attr('background-image',
130-
'image-set(var(--some-url))',
143+
'image-set(var(--some-string))',
131144
'https://does-not-exist.test/404.png',
132145
'none');
133146

134147
// Test via a registered custom property (list).
135148
test_attr('--x',
136-
'image-set(var(--some-url))',
149+
'image-set(var(--some-string-list))',
137150
'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")');
139152
test_attr('background-image',
140-
'image-set(var(--some-url))',
153+
'image-set(var(--some-string-list))',
141154
'https://does-not-exist.test/404.png',
142155
'none');
143156

@@ -150,4 +163,20 @@
150163
'image-set(var(--some-other-url))',
151164
'https://does-not-exist.test/404.png',
152165
'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');
153182
</script>

0 commit comments

Comments
 (0)