Bug 1301305 - Move propertyToIDL to testcommon.js; r?hiro draft
authorBrian Birtles <birtles@gmail.com>
Fri, 02 Dec 2016 08:58:19 +0900
changeset 447575 5e9af4f0ffacaaf08ecee4e6018bed1ee4a74047
parent 447574 ff89d0e6a5f9e59990ead431200726b492f71e81
child 447576 58462ab48acc0b1298915d0d3572915b6973ac82
push id38084
push userbbirtles@mozilla.com
push dateTue, 06 Dec 2016 07:57:40 +0000
reviewershiro
bugs1301305
milestone53.0a1
Bug 1301305 - Move propertyToIDL to testcommon.js; r?hiro We would like to use this method in the next patch. MozReview-Commit-ID: CSdwlVInyds
dom/animation/test/mozilla/file_discrete-animations.html
dom/animation/test/testcommon.js
--- a/dom/animation/test/mozilla/file_discrete-animations.html
+++ b/dom/animation/test/mozilla/file_discrete-animations.html
@@ -138,28 +138,16 @@ for (let property in gMozillaSpecificPro
     testAnimationSamples(animation, idlName,
                          [{ time: 0,    expected: from.toLowerCase() },
                           { time: 940,  expected: from.toLowerCase() },
                           { time: 960,  expected: to.toLowerCase() }]);
   }, property + " should animate between '"
    + from + "' and '" + to + "' with keyframe easing");
 }
 
-function propertyToIDL(property) {
-  var prefixMatch = property.match(/^-(\w+)-/);
-  if (prefixMatch) {
-    var prefix = prefixMatch[1] === "moz" ? "Moz" : prefixMatch[1];
-    property = prefix + property.substring(prefixMatch[0].length - 1);
-  }
-  // https://drafts.csswg.org/cssom/#css-property-to-idl-attribute
-  return property.replace(/-([a-z])/gi, function(str, group) {
-    return group.toUpperCase();
-  });
-}
-
 function testAnimationSamples(animation, idlName, testSamples) {
   const target = animation.effect.target;
   testSamples.forEach(testSample => {
     animation.currentTime = testSample.time;
     assert_equals(getComputedStyle(target)[idlName], testSample.expected,
                   "The value should be " + testSample.expected +
                   " at " + testSample.time + "ms");
   });
--- a/dom/animation/test/testcommon.js
+++ b/dom/animation/test/testcommon.js
@@ -133,16 +133,32 @@ function addStyle(t, rules) {
   if (t && typeof t.add_cleanup === 'function') {
     t.add_cleanup(function() {
       extraStyle.remove();
     });
   }
 }
 
 /**
+ * Takes a CSS property (e.g. margin-left) and returns the equivalent IDL
+ * name (e.g. marginLeft).
+ */
+function propertyToIDL(property) {
+  var prefixMatch = property.match(/^-(\w+)-/);
+  if (prefixMatch) {
+    var prefix = prefixMatch[1] === 'moz' ? 'Moz' : prefixMatch[1];
+    property = prefix + property.substring(prefixMatch[0].length - 1);
+  }
+  // https://drafts.csswg.org/cssom/#css-property-to-idl-attribute
+  return property.replace(/-([a-z])/gi, function(str, group) {
+    return group.toUpperCase();
+  });
+}
+
+/**
  * Promise wrapper for requestAnimationFrame.
  */
 function waitForFrame() {
   return new Promise(function(resolve, reject) {
     window.requestAnimationFrame(resolve);
   });
 }
 
@@ -209,17 +225,17 @@ if (opener) {
     opener.add_completion_callback(function() {
       self.close();
     });
     opener.done();
   }
 }
 
 /**
- * Return a new MutaionObserver which started observing |target| element
+ * Return a new MutationObserver which started observing |target| element
  * with { animations: true, subtree: |subtree| } option.
  * NOTE: This observer should be used only with takeRecords(). If any of
  * MutationRecords are observed in the callback of the MutationObserver,
  * it will raise an assertion.
  */
 function setupSynchronousObserver(t, target, subtree) {
    var observer = new MutationObserver(records => {
      assert_unreached("Any MutationRecords should not be observed in this " +