Bug 1424271 - convert mochitest test_audioBufferSourceNodeLoopStartEnd.html to a web-platform-test r?padenot draft
authorp1509425
Fri, 05 Jan 2018 11:56:12 +0100
changeset 717079 47c886768e417267da575124d4ca7bd6f4fef112
parent 717078 0a3235713389d527fcb77b8efa3ea13c6a8ddf79
child 717080 9b0e412885affbe5f9555dc28f7f7013fca14b70
push id94557
push userbmo:alan.guyoch@gmail.com
push dateMon, 08 Jan 2018 07:50:18 +0000
reviewerspadenot
bugs1424271
milestone59.0a1
Bug 1424271 - convert mochitest test_audioBufferSourceNodeLoopStartEnd.html to a web-platform-test r?padenot MozReview-Commit-ID: ApBRoGmR2k1
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/webaudio/the-audio-api/the-audiobuffersourcenode-interface/test_audioBufferSourceNodeLoopStartEnd.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -348558,16 +348558,22 @@
     ]
    ],
    "webaudio/the-audio-api/the-audiobuffersourcenode-interface/test_audioBufferSourceNodeLoop.html": [
     [
      "/webaudio/the-audio-api/the-audiobuffersourcenode-interface/test_audioBufferSourceNodeLoop.html",
      {}
     ]
    ],
+   "webaudio/the-audio-api/the-audiobuffersourcenode-interface/test_audioBufferSourceNodeLoopStartEnd.html": [
+    [
+     "/webaudio/the-audio-api/the-audiobuffersourcenode-interface/test_audioBufferSourceNodeLoopStartEnd.html",
+     {}
+    ]
+   ],
    "webaudio/the-audio-api/the-audiodestinationnode-interface/idl-test.html": [
     [
      "/webaudio/the-audio-api/the-audiodestinationnode-interface/idl-test.html",
      {}
     ]
    ],
    "webaudio/the-audio-api/the-audionode-interface/audionode-connect-return-value.html": [
     [
@@ -576463,16 +576469,20 @@
   "webaudio/the-audio-api/the-audiobuffersourcenode-interface/test_audioBufferSourceNodeLazyLoopParam.html": [
    "5ac3d042f02eea9ccd49c4985162b8f147f161e3",
    "testharness"
   ],
   "webaudio/the-audio-api/the-audiobuffersourcenode-interface/test_audioBufferSourceNodeLoop.html": [
    "a6047ca7c70167e32eac544dd1e5d31708db2c29",
    "testharness"
   ],
+  "webaudio/the-audio-api/the-audiobuffersourcenode-interface/test_audioBufferSourceNodeLoopStartEnd.html": [
+   "88d9b5d9930a0a59b3a509cc724d0f539a10cd89",
+   "testharness"
+  ],
   "webaudio/the-audio-api/the-audiocontext-interface/.gitkeep": [
    "da39a3ee5e6b4b0d3255bfef95601890afd80709",
    "support"
   ],
   "webaudio/the-audio-api/the-audiodestinationnode-interface/.gitkeep": [
    "da39a3ee5e6b4b0d3255bfef95601890afd80709",
    "support"
   ],
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/webaudio/the-audio-api/the-audiobuffersourcenode-interface/test_audioBufferSourceNodeLoopStartEnd.html
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <meta charset="utf-8">
+  <script src="/resources/testharness.js"></script>
+  <script src="/resources/testharnessreport.js"></script>
+  <script src="/webaudio/js/helpers.js"></script>
+  <script>
+var gTest = {
+  length: 2048 * 4,
+  numberOfChannels: 1,
+  createGraph: function(context) {
+    var buffer = context.createBuffer(1, 2048, context.sampleRate);
+    for (var i = 0; i < 2048; ++i) {
+      buffer.getChannelData(0)[i] = Math.sin(
+        440 * 2 * Math.PI * i / context.sampleRate
+      );
+    }
+
+    var source = new AudioBufferSourceNode(context, {
+      buffer: buffer,
+      loop: true,
+      loopStart: buffer.duration * 0.25,
+      loopEnd: buffer.duration * 0.75
+    });
+    source.start(0);
+    return source;
+  },
+  createExpectedBuffers: function(context) {
+    var expectedBuffer = context.createBuffer(1, 2048 * 4, context.sampleRate);
+    for (var i = 0; i < 1536; ++i) {
+      expectedBuffer.getChannelData(0)[i] = Math.sin(
+        440 * 2 * Math.PI * i / context.sampleRate
+      );
+    }
+    for (var i = 0; i < 6; ++i) {
+      for (var j = 512; j < 1536; ++j) {
+        expectedBuffer.getChannelData(0)[1536 + i * 1024 + j - 512] = Math.sin(
+          440 * 2 * Math.PI * j / context.sampleRate
+        );
+      }
+    }
+    for (var j = 7680; j < 2048 * 4; ++j) {
+      expectedBuffer.getChannelData(0)[j] = Math.sin(
+        440 * 2 * Math.PI * (j - 7168) / context.sampleRate
+      );
+    }
+    return expectedBuffer;
+  }
+};
+
+runTest();
+  </script>
+</head>
+</body>
+</html>