[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-browser/tor-browser-52.1.0esr-7.0-2] Bug 16337: Round times exposed by Animation API to nearest 100ms



commit 77f0de013fa2b5bedb851507f5ec94a8f39f8b8c
Author: Arthur Edelstein <arthuredelstein@xxxxxxxxx>
Date:   Wed May 3 23:47:53 2017 -0700

    Bug 16337: Round times exposed by Animation API to nearest 100ms
---
 dom/animation/AnimationUtils.h                     |  3 +-
 dom/animation/test/mochitest.ini                   |  1 +
 .../test/test_animation_time_rounding.html         | 43 ++++++++++++++++++++++
 3 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/dom/animation/AnimationUtils.h b/dom/animation/AnimationUtils.h
index 82ae69b..e20f314 100644
--- a/dom/animation/AnimationUtils.h
+++ b/dom/animation/AnimationUtils.h
@@ -28,7 +28,8 @@ public:
     dom::Nullable<double> result;
 
     if (!aTime.IsNull()) {
-      result.SetValue(aTime.Value().ToMilliseconds());
+      double unrounded = aTime.Value().ToMilliseconds();
+      result.SetValue(floor(unrounded / 100) * 100);
     }
 
     return result;
diff --git a/dom/animation/test/mochitest.ini b/dom/animation/test/mochitest.ini
index feb4245..49d230c 100644
--- a/dom/animation/test/mochitest.ini
+++ b/dom/animation/test/mochitest.ini
@@ -109,3 +109,4 @@ skip-if = toolkit == 'android'
 [style/test_animation-seeking-with-start-time.html]
 [style/test_animation-setting-effect.html]
 [style/test_animation-setting-spacing.html]
+[test_animation_time_rounding.html]
diff --git a/dom/animation/test/test_animation_time_rounding.html b/dom/animation/test/test_animation_time_rounding.html
new file mode 100644
index 0000000..baad593
--- /dev/null
+++ b/dom/animation/test/test_animation_time_rounding.html
@@ -0,0 +1,43 @@
+<!DOCTYPE HTML>
+<html>
+  <!--
+  https://trac.torproject.org/16337
+     -->
+  <head>
+    <meta charset="utf-8">
+    <title>Test for Tor Bug 16337</title>
+    <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+    <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  </head>
+  <body>
+    <div id="testDiv">test</div>
+    <script type="application/javascript">
+     SimpleTest.waitForExplicitFinish();
+     let runTest = async function () {
+       await SpecialPowers.pushPrefEnv({ set: [["dom.animations-api.core.enabled", true]] });
+       let isRounded = x => (Math.floor(x/100)*100) === x;
+       let testDiv = document.getElementById("testDiv");
+       let animation = testDiv.animate({ opacity: [0,1] }, 100000);
+       animation.play();
+       SimpleTest.waitForCondition(
+         () => animation.currentTime > 1000,
+         function () {
+           ok(isRounded(animation.startTime),
+              "animation.startTime is rounded");
+           ok(isRounded(animation.currentTime),
+              "animation.currentTime is rounded");
+           ok(isRounded(animation.timeline.currentTime),
+              "animation.timeline.currentTime is rounded");
+           if (document.timeline) {
+             ok(isRounded(document.timeline.currentTime),
+                "document.timeline.currentTime is rounded");
+           }
+           SimpleTest.finish();
+         },
+         "animation failed to start");
+     }
+
+     window.onload = runTest;
+    </script>
+  </body>
+</html>

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits