Commit 167f4e46 authored by Arthur Edelstein's avatar Arthur Edelstein Committed by Georg Koppen
Browse files

Bug 16337: Round times exposed by Animation API to nearest 100ms

parent 77274064
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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;
+1 −0
Original line number Diff line number Diff line
@@ -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]
+43 −0
Original line number Diff line number Diff line
<!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>