Bug 1526860 [wpt PR 15214] - Round up to the next render quantum for suspend, a=testonly
authorRaymond Toy <rtoy@chromium.org>
Tue, 19 Feb 2019 11:46:22 +0000
changeset 519215 dcf9f8a30353c00c97b288f85ea84f95bd4d3d19
parent 519214 c05f77a145341bc13fa1ffaad5ec9163bf6b2a5e
child 519216 b2d1b24dd99b273b6b1d0db52c1839d9e1ab8faf
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1526860, 15214, 927895, 1450536, 630346
milestone67.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 1526860 [wpt PR 15214] - Round up to the next render quantum for suspend, a=testonly Automatic update from web-platform-tests Round up to the next render quantum for suspend OfflineAudioContext.suspend rounds the time up to the next render quantum instead of down. It is sometimes confusing when suspend occurs before the given time, which is different from how everything else works in WebAudio. A few tests need to be fixed because they computed the boundary by rounding down instead of up. One test needed to be adjusted because the times were rounded to different boundaries instead of the same boundary. See also https://github.com/WebAudio/web-audio-api/issues/1822 Bug: 927895 Change-Id: Ie6685c620dd38eb2a059901d13b907764ba1a2db Reviewed-on: https://chromium-review.googlesource.com/c/1450536 Reviewed-by: Kent Tamura <tkent@chromium.org> Reviewed-by: Hongchan Choi <hongchan@chromium.org> Commit-Queue: Raymond Toy <rtoy@chromium.org> Cr-Commit-Position: refs/heads/master@{#630346} -- wpt-commits: 1b1a627e597f15b60327191799b8081beac2a3cd wpt-pr: 15214
testing/web-platform/tests/webaudio/the-audio-api/the-audionode-interface/audionode-disconnect-audioparam.html
testing/web-platform/tests/webaudio/the-audio-api/the-channelmergernode-interface/audiochannelmerger-disconnect.html
--- a/testing/web-platform/tests/webaudio/the-audio-api/the-audionode-interface/audionode-disconnect-audioparam.html
+++ b/testing/web-platform/tests/webaudio/the-audio-api/the-audionode-interface/audionode-disconnect-audioparam.html
@@ -17,30 +17,31 @@
       let renderDuration = 0.5;
       let disconnectTime = 0.5 * renderDuration;
 
       let audit = Audit.createTaskRunner();
 
       // Calculate the index for disconnection.
       function getDisconnectIndex(disconnectTime) {
         let disconnectIndex = disconnectTime * sampleRate;
-        return disconnectIndex -= (disconnectIndex) % renderQuantum;
+        disconnectIndex = renderQuantum *
+            Math.floor((disconnectIndex + renderQuantum - 1) / renderQuantum);
+        return disconnectIndex;
       }
 
       // Get the index of value change.
       function getValueChangeIndex(array, targetValue) {
         return array.findIndex(function(element, index) {
           if (element === targetValue)
             return true;
         });
       }
 
       // Task 1: test disconnect(AudioParam) method.
       audit.define('disconnect(AudioParam)', (task, should) => {
-
         // Creates a buffer source with value [1] and then connect it to two
         // gain nodes in series. The output of the buffer source is lowered by
         // half
         // (* 0.5) and then connected to two |.gain| AudioParams in each gain
         // node.
         //
         //  (1) bufferSource => gain1 => gain2
         //  (2) bufferSource => half => gain1.gain
@@ -84,24 +85,22 @@
               let channelData = buffer.getChannelData(0);
               let disconnectIndex = getDisconnectIndex(disconnectTime);
               let valueChangeIndex = getValueChangeIndex(channelData, 1.5);
 
               // Expected values are: 1 * 1.5 * 1.5 -> 1 * 1.5 = [2.25, 1.5]
               should(channelData, 'Channel #0').containValues([2.25, 1.5]);
               should(valueChangeIndex, 'The index of value change')
                   .beEqualTo(disconnectIndex);
-
             })
             .then(() => task.done());
       });
 
       // Task 2: test disconnect(AudioParam, output) method.
       audit.define('disconnect(AudioParam, output)', (task, should) => {
-
         // Create a 2-channel buffer source with [1, 2] in each channel and
         // make a serial connection through gain1 and gain 2. The make the
         // buffer source half with a gain node and connect it to a 2-output
         // splitter. Connect each output to 2 gain AudioParams respectively.
         //
         //    (1) bufferSource => gain1 => gain2
         //    (2) bufferSource => half => splitter(2)
         //    (3) splitter#0 => gain1.gain
@@ -163,17 +162,16 @@
                   .beEqualTo(disconnectIndex);
 
               // Expected values are: 2 * 1.5 * 2 -> 2 * 1.5 = [6, 3]
               should(channelData1, 'Channel #1').containValues([6, 3]);
               should(
                   valueChangeIndexCh1,
                   'The index of value change in channel #1')
                   .beEqualTo(disconnectIndex);
-
             })
             .then(() => task.done());
       });
 
       // Task 3: exception checks.
       audit.define('exceptions', (task, should) => {
         let context = new AudioContext();
         let gain1 = context.createGain();
@@ -186,29 +184,38 @@
         // exceptions are thrown.
         gain1.connect(splitter);
         splitter.connect(gain2.gain, 0);
         splitter.connect(gain3.gain, 1);
         gain2.connect(gain3);
         gain3.connect(context.destination);
 
         // gain1 is not connected to gain3.gain. Exception should be thrown.
-        should(function() {
-          gain1.disconnect(gain3.gain);
-        }, 'gain1.disconnect(gain3.gain)').throw(DOMException, 'InvalidAccessError');
+        should(
+            function() {
+              gain1.disconnect(gain3.gain);
+            },
+            'gain1.disconnect(gain3.gain)')
+            .throw(DOMException, 'InvalidAccessError');
 
         // When the output index is good but the destination is invalid.
-        should(function() {
-          splitter.disconnect(gain1.gain, 1);
-        }, 'splitter.disconnect(gain1.gain, 1)').throw(DOMException, 'InvalidAccessError');
+        should(
+            function() {
+              splitter.disconnect(gain1.gain, 1);
+            },
+            'splitter.disconnect(gain1.gain, 1)')
+            .throw(DOMException, 'InvalidAccessError');
 
         // When both arguments are wrong, throw IndexSizeError first.
-        should(function() {
-          splitter.disconnect(gain1.gain, 2);
-        }, 'splitter.disconnect(gain1.gain, 2)').throw(DOMException, 'IndexSizeError');
+        should(
+            function() {
+              splitter.disconnect(gain1.gain, 2);
+            },
+            'splitter.disconnect(gain1.gain, 2)')
+            .throw(DOMException, 'IndexSizeError');
 
         task.done();
       });
 
       audit.run();
     </script>
   </body>
 </html>
--- a/testing/web-platform/tests/webaudio/the-audio-api/the-channelmergernode-interface/audiochannelmerger-disconnect.html
+++ b/testing/web-platform/tests/webaudio/the-audio-api/the-channelmergernode-interface/audiochannelmerger-disconnect.html
@@ -53,29 +53,30 @@
             .then(function(buffer) {
               // The entire first channel of the output should be 1.
               should(buffer.getChannelData(0), 'Channel #0')
                   .beConstantValueOf(1);
 
               // Calculate the first zero index in the second channel.
               let channel1 = buffer.getChannelData(1);
               let disconnectIndex = disconnectTime * sampleRate;
-              disconnectIndex -= (disconnectIndex) % renderQuantum;
+              disconnectIndex = renderQuantum *
+                  Math.floor(
+                      (disconnectIndex + renderQuantum - 1) / renderQuantum);
               let firstZeroIndex = channel1.findIndex(function(element, index) {
                 if (element === 0)
                   return index;
               });
 
               // The second channel should contain 1, and 0 after the
               // disconnection.
               should(channel1, 'Channel #1').containValues([1, 0]);
               should(
                   firstZeroIndex, 'The index of first zero in the channel #1')
                   .beEqualTo(disconnectIndex);
-
             })
             .then(() => task.done());
       });
 
       audit.run();
     </script>
   </body>
 </html>