Bug 1446261 [wpt PR 10066] - [css-typed-om] Clean up CSSUnitValue tests., a=testonly
authorDarren Shen <shend@chromium.org>
Mon, 09 Apr 2018 17:16:17 +0000
changeset 413572 56277a5c9dfd4865be0ea8fb74a10e156425de48
parent 413571 ad7b8e6c381646d827339d34e4ac9db07654bcc8
child 413573 39a1b32c5425512ddbf4ee01b7fbcdc143bf8ef0
push id33850
push userapavel@mozilla.com
push dateMon, 16 Apr 2018 09:53:48 +0000
treeherdermozilla-central@6276ec7ebbf3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1446261, 10066, 774887, 954642, 543959
milestone61.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 1446261 [wpt PR 10066] - [css-typed-om] Clean up CSSUnitValue tests., a=testonly Automatic update from web-platform-tests[css-typed-om] Clean up CSSUnitValue tests. This patch: - Adds mutation tests for CSSUnitValue.value. - Clean up code style. Bug: 774887 Change-Id: I5a6398c4a4a2ad86f60165780ee8d48bb3d8b0a1 Reviewed-on: https://chromium-review.googlesource.com/954642 Commit-Queue: Darren Shen <shend@chromium.org> Reviewed-by: nainar <nainar@chromium.org> Cr-Commit-Position: refs/heads/master@{#543959} wpt-commits: 790e6601ee8b4b412b6ad9f6fde466b7ccb9cb7e wpt-pr: 10066 wpt-commits: 790e6601ee8b4b412b6ad9f6fde466b7ccb9cb7e wpt-pr: 10066
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/css/css-typed-om/stylevalue-subclasses/numeric-objects/cssUnitValue-value.html
testing/web-platform/tests/css/css-typed-om/stylevalue-subclasses/numeric-objects/cssUnitValue.html
testing/web-platform/tests/css/css-typed-om/stylevalue-subclasses/numeric-objects/cssUnitValue.tentative.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -316964,19 +316964,25 @@
     ]
    ],
    "css/css-typed-om/stylevalue-subclasses/numeric-objects/cssMathValue.tentative.html": [
     [
      "/css/css-typed-om/stylevalue-subclasses/numeric-objects/cssMathValue.tentative.html",
      {}
     ]
    ],
-   "css/css-typed-om/stylevalue-subclasses/numeric-objects/cssUnitValue.tentative.html": [
-    [
-     "/css/css-typed-om/stylevalue-subclasses/numeric-objects/cssUnitValue.tentative.html",
+   "css/css-typed-om/stylevalue-subclasses/numeric-objects/cssUnitValue-value.html": [
+    [
+     "/css/css-typed-om/stylevalue-subclasses/numeric-objects/cssUnitValue-value.html",
+     {}
+    ]
+   ],
+   "css/css-typed-om/stylevalue-subclasses/numeric-objects/cssUnitValue.html": [
+    [
+     "/css/css-typed-om/stylevalue-subclasses/numeric-objects/cssUnitValue.html",
      {}
     ]
    ],
    "css/css-typed-om/stylevalue-subclasses/numeric-objects/cssnumericvalue-multiply-two-types.tentative.html": [
     [
      "/css/css-typed-om/stylevalue-subclasses/numeric-objects/cssnumericvalue-multiply-two-types.tentative.html",
      {}
     ]
@@ -522383,18 +522389,22 @@
   "css/css-typed-om/stylevalue-subclasses/numeric-objects/cssMathNegate-type.html": [
    "98d69118f7b5c26031ec55e66112cd1424f74d4f",
    "testharness"
   ],
   "css/css-typed-om/stylevalue-subclasses/numeric-objects/cssMathValue.tentative.html": [
    "e19ec7ede86d52ecf29a142607de481facabcfb2",
    "testharness"
   ],
-  "css/css-typed-om/stylevalue-subclasses/numeric-objects/cssUnitValue.tentative.html": [
-   "e2d56515f3580649fc9cc8188b39056beb030036",
+  "css/css-typed-om/stylevalue-subclasses/numeric-objects/cssUnitValue-value.html": [
+   "9abf1e98ec0291f305c274e24f34b15b8c334e72",
+   "testharness"
+  ],
+  "css/css-typed-om/stylevalue-subclasses/numeric-objects/cssUnitValue.html": [
+   "a59472a3897ef37e3978f803f6a36d7a893e1f95",
    "testharness"
   ],
   "css/css-typed-om/stylevalue-subclasses/numeric-objects/cssnumericvalue-multiply-two-types.tentative.html": [
    "1b5a65d6cbc52cc263cfdb2c896e1d9591ac322f",
    "testharness"
   ],
   "css/css-typed-om/stylevalue-subclasses/numeric-objects/equals.tentative.html": [
    "466d97791b5fbec3dd52406bd8da3d277ae5ccdc",
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/css-typed-om/stylevalue-subclasses/numeric-objects/cssUnitValue-value.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>CSSUnitValue.value</title>
+<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#cssunitvalue">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<div id="log"></div>
+<script>
+'use strict';
+
+test(() => {
+  const result = new CSSUnitValue(-3.14, 'px');
+  result.value = 3.14;
+  assert_equals(result.value, 3.14, 'value reflects new value');
+  assert_equals(result.unit, 'px', 'unit does not change');
+}, 'CSSUnitValue.value can be updated to a different value');
+
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/css-typed-om/stylevalue-subclasses/numeric-objects/cssUnitValue.html
@@ -0,0 +1,32 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>CSSUnitValue Constructor</title>
+<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-cssunitvalue-cssunitvalue">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="../../resources/testhelper.js"></script>
+<body>
+<div id="log"></div>
+<script>
+'use strict';
+
+test(() => {
+  assert_throws(new TypeError(), () => new CSSUnitValue(0, 'lemon'));
+}, 'Constructing CSSUnitValue with an unknown unit throws a TypeError');
+
+test(() => {
+  assert_throws(new TypeError(), () => new CSSUnitValue(0, ''));
+}, 'Constructing CSSUnitValue with a empty string unit throws a TypeError');
+
+for (const unit of gValidUnits) {
+  test(() => {
+    const result = new CSSUnitValue(-3.14, unit);
+    assert_not_equals(result, null, 'a CSSUnitValue is created');
+    assert_equals(result.value, -3.14,
+                  'value is same as given by constructor');
+    assert_equals(result.unit, unit.toLowerCase(),
+                  'unit is same as given by constructor');
+  }, 'CSSUnitValue can be constructed with ' + unit);
+}
+
+</script>
deleted file mode 100644
--- a/testing/web-platform/tests/css/css-typed-om/stylevalue-subclasses/numeric-objects/cssUnitValue.tentative.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!doctype html>
-<meta charset="utf-8">
-<title>CSSUnitValue tests</title>
-<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#simple-numeric">
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script src="../../resources/testhelper.js"></script>
-<script>
-'use strict';
-
-const gInvalidTestUnits = [
-  { unit: '', desc: 'an empty string' },
-  { unit: 'lemon', desc: 'an invalid unit' },
-];
-
-for (const {unit, desc} of gInvalidTestUnits) {
-  test(() => {
-    assert_throws(new TypeError(), () => new CSSUnitValue(0, unit));
-  }, 'Constructing CSSUnitValue with ' + desc + ' as the unit throws a TypeError');
-}
-
-for (const unit of gValidUnits) {
-  test(() => {
-    const result = new CSSUnitValue(-3.14, unit);
-    assert_equals(result.value, -3.14);
-    assert_equals(result.unit, unit.toLowerCase());
-  }, 'CSSUnitValue can be constructed with ' + unit);
-}
-
-</script>