From 86a9631e9afba880045cfc90b1159303bb7a8461 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Thu, 3 Oct 2019 09:26:52 +0000 Subject: [PATCH] Bug 1487655 [wpt PR 12775] - [css-properties-values-api] Typify CSSStyleValue.parse/All., a=testonly Automatic update from web-platform-tests[css-properties-values-api] Typify CSSStyleValue.parse/All. Passing the PropertyRegistration makes StyleValueFactory::FromString find the typed value, and create appropriate and corresponding TypedOM types. Note: the check on property_id==CSSPropertyVariable isn't strictly required, but it's nice to avoid the AtomicString creation if we know it's not needed. R=futharkchromium.org Bug: 641877 Change-Id: Id7f7f8c754f8aab7f64a92efd896243858d03757 Reviewed-on: https://chromium-review.googlesource.com/1199182 Reviewed-by: Rune Lillesveen Commit-Queue: Anders Ruud Cr-Commit-Position: refs/heads/master{#588001} -- wpt-commits: 6955f7b1c81ebf402628229efb9a1b20af2f6370 wpt-pr: 12775 UltraBlame original commit: 401a8ac9850698b8858d952bc774e8430c1cc79a --- testing/web-platform/meta/MANIFEST.json | 2 +- .../typedom.tentative.html | 90 +++++++++++++++++++ 2 files changed, 91 insertions(+), 1 deletion(-) diff --git a/testing/web-platform/meta/MANIFEST.json b/testing/web-platform/meta/MANIFEST.json index b18c23078b4bb..e25096267d517 100644 --- a/testing/web-platform/meta/MANIFEST.json +++ b/testing/web-platform/meta/MANIFEST.json @@ -546987,7 +546987,7 @@ "support" ], "css/css-properties-values-api/typedom.tentative.html": [ - "9f102607de3f750eb42fd6377c36376fe89d07d6", + "eb2d8549ba61c8e3f5929d9f11e84a6c6ef80079", "testharness" ], "css/css-properties-values-api/unit-cycles.html": [ diff --git a/testing/web-platform/tests/css/css-properties-values-api/typedom.tentative.html b/testing/web-platform/tests/css/css-properties-values-api/typedom.tentative.html index 943e997532494..b960e8b8aec6d 100644 --- a/testing/web-platform/tests/css/css-properties-values-api/typedom.tentative.html +++ b/testing/web-platform/tests/css/css-properties-values-api/typedom.tentative.html @@ -435,4 +435,94 @@ shouldReject: [unparsed('42deg'), unparsed('20px'), CSS.s(1), '#fef'], }); +// CSSStyleValue.parse/parseAll + +function assert_parsed_type(prop, value, expected) { + let parse_value = CSSStyleValue.parse(prop, value); + let parse_all_value = CSSStyleValue.parseAll(prop, value); + + assert_true(parse_value instanceof expected); + assert_true(parse_all_value.every(x => x instanceof expected)) + + // If CSSStyleValue is expected, the values must be exactly CSSStyleValue. + // This is because CSSUnparsedValues are also CSSStyleValues, which would be + // wrong in this case. + if (expected == CSSStyleValue) { + assert_equals(parse_value.constructor, CSSStyleValue); + assert_true(parse_all_value.every(x => x.constructor == CSSStyleValue)); + } +} + +test(function(){ + assert_parsed_type(gen_prop('*', 'if(){}'), 'while(){}', CSSUnparsedValue); +}, 'CSSStyleValue.parse[All] returns CSSUnparsedValue for *'); + +test(function(){ + assert_parsed_type(gen_prop(' | fail', 'fail'), '42deg', CSSUnitValue); +}, 'CSSStyleValue.parse[All] returns CSSUnitValue for '); + +test(function(){ + assert_parsed_type(gen_prop(' | fail', 'fail'), '#fefefe', CSSStyleValue); +}, 'CSSStyleValue.parse[All] returns CSSStyleValue for '); + +test(function(){ + assert_parsed_type(gen_prop(' | ', '10px'), 'none', CSSKeywordValue); +}, 'CSSStyleValue.parse[All] returns CSSKeywordValue for '); + +test(function(){ + assert_parsed_type(gen_prop(' | fail', 'fail'), 'url(thing.png)', CSSImageValue); +}, 'CSSStyleValue.parse[All] returns CSSImageValue for [url]'); + +test(function(){ + assert_parsed_type(gen_prop(' | fail', 'fail'), '100', CSSUnitValue); +}, 'CSSStyleValue.parse[All] returns CSSUnitValue for '); + +test(function(){ + assert_parsed_type(gen_prop(' | fail', 'fail'), '10%', CSSUnitValue); +}, 'CSSStyleValue.parse[All] returns CSSUnitValue for [%]'); + +test(function(){ + assert_parsed_type(gen_prop(' | fail', 'fail'), '10px', CSSUnitValue); +}, 'CSSStyleValue.parse[All] returns CSSUnitValue for [px]'); + +test(function(){ + assert_parsed_type(gen_prop(' | fail', 'fail'), 'calc(10px + 10%)', CSSMathSum); +}, 'CSSStyleValue.parse[All] returns CSSMathSum for [px + %]'); + +test(function(){ + assert_parsed_type(gen_prop(' | fail', 'fail'), '10px', CSSUnitValue); +}, 'CSSStyleValue.parse[All] returns CSSUnitValue for '); + +test(function(){ + assert_parsed_type(gen_prop(' | fail', 'fail'), '42', CSSUnitValue); +}, 'CSSStyleValue.parse[All] returns CSSUnitValue for '); + +test(function(){ + assert_parsed_type(gen_prop(' | fail', 'fail'), '10%', CSSUnitValue); +}, 'CSSStyleValue.parse[All] returns CSSUnitValue for '); + +test(function(){ + assert_parsed_type(gen_prop(' | fail', 'fail'), '300dpi', CSSUnitValue); +}, 'CSSStyleValue.parse[All] returns CSSUnitValue for '); + +test(function(){ + assert_parsed_type(gen_prop('