Skip to content

Commit

Permalink
Bug 1937815 [wpt PR 49730] - [css-properties-values-api] Test unit ar…
Browse files Browse the repository at this point in the history
…ithmetic separately, a=testonly

Automatic update from web-platform-tests
[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}

--

wpt-commits: 09eacd6963a7623ac88d83573a7d5a6afe58f129
wpt-pr: 49730
  • Loading branch information
andruud authored and moz-wptsync-bot committed Dec 20, 2024
1 parent 27385bc commit 068f210
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
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
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 068f210

Please sign in to comment.