Bug 1439768 [wpt PR 9592] - [css-typed-om] Add CSS-wide keyword tests., a=testonly
authorDarren Shen <shend@chromium.org>
Mon, 26 Mar 2018 12:37:20 +0000
changeset 775610 f973b34a6b70e9dc0e472cf7206265dff243ae5e
parent 775609 fb42cfd44ef818b2b761cd4940f90167fdd236b7
child 775611 beb47b5c820c54ea5e366f077ea864be28b304a0
push id104740
push userbmo:ntim.bugs@gmail.com
push dateSun, 01 Apr 2018 11:54:49 +0000
reviewerstestonly
bugs1439768, 774887, 925201, 537969
milestone61.0a1
Bug 1439768 [wpt PR 9592] - [css-typed-om] Add CSS-wide keyword tests., a=testonly Automatic update from web-platform-tests[css-typed-om] Add CSS-wide keyword tests. This patch adds per-property tests for CSS-wide keywords like 'initial'. Every property should support these. Bug: 774887 Change-Id: Ie1d71e30c18ebff50ea166d27e92606782af43fa Reviewed-on: https://chromium-review.googlesource.com/925201 Commit-Queue: Darren Shen <shend@chromium.org> Reviewed-by: nainar <nainar@chromium.org> Cr-Commit-Position: refs/heads/master@{#537969} wpt-commits: 9262595b48e9a859509a2b30fa1e5c03cbb15597 wpt-pr: 9592 wpt-commits: 9262595b48e9a859509a2b30fa1e5c03cbb15597 wpt-pr: 9592
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/css/css-typed-om/the-stylepropertymap/properties/resources/testsuite.js
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -519539,17 +519539,17 @@
    "70c2e29badef7528469bcf11e1cb7bbc6cd519ea",
    "testharness"
   ],
   "css/css-typed-om/the-stylepropertymap/properties/position.html": [
    "4e3eccee58cec470febe4cd9a9149f4b4436487e",
    "testharness"
   ],
   "css/css-typed-om/the-stylepropertymap/properties/resources/testsuite.js": [
-   "3ac46f9655cf07f63761850d38eb0c0cebdd98bf",
+   "8f23e63849f184553cdc43d2c45aec316300db0a",
    "support"
   ],
   "css/css-typed-om/the-stylepropertymap/properties/right.html": [
    "68a2611eaf9eecb7393c2b0db0f4378ebe285f22",
    "testharness"
   ],
   "css/css-typed-om/the-stylepropertymap/properties/text-align.html": [
    "88a1f5866a767c25dec2ef75728c68c5631d371f",
--- a/testing/web-platform/tests/css/css-typed-om/the-stylepropertymap/properties/resources/testsuite.js
+++ b/testing/web-platform/tests/css/css-typed-om/the-stylepropertymap/properties/resources/testsuite.js
@@ -11,16 +11,31 @@ function assert_is_calc_sum(result) {
 
 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);
 }
 
+const gCssWideKeywordsExamples = [
+  {
+    description: 'initial keyword',
+    input: new CSSKeywordValue('initial')
+  },
+  {
+    description: 'inherit keyword',
+    input: new CSSKeywordValue('initial')
+  },
+  {
+    description: 'unset keyword',
+    input: new CSSKeywordValue('initial')
+  },
+];
+
 const gTestSyntaxExamples = {
   '<length>': {
     description: 'a length',
     examples: [
       {
         description: "zero px",
         input: new CSSUnitValue(0, 'px')
       },
@@ -144,36 +159,38 @@ function testPropertyValid(propertyName,
   test(t => {
     let element = createDivWithStyle(t);
 
     for (const example of examples) {
       element.attributeStyleMap.set(propertyName, example.input);
 
       // specified style
       const specifiedResult = element.attributeStyleMap.get(propertyName);
+      assert_not_equals(specifiedResult, null,
+        'Specified value must not be null');
+      assert_true(specifiedResult instanceof CSSStyleValue,
+        'Specified value must be a CSSStyleValue');
+
       if (specified || example.defaultSpecified) {
         (specified || example.defaultSpecified)(example.input, specifiedResult);
       } else {
-        assert_not_equals(specifiedResult, null,
-          'Specified value must not be null');
-        assert_true(specifiedResult instanceof CSSStyleValue,
-          'Specified value must be a CSSStyleValue');
         assert_style_value_equals(specifiedResult, example.input,
           `Setting ${example.description} and getting its specified value`);
       }
 
       // computed style
       const computedResult = element.computedStyleMap().get(propertyName);
+      assert_not_equals(computedResult, null,
+        'Computed value must not be null');
+      assert_true(computedResult instanceof CSSStyleValue,
+        'Computed value must be a CSSStyleValue');
+
       if (computed || example.defaultComputed) {
         (computed || example.defaultComputed)(example.input, computedResult);
       } else {
-        assert_not_equals(computedResult, null,
-          'Computed value must not be null');
-        assert_true(computedResult instanceof CSSStyleValue,
-          'Computed value must be a CSSStyleValue');
         assert_style_value_equals(computedResult, example.input,
           `Setting ${example.description} and getting its computed value`);
       }
     }
   }, `Can set '${propertyName}' to ${description}`);
 }
 
 // Test that styleMap.set throws for invalid values
@@ -215,16 +232,23 @@ function createKeywordExample(keyword) {
 //
 // FIXME: The reason we pass argument #2 is that it's sometimes difficult to
 // compute exactly what the expected result should be (e.g. browser-specific
 // values). Once we can do that, we can remove argument #2 and just return
 // the expected result.
 function runPropertyTests(propertyName, testCases) {
   let syntaxTested = new Set();
 
+  // Every property should at least support CSS-wide keywords.
+  testPropertyValid(propertyName,
+    gCssWideKeywordsExamples,
+    null, // should be as specified
+    () => {}, // could be anything
+    'CSS-wide keywords');
+
   for (const testCase of testCases) {
     // Retrieve test examples for this test case's syntax. If the syntax
     // looks like a keyword, then create an example on the fly.
     const syntaxExamples = testCase.syntax.match(/^[a-z\-]+$/) ?
       createKeywordExample(testCase.syntax) :
       gTestSyntaxExamples[testCase.syntax];
 
     if (!syntaxExamples)