Skip to content

Commit 1cad4e8

Browse files
andruudchromium-wpt-export-bot
authored andcommitted
[css-properties-values-api] Test unit arithmetic separately
A subtest relying on unit arithmetic snuck into one of the WPTs covered by the "Custom Properties" focus area of Interop 2024. As unit arithmetic is not covered by Interop 2024, the default resolution to this problem is to remove the whole file from Interop [1]. However, in this case, it's relatively easy and harmless to move the offending test to a separate file. [1] web-platform-tests/interop#604 Change-Id: Ic444d07288c2c8bb54595c61813d0217b3cc1032 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6097816 Reviewed-by: Daniil Sakhapov <[email protected]> Commit-Queue: Anders Hartvoll Ruud <[email protected]> Cr-Commit-Position: refs/heads/main@{#1397239}
1 parent b9ff3b3 commit 1cad4e8

File tree

3 files changed

+29
-17
lines changed

3 files changed

+29
-17
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE HTML>
2+
<title>CSS Properties and Values API: Unit arithmetic in initial value</title>
3+
<link rel="help" href="https://drafts.css-houdini.org/css-properties-values-api/#dom-css-registerproperty" />
4+
<link rel="help" href="https://drafts.css-houdini.org/css-properties-values-api/#supported-syntax-strings" />
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
<script src="./resources/utils.js"></script>
8+
<script>
9+
test_initial_value_valid("<length>", "calc(5px * 3px / 6px)");
10+
</script>

css/css-properties-values-api/register-property-syntax-parsing.html

+3-17
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,11 @@
44
<link rel="help" href="https://drafts.css-houdini.org/css-properties-values-api/#supported-syntax-strings" />
55
<script src="/resources/testharness.js"></script>
66
<script src="/resources/testharnessreport.js"></script>
7+
<script src="./resources/utils.js"></script>
78
<script>
8-
test_count = 0;
99

10-
function assert_valid(syntax, initialValue) {
11-
// No actual assertions, this just shouldn't throw
12-
test(function() {
13-
var name = '--syntax-test-' + (test_count++);
14-
CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false});
15-
}, "syntax:'" + syntax + "', initialValue:'" + initialValue + "' is valid");
16-
}
17-
18-
function assert_invalid(syntax, initialValue) {
19-
test(function(){
20-
var name = '--syntax-test-' + (test_count++);
21-
assert_throws_dom("SyntaxError",
22-
() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false}));
23-
}, "syntax:'" + syntax + "', initialValue:'" + initialValue + "' is invalid");
24-
}
10+
let assert_valid = test_initial_value_valid;
11+
let assert_invalid = test_initial_value_invalid;
2512

2613
assert_valid("*", "a");
2714
assert_valid(" * ", "b");
@@ -47,7 +34,6 @@
4734
assert_valid("<length>", "10px /*:)*/");
4835
assert_valid("<length>", " calc(-2px)");
4936
assert_valid("<length>", "calc(2px*4 + 10px)");
50-
assert_valid("<length>", "calc(5px * 3px / 6px)");
5137
assert_valid("<length>", "7.1e-4cm");
5238
assert_valid("<length>", "calc(7in - 12px)");
5339
assert_valid("<length>", "calc(15px + (sign(100vh - 10px) * 5px))");

css/css-properties-values-api/resources/utils.js

+16
Original file line numberDiff line numberDiff line change
@@ -243,3 +243,19 @@ function no_transition_test(options, description) {
243243
assert_equals(getComputedStyle(target).getPropertyValue(customProperty), options.to, "Element has the expected final value");
244244
}, description);
245245
};
246+
247+
function test_initial_value_valid(syntax, initialValue) {
248+
// No actual assertions, this just shouldn't throw
249+
test(() => {
250+
var name = generate_name();
251+
CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false});
252+
}, "syntax:'" + syntax + "', initialValue:'" + initialValue + "' is valid");
253+
}
254+
255+
function test_initial_value_invalid(syntax, initialValue) {
256+
test(() =>{
257+
var name = generate_name();
258+
assert_throws_dom("SyntaxError",
259+
() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false}));
260+
}, "syntax:'" + syntax + "', initialValue:'" + initialValue + "' is invalid");
261+
}

0 commit comments

Comments
 (0)