Skip to content

Commit 5e9fedd

Browse files
tursunovachromium-wpt-export-bot
authored andcommitted
Check if url functions are supported in attr() security tests
Blink, as well as Gecko and Webkit do not support src() function [0] and image() function [1]. Hypothetical string() function is not supported as well. This causes some of the attr() security tests to incorrectly fail. If function is not supported this should not be a violation to the security, so we can just skip these tests. This Cl also restructures test a bit, use consts instead of long urls. [0] https://drafts.csswg.org/css-values-4/#urls [1] https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/image/image Fixed: 489670248 Change-Id: I7fe76e02135d983c4f2f801d63a28eee7cb992d2
1 parent 4267ed5 commit 5e9fedd

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

css/css-values/attr-security.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,17 @@
3737
function test_attr(property, attrString, attrValue, expectedValue) {
3838
var elem = document.getElementById("attr");
3939
elem.setAttribute("data-foo", attrValue);
40-
elem.style.setProperty(property, attrString);
40+
41+
elem.style.setProperty("--unregistered", attrString);
42+
let value = window.getComputedStyle(elem).getPropertyValue("--unregistered");
4143

4244
test(() => {
45+
// Skip tests that include unsupported functions, since they are not violation of attr() security.
46+
if (value == "" || CSS.supports(`${property} : ${value}`)) {
47+
elem.style.setProperty(property, attrString);
4348
assert_equals(window.getComputedStyle(elem).getPropertyValue(property),
4449
expectedValue);
50+
}
4551
}, `'${property}: ${attrString}' with data-foo="${attrValue}"`);
4652

4753
elem.style.setProperty(property, null);

0 commit comments

Comments
 (0)