bug 1208318 ensure that currentTime has advanced sufficiently to easily detect failure r=padenot
authorKarl Tomlinson <karlt+@karlt.net>
Tue, 29 Sep 2015 13:39:24 +1300
changeset 265087 5a6b599cc18cfe65522ea69debbf0319332d48de
parent 265086 96db1aea13c6fd2e11c57d9236477baab6094de8
child 265088 33053d791e56928a4906949ff4ee15681edf935b
push id65838
push userktomlinson@mozilla.com
push dateWed, 30 Sep 2015 00:43:54 +0000
treeherdermozilla-inbound@f1f82e673a34 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1208318
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 1208318 ensure that currentTime has advanced sufficiently to easily detect failure r=padenot
dom/media/webaudio/test/test_scriptProcessorNode_playbackTime1.html
--- a/dom/media/webaudio/test/test_scriptProcessorNode_playbackTime1.html
+++ b/dom/media/webaudio/test/test_scriptProcessorNode_playbackTime1.html
@@ -5,42 +5,48 @@
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
-SimpleTest.requestFlakyTimeout(
-  "This test needs to wait until AudioDestinationNode has started has " +
-  "accumulated some 'extra' time.");
 
 var context = new AudioContext();
 const delay = 0.1;
 
-setTimeout(
-  function() {
-    const processorBufferLength = 256;
-    // |currentTime| may include double precision floating point
-    // rounding errors, so round to nearest integer sample to ignore these.
-    var minimumPlaybackSample =
-      Math.round(context.currentTime * context.sampleRate) +
-      processorBufferLength;
-    var sp = context.createScriptProcessor(processorBufferLength);
-    sp.connect(context.destination);
-    sp.onaudioprocess =
-      function(e) {
-        is(e.inputBuffer.length, processorBufferLength,
-           "expected buffer length");
-        var playbackSample = Math.round(e.playbackTime * context.sampleRate)
-        ok(playbackSample >= minimumPlaybackSample,
-           "playbackSample " + playbackSample +
-           " beyond expected minimum " + minimumPlaybackSample);
-        sp.onaudioprocess = null;
-        SimpleTest.finish();
-      };
-  }, 1000 * delay);
+function doTest() {
+  const processorBufferLength = 256;
+  // |currentTime| may include double precision floating point
+  // rounding errors, so round to nearest integer sample to ignore these.
+  var minimumPlaybackSample =
+    Math.round(context.currentTime * context.sampleRate) +
+    processorBufferLength;
+  var sp = context.createScriptProcessor(processorBufferLength);
+  sp.connect(context.destination);
+  sp.onaudioprocess =
+    function(e) {
+      is(e.inputBuffer.length, processorBufferLength,
+         "expected buffer length");
+      var playbackSample = Math.round(e.playbackTime * context.sampleRate)
+      ok(playbackSample >= minimumPlaybackSample,
+         "playbackSample " + playbackSample +
+         " beyond expected minimum " + minimumPlaybackSample);
+      sp.onaudioprocess = null;
+      SimpleTest.finish();
+    };
+}
+
+// Wait until AudioDestinationNode has accumulated enough 'extra' time so that
+// a failure would be easily detected.
+(function waitForExtraTime() {
+  if (context.currentTime < delay) {
+    SimpleTest.executeSoon(waitForExtraTime);
+  } else {
+    doTest();
+  }
+})();
 
 </script>
 </pre>
 </body>
 </html>