Skip to content

Commit

Permalink
[css-properties-values-api] Test unit arithmetic separately
Browse files Browse the repository at this point in the history
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}
  • Loading branch information
andruud authored and chromium-wpt-export-bot committed Dec 17, 2024
1 parent b9ff3b3 commit 09eacd6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
10 changes: 10 additions & 0 deletions css/css-properties-values-api/initial-value-unit-arithmetic.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE HTML>
<title>CSS Properties and Values API: Unit arithmetic in initial value</title>
<link rel="help" href="https://drafts.css-houdini.org/css-properties-values-api/#dom-css-registerproperty" />
<link rel="help" href="https://drafts.css-houdini.org/css-properties-values-api/#supported-syntax-strings" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="./resources/utils.js"></script>
<script>
test_initial_value_valid("<length>", "calc(5px * 3px / 6px)");
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,11 @@
<link rel="help" href="https://drafts.css-houdini.org/css-properties-values-api/#supported-syntax-strings" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="./resources/utils.js"></script>
<script>
test_count = 0;

function assert_valid(syntax, initialValue) {
// No actual assertions, this just shouldn't throw
test(function() {
var name = '--syntax-test-' + (test_count++);
CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false});
}, "syntax:'" + syntax + "', initialValue:'" + initialValue + "' is valid");
}

function assert_invalid(syntax, initialValue) {
test(function(){
var name = '--syntax-test-' + (test_count++);
assert_throws_dom("SyntaxError",
() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false}));
}, "syntax:'" + syntax + "', initialValue:'" + initialValue + "' is invalid");
}
let assert_valid = test_initial_value_valid;
let assert_invalid = test_initial_value_invalid;

assert_valid("*", "a");
assert_valid(" * ", "b");
Expand All @@ -47,7 +34,6 @@
assert_valid("<length>", "10px /*:)*/");
assert_valid("<length>", " calc(-2px)");
assert_valid("<length>", "calc(2px*4 + 10px)");
assert_valid("<length>", "calc(5px * 3px / 6px)");
assert_valid("<length>", "7.1e-4cm");
assert_valid("<length>", "calc(7in - 12px)");
assert_valid("<length>", "calc(15px + (sign(100vh - 10px) * 5px))");
Expand Down
16 changes: 16 additions & 0 deletions css/css-properties-values-api/resources/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,19 @@ function no_transition_test(options, description) {
assert_equals(getComputedStyle(target).getPropertyValue(customProperty), options.to, "Element has the expected final value");
}, description);
};

function test_initial_value_valid(syntax, initialValue) {
// No actual assertions, this just shouldn't throw
test(() => {
var name = generate_name();
CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false});
}, "syntax:'" + syntax + "', initialValue:'" + initialValue + "' is valid");
}

function test_initial_value_invalid(syntax, initialValue) {
test(() =>{
var name = generate_name();
assert_throws_dom("SyntaxError",
() => CSS.registerProperty({name: name, syntax: syntax, initialValue: initialValue, inherits: false}));
}, "syntax:'" + syntax + "', initialValue:'" + initialValue + "' is invalid");
}

0 comments on commit 09eacd6

Please sign in to comment.