Bug 1301305 - Move propertyToIDL to testcommon.js; r=hiro
authorBrian Birtles <birtles@gmail.com>
Fri, 02 Dec 2016 08:58:19 +0900
changeset 325327 aba14a8202e05d4c62b478ff9c61f0ac02dc8438
parent 325326 aa5c5ad83b28d871837a3265d1b35fd2d75e8212
child 325328 9a3bdee53cec09705fdf604c0c0c93364eb16c2a
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +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 " +