Bug 1398038 - Use slightly more modern JS in keyframe-*.js; r?hiro draft
authorBrian Birtles <birtles@gmail.com>
Wed, 18 Oct 2017 14:12:15 +0900
changeset 683755 0cca0bdff94dfe6e5d470a2267b096a408c00d4d
parent 683754 85e7605dc3d55632074902e37955b17d782ab269
child 683756 804155ee15bb1b94bd0381c15c7fe92685d42e17
push id85456
push userbmo:bbirtles@mozilla.com
push dateFri, 20 Oct 2017 06:31:55 +0000
reviewershiro
bugs1398038
milestone58.0a1
Bug 1398038 - Use slightly more modern JS in keyframe-*.js; r?hiro MozReview-Commit-ID: BCIiGEtivzq
testing/web-platform/tests/web-animations/resources/keyframe-tests.js
testing/web-platform/tests/web-animations/resources/keyframe-utils.js
--- a/testing/web-platform/tests/web-animations/resources/keyframe-tests.js
+++ b/testing/web-platform/tests/web-animations/resources/keyframe-tests.js
@@ -6,39 +6,39 @@
 //
 // ==============================
 
 
 // ------------------------------
 //  Composite values
 // ------------------------------
 
-var gGoodKeyframeCompositeValueTests = [
+const gGoodKeyframeCompositeValueTests = [
   "replace", "add", "accumulate", undefined
 ];
 
-var gGoodOptionsCompositeValueTests = [
+const gGoodOptionsCompositeValueTests = [
   "replace", "add", "accumulate"
 ];
 
-var gBadCompositeValueTests = [
+const gBadCompositeValueTests = [
   "unrecognised", "replace ", "Replace", null
 ];
 
 // ------------------------------
 //  Keyframes
 // ------------------------------
 
-var gEmptyKeyframeListTests = [
+const gEmptyKeyframeListTests = [
   [],
   null,
   undefined,
 ];
 
-var gPropertyIndexedKeyframesTests = [
+const gPropertyIndexedKeyframesTests = [
   { desc:   "a one property two value property-indexed keyframes specification",
     input:  { left: ["10px", "20px"] },
     output: [{ offset: null, computedOffset: 0, easing: "linear",
                left: "10px" },
              { offset: null, computedOffset: 1, easing: "linear",
                left: "20px" }] },
   { desc:   "a one shorthand property two value property-indexed keyframes"
             + " specification",
@@ -124,17 +124,17 @@ var gPropertyIndexedKeyframesTests = [
   { desc:   "a one property two value property-indexed keyframes specification"
             + " where the second value is invalid",
     input:  { left: ["10px", "invalid"] },
     output: [{ offset: null, computedOffset: 0, easing: "linear",
                left: "10px" },
              { offset: null, computedOffset: 1, easing: "linear" }] },
 ];
 
-var gKeyframeSequenceTests = [
+const gKeyframeSequenceTests = [
   { desc:   "a one property one keyframe sequence",
     input:  [{ offset: 1, left: "10px" }],
     output: [{ offset: 1, computedOffset: 1, easing: "linear",
                left: "10px" }] },
   { desc:   "a one property two keyframe sequence",
     input:  [{ offset: 0, left: "10px" },
              { offset: 1, left: "20px" }],
     output: [{ offset: 0, computedOffset: 0, easing: "linear", left: "10px" },
@@ -405,17 +405,17 @@ var gKeyframeSequenceTests = [
              { offset: 0.5, computedOffset: 0.5, easing: "linear",
                left: "300px" },
              { offset: 1.0, computedOffset: 1.0, easing: "ease-out",
                left: "400px" },
              { offset: 1.0, computedOffset: 1.0, easing: "steps(1)",
                left: "500px" }] },
 ];
 
-var gInvalidKeyframesTests = [
+const gInvalidKeyframesTests = [
   { desc:     "keyframes with an out-of-bounded positive offset",
     input:    [ { opacity: 0 },
                 { opacity: 0.5, offset: 2 },
                 { opacity: 1 } ],
     expected: { name: "TypeError" } },
   { desc:     "keyframes with an out-of-bounded negative offset",
     input:    [ { opacity: 0 },
                 { opacity: 0.5, offset: -1 },
@@ -438,17 +438,17 @@ var gInvalidKeyframesTests = [
                 { opacity: 1 } ],
     expected: { name: "TypeError" } }
 ];
 
 // ------------------------------
 //  KeyframeEffectOptions
 // ------------------------------
 
-var gKeyframeEffectOptionTests = [
+const gKeyframeEffectOptionTests = [
   { desc:     "an empty KeyframeEffectOptions object",
     input:    { },
     expected: { } },
   { desc:     "a normal KeyframeEffectOptions object",
     input:    { delay: 1000,
                 fill: "auto",
                 iterations: 5.5,
                 duration: "auto",
@@ -476,17 +476,17 @@ var gKeyframeEffectOptionTests = [
   { desc:     "an auto fill",
     input:    { fill: "auto" },
     expected: { fill: "auto" } },
   { desc:     "a forwards fill",
     input:    { fill: "forwards" },
     expected: { fill: "forwards" } }
 ];
 
-var gInvalidKeyframeEffectOptionTests = [
+const gInvalidKeyframeEffectOptionTests = [
   { desc:     "-Infinity",
     input:    -Infinity,
     expected: { name: "TypeError" } },
   { desc:     "NaN",
     input:    NaN,
     expected: { name: "TypeError" } },
   { desc:     "a negative value",
     input:    -1,
--- a/testing/web-platform/tests/web-animations/resources/keyframe-utils.js
+++ b/testing/web-platform/tests/web-animations/resources/keyframe-utils.js
@@ -13,22 +13,22 @@
 
 /**
  * Test equality between two lists of computed keyframes
  * @param {Array.<ComputedKeyframe>} a - actual computed keyframes
  * @param {Array.<ComputedKeyframe>} b - expected computed keyframes
  */
 function assert_frame_lists_equal(a, b) {
   assert_equals(a.length, b.length, "number of frames");
-  for (var i = 0; i < Math.min(a.length, b.length); i++) {
-    assert_frames_equal(a[i], b[i], "ComputedKeyframe #" + i);
+  for (let i = 0; i < Math.min(a.length, b.length); i++) {
+    assert_frames_equal(a[i], b[i], `ComputedKeyframe #${i}`);
   }
 }
 
 /** Helper for assert_frame_lists_equal */
 function assert_frames_equal(a, b, name) {
   assert_equals(Object.keys(a).sort().toString(),
                 Object.keys(b).sort().toString(),
-                "properties on " + name);
-  for (var p in a) {
-    assert_equals(a[p], b[p], "value for '" + p + "' on " + name);
+                `properties on ${name} should match`);
+  for (const p in a) {
+    assert_equals(a[p], b[p], `value for '${p}' on ${name}`);
   }
 }