Bug 1482942 [wpt PR 12431] - [css-properties-values-api] Reify values from attributeStyleMap.get., a=testonly
authorAnders Hartvoll Ruud <andruud@chromium.org>
Wed, 15 Aug 2018 09:59:40 +0000
changeset 431752 08733b64cf88583cdaf0f3400e140c91392cf45e
parent 431751 c4cf7efdfc50a14e99c37e5ec856b9e4a06baf69
child 431753 51fb2af4cf81b859dd2466ecaa7a2de507e1b37f
push id34451
push userebalazs@mozilla.com
push dateThu, 16 Aug 2018 09:25:15 +0000
treeherdermozilla-central@161817e6d127 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1482942, 12431, 641877, 1172291, 582569
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1482942 [wpt PR 12431] - [css-properties-values-api] Reify values from attributeStyleMap.get., a=testonly Automatic update from web-platform-tests[css-properties-values-api] Reify values from attributeStyleMap.get. When retrieving values via attributeStyleMap.get/getAll, produce the correct CSSStyleValue subclass according to the registration of the custom property. R=futhark@chromium.org Bug: 641877 Change-Id: If564fb039506a22162ad2521479fcb1c3de9336c Reviewed-on: https://chromium-review.googlesource.com/1172291 Reviewed-by: Rune Lillesveen <futhark@chromium.org> Commit-Queue: Anders Ruud <andruud@chromium.org> Cr-Commit-Position: refs/heads/master@{#582569} -- wpt-commits: 816706b1fa03ffbc7b1f98a560f8ac7db80bc481 wpt-pr: 12431
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/css/css-properties-values-api/typedom.tentative.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -539089,17 +539089,17 @@
    "169ed7b53c16a145df8598e0888e1271d288d5c7",
    "support"
   ],
   "css/css-properties-values-api/support/main/main.utf16be.css": [
    "26485da32b751b8c66191f3e64814051bd91c284",
    "support"
   ],
   "css/css-properties-values-api/typedom.tentative.html": [
-   "9fff08004cbea052754a18ddccc5c889b1f29cf4",
+   "065280614cca9fa52b79c28e253c30ada188a1b9",
    "testharness"
   ],
   "css/css-properties-values-api/unit-cycles.html": [
    "c242640f2b93e7820b9d016b53f5f2279ec18eca",
    "testharness"
   ],
   "css/css-properties-values-api/url-resolution.html": [
    "6e7c008a58c311aeb18e89edd4dd29e8a3e6c1ed",
--- 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
@@ -8,26 +8,32 @@
 
 <div id=target></div>
 
 <script>
 
 // Properties are generated on demand, as `--prop-${g_counter}`.
 let g_counter = 1;
 
+// Generate a new property name.
+function gen_name() {
+    let name = `--prop-${g_counter}`;
+    g_counter++;
+    return name;
+}
+
 // Generate a property and return its name.
 function gen_prop(syntax, initialValue) {
-    let name = `--prop-${g_counter}`;
+    let name = gen_name();
     CSS.registerProperty({
         name: name,
         syntax: syntax,
         initialValue: initialValue,
         inherits: false
     });
-    g_counter++;
     return name;
 }
 
 // On the target element, verify that computed value of 'name' is an instance
 // of 'expected' and not an instance of CSSUnparsedValue.
 //
 // If 'value' is non-null, that value is first set on the attributeStyleMap
 // of the target.
@@ -45,16 +51,38 @@ function assert_computed_type(name, valu
     assert_false(computedValue instanceof CSSUnparsedValue);
     assert_true(computedValue instanceof expected);
 
     if (value != null) {
         target.attributeStyleMap.delete(name);
     }
 }
 
+function assert_attribute_get_type(syntax, value, expected) {
+    let name = gen_name();
+    target.style = `${name}: ${value}`;
+
+    assert_true(target.attributeStyleMap.get(name) instanceof CSSUnparsedValue);
+
+    CSS.registerProperty({
+        name: name,
+        syntax: syntax,
+        initialValue: value,
+        inherits: false
+    });
+
+    if (expected == CSSStyleValue) {
+        assert_false(target.attributeStyleMap.get(name) instanceof CSSUnparsedValue);
+    }
+
+    assert_true(target.attributeStyleMap.get(name) instanceof expected);
+}
+
+// computedStyleMap
+
 test(function(){
     let name = gen_prop('*', 'if(){}');
     assert_true(target.computedStyleMap().get(name) instanceof CSSUnparsedValue);
 
     target.attributeStyleMap.set(name, 'as{}df');
     assert_true(target.computedStyleMap().get(name) instanceof CSSUnparsedValue);
     target.attributeStyleMap.delete(name);
 }, 'Computed * is reified as CSSUnparsedValue');
@@ -159,9 +187,115 @@ test(function(){
     assert_equals(target.computedStyleMap().getAll(name).length, 2);
     assert_true(target.computedStyleMap().getAll(name).every(x => x instanceof CSSUnitValue));
 
     target.attributeStyleMap.set(name, '10px, 20px, 30px');
     assert_equals(target.computedStyleMap().getAll(name).length, 3);
     assert_true(target.computedStyleMap().getAll(name).every(x => x instanceof CSSUnitValue));
 }, 'All computed values correctly reified in comma-separated list');
 
+// attributeStyleMap.get
+
+test(function(){
+    let name1 = gen_prop('<length>', '100px');
+    let name2 = gen_prop('<length>', '0px');
+    target.style = `${name2}: var(${name1})`;
+    assert_true(target.attributeStyleMap.get(name2) instanceof CSSUnparsedValue);
+}, 'attributeStyleMap.get returns CSSUnparsedValue for value with var references');
+
+test(function(){
+    let name1 = gen_prop('<length>', '100px');
+    let name2 = gen_prop('<length>#', '0px');
+    target.style = `${name2}: 1px, var(${name1}), 3px`;
+    assert_true(target.attributeStyleMap.get(name2) instanceof CSSUnparsedValue);
+}, 'attributeStyleMap.get returns CSSUnparsedValue for value with var reference in list');
+
+test(function(){
+    assert_attribute_get_type('*', 'if(){}', CSSUnparsedValue);
+}, 'attributeStyleMap.get returns CSSUnparsedValue for *');
+
+test(function(){
+    assert_attribute_get_type('<angle>', '42deg', CSSUnitValue);
+}, 'attributeStyleMap.get returns CSSUnitValue for <angle>');
+
+test(function(){
+    assert_attribute_get_type('<color>', '#fefefe', CSSStyleValue);
+}, 'attributeStyleMap.get returns CSSStyleValue for <color>');
+
+test(function(){
+    assert_attribute_get_type('<custom-ident>', 'none', CSSKeywordValue);
+}, 'attributeStyleMap.get returns CSSKeywordValue for <custom-ident>');
+
+test(function(){
+    assert_attribute_get_type('<image>', 'url(thing.png)', CSSImageValue);
+}, 'attributeStyleMap.get returns CSSImageValue for <image>');
+
+test(function(){
+    assert_attribute_get_type('<integer>', '100', CSSUnitValue);
+}, 'attributeStyleMap.get returns CSSUnitValue for <integer>');
+
+test(function(){
+    assert_attribute_get_type('<length-percentage>', '10%', CSSUnitValue);
+}, 'attributeStyleMap.get returns CSSUnitValue for <length-percentage> [10%]');
+
+test(function(){
+    assert_attribute_get_type('<length-percentage>', '10px', CSSUnitValue);
+}, 'attributeStyleMap.get returns CSSUnitValue for <length-percentage> [10px]');
+
+test(function(){
+    assert_attribute_get_type('<length-percentage>', 'calc(10px + 10%)', CSSMathSum);
+}, 'attributeStyleMap.get returns CSSMathSum for <length-percentage> [calc(10px + 10%)]');
+
+test(function(){
+    assert_attribute_get_type('<length>', '10px', CSSUnitValue);
+}, 'attributeStyleMap.get returns CSSUnitValue for <length>');
+
+test(function(){
+    assert_attribute_get_type('<number>', '42', CSSUnitValue);
+}, 'attributeStyleMap.get returns CSSUnitValue for <number>');
+
+test(function(){
+    assert_attribute_get_type('<percentage>', '10%', CSSUnitValue);
+}, 'attributeStyleMap.get returns CSSUnitValue for <percentage>');
+
+test(function(){
+    assert_attribute_get_type('<resolution>', '300dpi', CSSUnitValue);
+}, 'attributeStyleMap.get returns CSSUnitValue for <resolution>');
+
+test(function(){
+    assert_attribute_get_type('<time>', '42s', CSSUnitValue);
+}, 'attributeStyleMap.get returns CSSUnitValue for <time>');
+
+test(function(){
+    assert_attribute_get_type('<url>', 'url(a)', CSSStyleValue);
+}, 'attributeStyleMap.get returns CSSStyleValue for <url>');
+
+test(function(){
+    assert_attribute_get_type('thing1 | THING2', 'thing1', CSSKeywordValue);
+}, 'attributeStyleMap.get returns CSSKeywordValue for thing1 | THING2');
+
+test(function(){
+    assert_attribute_get_type('<length>+', '10px 20px', CSSUnitValue);
+}, 'attributeStyleMap.get returns CSSUnitValue for <length>+');
+
+test(function(){
+    assert_attribute_get_type('<length>#', '10px 20px', CSSUnitValue);
+}, 'attributeStyleMap.get returns CSSUnitValue for <length>#');
+
+// attributeStyleMap.getAll
+
+test(function(){
+    let name = gen_prop('<length>+', '0px');
+    target.attributeStyleMap.clear();
+    target.attributeStyleMap.set(name, '10px 20px 30px');
+    assert_equals(target.attributeStyleMap.getAll(name).length, 3);
+    assert_true(target.attributeStyleMap.getAll(name).every(x => x instanceof CSSUnitValue));
+}, 'attributeStyleMap.getAll returns a list of CSSUnitValues for <length>+');
+
+test(function(){
+    let name = gen_prop('<length>#', '0px');
+    target.attributeStyleMap.clear();
+    target.attributeStyleMap.set(name, '10px, 20px, 30px');
+    assert_equals(target.attributeStyleMap.getAll(name).length, 3);
+    assert_true(target.attributeStyleMap.getAll(name).every(x => x instanceof CSSUnitValue));
+}, 'attributeStyleMap.getAll returns a list of CSSUnitValues for <length>#');
+
 </script>