From eb39c0162c69688f10a64de9c9425a86ad96471c Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Fri, 12 Sep 2025 14:35:56 +0100 Subject: [PATCH] Tests: Import a selection of CSS Typed-OM property tests This is an arbitrary set of tests intended to cover the different CSSStyleValue types without too much overlap. Right now they all fail, because testsuite.js attempts to create one of every type of CSSStyleValue on load, and we don't have most of them. --- .../the-stylepropertymap/properties/color.txt | 3 + .../properties/cursor.txt | 3 + .../properties/display.txt | 3 + .../the-stylepropertymap/properties/font.txt | 3 + .../properties/padding.txt | 3 + .../properties/transform.txt | 3 + .../the-stylepropertymap/properties/width.txt | 3 + .../properties/color.html | 30 ++ .../properties/cursor.html | 59 +++ .../properties/display.html | 59 +++ .../the-stylepropertymap/properties/font.html | 24 + .../properties/padding.html | 39 ++ .../properties/resources/testsuite.js | 485 ++++++++++++++++++ .../properties/transform.html | 25 + .../properties/width.html | 63 +++ 15 files changed, 805 insertions(+) create mode 100644 Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/color.txt create mode 100644 Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/cursor.txt create mode 100644 Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/display.txt create mode 100644 Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/font.txt create mode 100644 Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/padding.txt create mode 100644 Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/transform.txt create mode 100644 Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/width.txt create mode 100644 Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/the-stylepropertymap/properties/color.html create mode 100644 Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/the-stylepropertymap/properties/cursor.html create mode 100644 Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/the-stylepropertymap/properties/display.html create mode 100644 Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/the-stylepropertymap/properties/font.html create mode 100644 Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/the-stylepropertymap/properties/padding.html create mode 100644 Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/the-stylepropertymap/properties/resources/testsuite.js create mode 100644 Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/the-stylepropertymap/properties/transform.html create mode 100644 Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/the-stylepropertymap/properties/width.html diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/color.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/color.txt new file mode 100644 index 00000000000..6055c864758 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/color.txt @@ -0,0 +1,3 @@ +Harness status: Error + +Found 0 tests diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/cursor.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/cursor.txt new file mode 100644 index 00000000000..6055c864758 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/cursor.txt @@ -0,0 +1,3 @@ +Harness status: Error + +Found 0 tests diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/display.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/display.txt new file mode 100644 index 00000000000..6055c864758 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/display.txt @@ -0,0 +1,3 @@ +Harness status: Error + +Found 0 tests diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/font.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/font.txt new file mode 100644 index 00000000000..6055c864758 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/font.txt @@ -0,0 +1,3 @@ +Harness status: Error + +Found 0 tests diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/padding.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/padding.txt new file mode 100644 index 00000000000..6055c864758 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/padding.txt @@ -0,0 +1,3 @@ +Harness status: Error + +Found 0 tests diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/transform.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/transform.txt new file mode 100644 index 00000000000..6055c864758 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/transform.txt @@ -0,0 +1,3 @@ +Harness status: Error + +Found 0 tests diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/width.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/width.txt new file mode 100644 index 00000000000..6055c864758 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/width.txt @@ -0,0 +1,3 @@ +Harness status: Error + +Found 0 tests diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/the-stylepropertymap/properties/color.html b/Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/the-stylepropertymap/properties/color.html new file mode 100644 index 00000000000..6bd119a61bb --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/the-stylepropertymap/properties/color.html @@ -0,0 +1,30 @@ + + +'color' property + + + + + + + + +
+ diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/the-stylepropertymap/properties/cursor.html b/Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/the-stylepropertymap/properties/cursor.html new file mode 100644 index 00000000000..43e826044c0 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/the-stylepropertymap/properties/cursor.html @@ -0,0 +1,59 @@ + + +'cursor' property + + + + + + + + +
+ diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/the-stylepropertymap/properties/display.html b/Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/the-stylepropertymap/properties/display.html new file mode 100644 index 00000000000..e9a6609c584 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/the-stylepropertymap/properties/display.html @@ -0,0 +1,59 @@ + + +'display' property + + + + + + + + +
+ diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/the-stylepropertymap/properties/font.html b/Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/the-stylepropertymap/properties/font.html new file mode 100644 index 00000000000..26b134e714d --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/the-stylepropertymap/properties/font.html @@ -0,0 +1,24 @@ + + +'font' property + + + + + + + + +
+ diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/the-stylepropertymap/properties/padding.html b/Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/the-stylepropertymap/properties/padding.html new file mode 100644 index 00000000000..3e57231e6e2 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/the-stylepropertymap/properties/padding.html @@ -0,0 +1,39 @@ + + +padding properties + + + + + + + + +
+ diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/the-stylepropertymap/properties/resources/testsuite.js b/Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/the-stylepropertymap/properties/resources/testsuite.js new file mode 100644 index 00000000000..cecd72ad927 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/the-stylepropertymap/properties/resources/testsuite.js @@ -0,0 +1,485 @@ +function assert_is_unit(unit, result) { + assert_class_string(result, 'CSSUnitValue', + 'relative lengths must compute to a CSSUnitValue'); + assert_equals(result.unit, unit, 'unit'); +} + +function assert_is_calc_sum(result) { + assert_class_string(result, 'CSSMathSum', + 'specified calc must be a CSSMathSum'); +} + +function assert_is_equal_with_range_handling(input, result) { + if (input instanceof CSSUnitValue && input.value < 0) + assert_style_value_equals(result, new CSSMathSum(input)); + else + assert_style_value_equals(result, input); +} + +function assert_is_unsupported(result) { + assert_class_string(result, 'CSSStyleValue'); +} + +const gCssWideKeywordsExamples = [ + { + description: 'initial keyword', + input: new CSSKeywordValue('initial') + }, + { + description: 'inherit keyword', + input: new CSSKeywordValue('inherit') + }, + { + description: 'unset keyword', + input: new CSSKeywordValue('unset') + }, + { + description: 'revert keyword', + input: new CSSKeywordValue('revert') + }, +]; + +const gVarReferenceExamples = [ + { + description: 'a var() reference', + input: new CSSUnparsedValue([' ', new CSSVariableReferenceValue('--A')]) + }, +]; + +const gTestSyntaxExamples = { + '': { + description: 'a length', + examples: [ + { + description: "zero px", + input: new CSSUnitValue(0, 'px') + }, + { + description: "a negative em", + input: new CSSUnitValue(-3.14, 'em'), + // 'ems' are relative units, so just check that it computes to px + defaultComputed: (_, result) => assert_is_unit('px', result) + }, + { + description: "a positive cm", + input: new CSSUnitValue(3.14, 'cm'), + // 'cms' are relative units, so just check that it computes to px + defaultComputed: (_, result) => assert_is_unit('px', result) + }, + { + description: "a calc length", + input: new CSSMathSum(new CSSUnitValue(0, 'px'), new CSSUnitValue(0, 'em')), + // Specified/computed calcs are usually simplified. + // FIXME: Test this properly + defaultSpecified: (_, result) => assert_is_calc_sum(result), + defaultComputed: (_, result) => assert_is_unit('px', result) + } + ], + }, + '': { + description: 'a percent', + examples: [ + { + description: "zero percent", + input: new CSSUnitValue(0, 'percent') + }, + { + description: "a negative percent", + input: new CSSUnitValue(-3.14, 'percent') + }, + { + description: "a positive percent", + input: new CSSUnitValue(3.14, 'percent') + }, + { + description: "a calc percent", + input: new CSSMathSum(new CSSUnitValue(0, 'percent'), new CSSUnitValue(0, 'percent')), + // Specified/computed calcs are usually simplified. + // FIXME: Test this properly + defaultSpecified: (_, result) => assert_is_calc_sum(result), + defaultComputed: (_, result) => assert_is_unit('percent', result) + } + ], + }, + '