Skip to content

Commit

Permalink
Bug 1487655 [wpt PR 12775] - [css-properties-values-api] Typify CSSSt…
Browse files Browse the repository at this point in the history
…yleValue.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 <futharkchromium.org>
Commit-Queue: Anders Ruud <andruudchromium.org>
Cr-Commit-Position: refs/heads/master{#588001}

--

wpt-commits: 6955f7b1c81ebf402628229efb9a1b20af2f6370
wpt-pr: 12775

UltraBlame original commit: 401a8ac9850698b8858d952bc774e8430c1cc79a
  • Loading branch information
marco-c committed Oct 3, 2019
1 parent 6e550ee commit 86a9631
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 1 deletion.
2 changes: 1 addition & 1 deletion testing/web-platform/meta/MANIFEST.json
Original file line number Diff line number Diff line change
Expand Up @@ -546987,7 +546987,7 @@
"support"
],
"css/css-properties-values-api/typedom.tentative.html": [
"9f102607de3f750eb42fd6377c36376fe89d07d6",
"eb2d8549ba61c8e3f5929d9f11e84a6c6ef80079",
"testharness"
],
"css/css-properties-values-api/unit-cycles.html": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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('<angle> | fail', 'fail'), '42deg', CSSUnitValue);
}, 'CSSStyleValue.parse[All] returns CSSUnitValue for <angle>');

test(function(){
assert_parsed_type(gen_prop('<color> | fail', 'fail'), '#fefefe', CSSStyleValue);
}, 'CSSStyleValue.parse[All] returns CSSStyleValue for <color>');

test(function(){
assert_parsed_type(gen_prop('<custom-ident> | <length>', '10px'), 'none', CSSKeywordValue);
}, 'CSSStyleValue.parse[All] returns CSSKeywordValue for <custom-ident>');

test(function(){
assert_parsed_type(gen_prop('<image> | fail', 'fail'), 'url(thing.png)', CSSImageValue);
}, 'CSSStyleValue.parse[All] returns CSSImageValue for <image> [url]');

test(function(){
assert_parsed_type(gen_prop('<integer> | fail', 'fail'), '100', CSSUnitValue);
}, 'CSSStyleValue.parse[All] returns CSSUnitValue for <integer>');

test(function(){
assert_parsed_type(gen_prop('<length-percentage> | fail', 'fail'), '10%', CSSUnitValue);
}, 'CSSStyleValue.parse[All] returns CSSUnitValue for <length-percentage> [%]');

test(function(){
assert_parsed_type(gen_prop('<length-percentage> | fail', 'fail'), '10px', CSSUnitValue);
}, 'CSSStyleValue.parse[All] returns CSSUnitValue for <length-percentage> [px]');

test(function(){
assert_parsed_type(gen_prop('<length-percentage> | fail', 'fail'), 'calc(10px + 10%)', CSSMathSum);
}, 'CSSStyleValue.parse[All] returns CSSMathSum for <length-percentage> [px + %]');

test(function(){
assert_parsed_type(gen_prop('<length> | fail', 'fail'), '10px', CSSUnitValue);
}, 'CSSStyleValue.parse[All] returns CSSUnitValue for <length>');

test(function(){
assert_parsed_type(gen_prop('<number> | fail', 'fail'), '42', CSSUnitValue);
}, 'CSSStyleValue.parse[All] returns CSSUnitValue for <number>');

test(function(){
assert_parsed_type(gen_prop('<percentage> | fail', 'fail'), '10%', CSSUnitValue);
}, 'CSSStyleValue.parse[All] returns CSSUnitValue for <percentage>');

test(function(){
assert_parsed_type(gen_prop('<resolution> | fail', 'fail'), '300dpi', CSSUnitValue);
}, 'CSSStyleValue.parse[All] returns CSSUnitValue for <resolution>');

test(function(){
assert_parsed_type(gen_prop('<time> | fail', 'fail'), '42s', CSSUnitValue);
}, 'CSSStyleValue.parse[All] returns CSSUnitValue for <time>');

test(function(){
assert_parsed_type(gen_prop('<url> | fail', 'fail'), 'url(a)', CSSStyleValue);
}, 'CSSStyleValue.parse[All] returns CSSStyleValue for <url>');

test(function(){
assert_parsed_type(gen_prop('thing1 | THING2 | <url>', 'url(fail)'), 'THING2', CSSKeywordValue);
}, 'CSSStyleValue.parse[All] returns CSSKeywordValue for ident');

test(function(){
assert_parsed_type(gen_prop('<length>+ | fail', 'fail'), '10px 20px', CSSUnitValue);
}, 'CSSStyleValue.parse[All] returns list of CSSUnitValues for <length>+');

test(function(){
assert_parsed_type(gen_prop('<length># | fail', 'fail'), '10px, 20px', CSSUnitValue);
}, 'CSSStyleValue.parse[All] returns list of CSSUnitValues for <length>#');

</script>

0 comments on commit 86a9631

Please sign in to comment.