Title: [264469] trunk/LayoutTests/imported/w3c
Revision
264469
Author
[email protected]
Date
2020-07-16 10:39:21 -0700 (Thu, 16 Jul 2020)

Log Message

Resync web-platform-tests/webaudio from upstream
https://bugs.webkit.org/show_bug.cgi?id=214411

Reviewed by Geoffrey Garen.

Resync web-platform-tests/webaudio from upstream 81de986322a0de90f2.

* web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/processing-after-resume.https-expected.txt: Added.
* web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/processing-after-resume.https.html: Added.
* web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/suspend-after-construct-expected.txt: Added.
* web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/suspend-after-construct.html: Added.
* web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/w3c-import.log:
* web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletprocessor-process-frozen-array.https-expected.txt: Added.
* web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletprocessor-process-frozen-array.https.html: Added.
* web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletprocessor-process-zero-outputs.https-expected.txt: Added.
* web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletprocessor-process-zero-outputs.https.html: Added.
* web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/array-check-processor.js: Added.
(ArrayFrozenProcessor):
(ArrayFrozenProcessor.prototype.process):
(ArrayTransferProcessor):
(ArrayTransferProcessor.prototype.process):
* web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/port-processor.js:
(PortProcessor):
(PortProcessor.prototype.handleMessage):
(PortProcessor.prototype.process):
* web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/w3c-import.log:
* web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/zero-outputs-check-processor.js: Added.
(IsAllZero):
(ZeroOutputsCheckProcessor):
(ZeroOutputsCheckProcessor.prototype.process):
* web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/suspended-context-messageport.https.html:
* web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/w3c-import.log:
* web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/convolver-response-1-chan.html:
* web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/convolver-response-2-chan-expected.txt:
* web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/convolver-response-2-chan.html:
* web-platform-tests/webaudio/the-audio-api/the-delaynode-interface/no-dezippering.html:
* web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/osc-basic-waveform-expected.txt: Added.
* web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/osc-basic-waveform.html: Added.
* web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/w3c-import.log:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (264468 => 264469)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-07-16 17:25:51 UTC (rev 264468)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-07-16 17:39:21 UTC (rev 264469)
@@ -1,3 +1,45 @@
+2020-07-16  Chris Dumez  <[email protected]>
+
+        Resync web-platform-tests/webaudio from upstream
+        https://bugs.webkit.org/show_bug.cgi?id=214411
+
+        Reviewed by Geoffrey Garen.
+
+        Resync web-platform-tests/webaudio from upstream 81de986322a0de90f2.
+
+        * web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/processing-after-resume.https-expected.txt: Added.
+        * web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/processing-after-resume.https.html: Added.
+        * web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/suspend-after-construct-expected.txt: Added.
+        * web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/suspend-after-construct.html: Added.
+        * web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/w3c-import.log:
+        * web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletprocessor-process-frozen-array.https-expected.txt: Added.
+        * web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletprocessor-process-frozen-array.https.html: Added.
+        * web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletprocessor-process-zero-outputs.https-expected.txt: Added.
+        * web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletprocessor-process-zero-outputs.https.html: Added.
+        * web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/array-check-processor.js: Added.
+        (ArrayFrozenProcessor):
+        (ArrayFrozenProcessor.prototype.process):
+        (ArrayTransferProcessor):
+        (ArrayTransferProcessor.prototype.process):
+        * web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/port-processor.js:
+        (PortProcessor):
+        (PortProcessor.prototype.handleMessage):
+        (PortProcessor.prototype.process):
+        * web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/w3c-import.log:
+        * web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/zero-outputs-check-processor.js: Added.
+        (IsAllZero):
+        (ZeroOutputsCheckProcessor):
+        (ZeroOutputsCheckProcessor.prototype.process):
+        * web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/suspended-context-messageport.https.html:
+        * web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/w3c-import.log:
+        * web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/convolver-response-1-chan.html:
+        * web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/convolver-response-2-chan-expected.txt:
+        * web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/convolver-response-2-chan.html:
+        * web-platform-tests/webaudio/the-audio-api/the-delaynode-interface/no-dezippering.html:
+        * web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/osc-basic-waveform-expected.txt: Added.
+        * web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/osc-basic-waveform.html: Added.
+        * web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/w3c-import.log:
+
 2020-07-16  Oriol Brufau  <[email protected]>
 
         [css-grid] Fix line name positions after implicit tracks

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/processing-after-resume.https-expected.txt (0 => 264469)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/processing-after-resume.https-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/processing-after-resume.https-expected.txt	2020-07-16 17:39:21 UTC (rev 264469)
@@ -0,0 +1,3 @@
+
+FAIL Test consistency of processing after resume() promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'realtime.audioWorklet.addModule')"
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/processing-after-resume.https.html (0 => 264469)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/processing-after-resume.https.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/processing-after-resume.https.html	2020-07-16 17:39:21 UTC (rev 264469)
@@ -0,0 +1,55 @@
+<!doctype html>
+<title>Test consistency of processing after resume()</title>
+<script src=""
+<script src=""
+<script>
+const get_node_and_reply = (context) => {
+  const node = new AudioWorkletNode(context, 'port-processor');
+  return new Promise((resolve) => {
+    node.port._onmessage_ = (event) => resolve({node: node, reply: event.data});
+  });
+};
+const ping_for_reply = (node) => {
+  return new Promise((resolve) => {
+    node.port._onmessage_ = (event) => resolve(event.data);
+    node.port.postMessage('ping');
+  });
+};
+const assert_consistent = (constructReply, pong, expectedPongTime, name) => {
+  const blockSize = 128;
+  assert_equals(pong.timeStamp, expectedPongTime, `${name} pong time`);
+  assert_equals(pong.processCallCount * blockSize,
+                pong.currentFrame - constructReply.currentFrame,
+                `${name} processed frame count`);
+};
+const modulePath = '/webaudio/the-audio-api/' +
+    'the-audioworklet-interface/processors/port-processor.js';
+
+promise_test(async () => {
+  const realtime = new AudioContext();
+  await realtime.audioWorklet.addModule(modulePath);
+  await realtime.suspend();
+  const timeBeforeResume = realtime.currentTime;
+  // Two AudioWorkletNodes are constructed.
+  // node1 is constructed before and node2 after the resume() call.
+  const construct1 = get_node_and_reply(realtime);
+  const resume = realtime.resume();
+  const construct2 = get_node_and_reply(realtime);
+  const {node: node1, reply: constructReply1} = await construct1;
+  assert_equals(constructReply1.timeStamp, timeBeforeResume,
+                'construct time before resume');
+  const {node: node2, reply: constructReply2} = await construct2;
+  assert_greater_than_equal(constructReply2.timeStamp, timeBeforeResume,
+                'construct time after resume');
+  await resume;
+  // Suspend the context to freeze time and check that the processing for each
+  // node matches the elapsed time.
+  await realtime.suspend();
+  const timeAfterSuspend = realtime.currentTime;
+  const pong1 = await ping_for_reply(node1);
+  const pong2 = await ping_for_reply(node2);
+  assert_consistent(constructReply1, pong1, timeAfterSuspend, 'node1');
+  assert_consistent(constructReply2, pong2, timeAfterSuspend, 'node2');
+  assert_equals(pong1.currentFrame, pong2.currentFrame, 'currentFrame matches');
+});
+</script>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/suspend-after-construct-expected.txt (0 => 264469)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/suspend-after-construct-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/suspend-after-construct-expected.txt	2020-07-16 17:39:21 UTC (rev 264469)
@@ -0,0 +1,7 @@
+
+FAIL State change counting assert_less_than_equal: ctx 1 state change count. expected a number less than or equal to 1 but got 2
+PASS Iteration 1 
+PASS Iteration 2 
+PASS Iteration 3 
+PASS Stop waiting 
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/suspend-after-construct.html (0 => 264469)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/suspend-after-construct.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/suspend-after-construct.html	2020-07-16 17:39:21 UTC (rev 264469)
@@ -0,0 +1,72 @@
+<!doctype html>
+<title>Test AudioContext state updates with suspend() shortly after
+  construction</title>
+<script src=""
+<script src=""
+<script>
+// A separate async_test is used for tracking state change counts so that it
+// can report excess changes after the promise_test for the iteration has
+// completed.
+const changeCountingTest = async_test('State change counting');
+
+const doTest = async (testCount) => {
+  const ctx = new AudioContext();
+  // Explicitly resume to get a promise to indicate whether the context
+  // successfully started running.
+  const resume = ctx.resume();
+  const suspend = ctx.suspend();
+  let stateChangesDone = new Promise((resolve) => {
+    ctx._onstatechange_ = () => {
+      ++ctx.stateChangeCount;
+      changeCountingTest.step(() => {
+        assert_less_than_equal(ctx.stateChangeCount,
+                               ctx.expectedStateChangeCount,
+                               `ctx ${testCount} state change count.`);
+        assert_equals(ctx.state, ctx.expectedState, `ctx ${testCount} state`);
+      });
+      if (ctx.stateChangeCount == ctx.totalStateChangeCount) {
+        resolve();
+      }
+    };
+  });
+  ctx.stateChangeCount = 0;
+  ctx.expectedStateChangeCount = 1;
+  ctx.expectedState = 'running';
+  ctx.totalStateChangeCount = 2;
+  let resumeState = 'pending';
+  resume.then(() => {
+    resumeState = 'fulfilled';
+    assert_equals(ctx.state, 'running', 'state on resume fulfilled.');
+  }).catch(() => {
+    // The resume() promise may be rejected if "Attempt to acquire system
+    // resources" fails.  The spec does not discuss the possibility of a
+    // subsequent suspend causing such a failure, but accept this as a
+    // reasonable behavior.
+    resumeState = 'rejected';
+    assert_equals(ctx.state, 'suspended', 'state on resume rejected.');
+    assert_equals(ctx.stateChangeCount, 0);
+    ctx.expectedStateChangeCount = 0;
+    stateChangesDone = Promise.resolve();
+  });
+  suspend.then(() => {
+    assert_not_equals(resumeState, 'pending',
+                      'resume promise should settle before suspend promise.')
+    if (resumeState == 'fulfilled') {
+      ++ctx.expectedStateChangeCount;
+    }
+    ctx.expectedState = 'suspended';
+    assert_equals(ctx.state, 'suspended', 'state on suspend fulfilled.');
+  });
+  await resume;
+  await suspend;
+  await stateChangesDone;
+};
+
+// Repeat the test because Gecko uses different code when there is more than
+// one AudioContext.  The third run provides time to check that no further
+// state changes from the second run are pending.
+for (const testCount of [1, 2, 3]) {
+  promise_test(() => { return doTest(testCount); }, `Iteration ${testCount}`);
+}
+promise_test(async () => changeCountingTest.done(), 'Stop waiting');
+</script>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/w3c-import.log (264468 => 264469)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/w3c-import.log	2020-07-16 17:25:51 UTC (rev 264468)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/w3c-import.log	2020-07-16 17:39:21 UTC (rev 264469)
@@ -18,3 +18,5 @@
 /LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/audiocontext-getoutputtimestamp.html
 /LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/audiocontext-suspend-resume.html
 /LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/audiocontextoptions.html
+/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/processing-after-resume.https.html
+/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/suspend-after-construct.html

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletprocessor-process-frozen-array.https-expected.txt (0 => 264469)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletprocessor-process-frozen-array.https-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletprocessor-process-frozen-array.https-expected.txt	2020-07-16 17:39:21 UTC (rev 264469)
@@ -0,0 +1,9 @@
+
+PASS # AUDIT TASK RUNNER STARTED. 
+FAIL Executing "check-frozen-array" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'context.audioWorklet.addModule')"
+FAIL Executing "transfer-frozen-array" promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: ConstantSourceNode"
+PASS Audit report 
+PASS > [check-frozen-array]  
+PASS > [transfer-frozen-array]  
+PASS # AUDIT TASK RUNNER FINISHED: 2 tasks ran successfully. 
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletprocessor-process-frozen-array.https.html (0 => 264469)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletprocessor-process-frozen-array.https.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletprocessor-process-frozen-array.https.html	2020-07-16 17:39:21 UTC (rev 264469)
@@ -0,0 +1,53 @@
+<!doctype html>
+<html>
+  <head>
+    <title>
+      Test given arrays within AudioWorkletProcessor.process() method
+    </title>
+    <script src=""
+    <script src=""
+    <script src=""
+  </head>
+
+  <body>
+    <script>
+      const audit = Audit.createTaskRunner();
+      const filePath = 'processors/array-check-processor.js';
+      const context = new AudioContext();
+
+      // Test if the incoming arrays are frozen as expected.
+      audit.define('check-frozen-array', (task, should) => {
+        context.audioWorklet.addModule(filePath).then(() => {
+          const workletNode =
+              new AudioWorkletNode(context, 'array-frozen-processor');
+          workletNode.port._onmessage_ = (message) => {
+            const actual = message.data;
+            should(actual.isInputFrozen, '|inputs| is frozen').beTrue();
+            should(actual.isOutputFrozen, '|outputs| is frozen').beTrue();
+            task.done();
+          };
+        });
+      });
+
+      // The incoming arrays should not be transferred, but the associated
+      // ArrayBuffers can be transferred. See the `array-transfer-processor`
+      // definition for the details.
+      audit.define('transfer-frozen-array', (task, should) => {
+        const sourceNode = new ConstantSourceNode(context);
+        const workletNode =
+            new AudioWorkletNode(context, 'array-transfer-processor');
+        workletNode.port._onmessage_ = (message) => {
+          const actual = message.data;
+          if (actual.type === 'assertion')
+            should(actual.success, actual.message).beTrue();
+          if (actual.done)
+            task.done();
+        };
+        sourceNode.connect(workletNode);
+        sourceNode.start();
+      });
+
+      audit.run();
+    </script>
+  </body>
+</html>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletprocessor-process-zero-outputs.https-expected.txt (0 => 264469)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletprocessor-process-zero-outputs.https-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletprocessor-process-zero-outputs.https-expected.txt	2020-07-16 17:39:21 UTC (rev 264469)
@@ -0,0 +1,7 @@
+
+PASS # AUDIT TASK RUNNER STARTED. 
+FAIL Executing "check-zero-outputs" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'context.audioWorklet.addModule')"
+PASS Audit report 
+PASS > [check-zero-outputs]  
+PASS # AUDIT TASK RUNNER FINISHED: 1 tasks ran successfully. 
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletprocessor-process-zero-outputs.https.html (0 => 264469)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletprocessor-process-zero-outputs.https.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletprocessor-process-zero-outputs.https.html	2020-07-16 17:39:21 UTC (rev 264469)
@@ -0,0 +1,36 @@
+<!doctype html>
+<html>
+  <head>
+    <title>
+      Test if |outputs| argument is all zero in AudioWorkletProcessor.process()
+    </title>
+    <script src=""
+    <script src=""
+    <script src=""
+  </head>
+
+  <body>
+    <script>
+      const audit = Audit.createTaskRunner();
+      const filePath = 'processors/zero-outputs-check-processor.js';
+      const context = new AudioContext();
+
+      // Test if the incoming arrays are frozen as expected.
+      audit.define('check-zero-outputs', (task, should) => {
+        context.audioWorklet.addModule(filePath).then(() => {
+          const workletNode =
+              new AudioWorkletNode(context, 'zero-outputs-check-processor');
+          workletNode.port._onmessage_ = (message) => {
+            const actual = message.data;
+            if (actual.type === 'assertion') {
+              should(actual.success, actual.message).beTrue();
+              task.done();
+            }
+          };
+        });
+      });
+
+      audit.run();
+    </script>
+  </body>
+</html>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/array-check-processor.js (0 => 264469)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/array-check-processor.js	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/array-check-processor.js	2020-07-16 17:39:21 UTC (rev 264469)
@@ -0,0 +1,94 @@
+/**
+ * @class ArrayFrozenProcessor
+ * @extends AudioWorkletProcessor
+ */
+class ArrayFrozenProcessor extends AudioWorkletProcessor {
+  constructor() {
+    super();
+    this._messageSent = false;
+  }
+
+  process(inputs, outputs, parameters) {
+    const input = inputs[0];
+    const output = outputs[0];
+
+    if (!this._messageSent) {
+      this.port.postMessage({
+        inputLength: input.length,
+        isInputFrozen: Object.isFrozen(inputs) && Object.isFrozen(input),
+        outputLength: output.length,
+        isOutputFrozen: Object.isFrozen(outputs) && Object.isFrozen(output)
+      });
+      this._messageSent = true;
+    }
+
+    return false;
+  }
+}
+
+/**
+ * @class ArrayTransferProcessor
+ * @extends AudioWorkletProcessor
+ */
+class ArrayTransferProcessor extends AudioWorkletProcessor {
+  constructor() {
+    super();
+    this._messageSent = false;
+  }
+
+  process(inputs, outputs, parameters) {
+    const input = inputs[0];
+    const output = outputs[0];
+
+    if (!this._messageSent) {
+      try {
+        // Transferring Array objects should NOT work.
+        this.port.postMessage({
+          inputs, input, inputChannel: input[0],
+          outputs, output, outputChannel: output[0]
+        }, [inputs, input, inputs[0], outputs, output, output[0]]);
+        // Hence, the following must NOT be reached.
+        this.port.postMessage({
+          type: 'assertion',
+          success: false,
+          message: 'Transferring inputs/outputs, an individual input/output ' +
+              'array, or a channel Float32Array MUST fail, but succeeded.'
+        });
+      } catch (error) {
+        this.port.postMessage({
+          type: 'assertion',
+          success: true,
+          message: 'Transferring inputs/outputs, an individual input/output ' +
+              'array, or a channel Float32Array is not allowed as expected.'
+        });
+      }
+
+      try {
+        // Transferring ArrayBuffers should work.
+        this.port.postMessage(
+          {inputChannel: input[0], outputChannel: output[0]},
+          [input[0].buffer, output[0].buffer]);
+        this.port.postMessage({
+          type: 'assertion',
+          success: true,
+          message: 'Transferring ArrayBuffers was successful as expected.'
+        });
+      } catch (error) {
+        // This must NOT be reached.
+        this.port.postMessage({
+          type: 'assertion',
+          success: false,
+          message: 'Transferring ArrayBuffers unexpectedly failed.'
+        });
+      }
+
+      this.port.postMessage({done: true});
+      this._messageSent = true;
+    }
+
+    return false;
+  }
+}
+
+registerProcessor('array-frozen-processor', ArrayFrozenProcessor);
+registerProcessor('array-transfer-processor', ArrayTransferProcessor);

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/port-processor.js (264468 => 264469)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/port-processor.js	2020-07-16 17:25:51 UTC (rev 264468)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/port-processor.js	2020-07-16 17:39:21 UTC (rev 264469)
@@ -10,18 +10,23 @@
     this.port._onmessage_ = this.handleMessage.bind(this);
     this.port.postMessage({
       state: 'created',
-      timeStamp: currentTime
+      timeStamp: currentTime,
+      currentFrame: currentFrame
     });
+    this.processCallCount = 0;
   }
 
   handleMessage(event) {
     this.port.postMessage({
       message: event.data,
-      timeStamp: currentTime
+      timeStamp: currentTime,
+      currentFrame: currentFrame,
+      processCallCount: this.processCallCount
     });
   }
 
   process() {
+    ++this.processCallCount;
     return true;
   }
 }

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/w3c-import.log (264468 => 264469)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/w3c-import.log	2020-07-16 17:25:51 UTC (rev 264468)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/w3c-import.log	2020-07-16 17:39:21 UTC (rev 264469)
@@ -16,6 +16,7 @@
 List of files:
 /LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/active-processing.js
 /LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/add-offset.js
+/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/array-check-processor.js
 /LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/channel-count-processor.js
 /LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/construction-port-new-after-new.js
 /LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/construction-port-new-after-super.js
@@ -37,3 +38,4 @@
 /LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/sharedarraybuffer-processor.js
 /LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/timing-info-processor.js
 /LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/zero-output-processor.js
+/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/zero-outputs-check-processor.js

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/zero-outputs-check-processor.js (0 => 264469)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/zero-outputs-check-processor.js	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/processors/zero-outputs-check-processor.js	2020-07-16 17:39:21 UTC (rev 264469)
@@ -0,0 +1,78 @@
+/**
+ * Returns true if a given AudioPort is completely filled with zero samples.
+ * "AudioPort" is a short-hand for FrozenArray<FrozenArray<Float32Array>>.
+ *
+ * @param {FrozenArray<FrozenArray<Float32Array>>} audioPort
+ * @returns bool
+ */
+function IsAllZero(audioPort) {
+  for (let busIndex = 0; busIndex < audioPort.length; ++busIndex) {
+    const audioBus = audioPort[busIndex];
+    for (let channelIndex = 0; channelIndex < audioBus.length; ++channelIndex) {
+      const audioChannel = audioBus[channelIndex];
+      for (let sample = 0; sample < audioChannel.length; ++sample) {
+        if (audioChannel[sample] != 0)
+          return false;
+      }
+    }
+  }
+  return true;
+}
+
+const kRenderQuantumFrames = 128;
+const kTestLengthInSec = 1.0;
+const kPulseDuration = 100;
+
+/**
+ * Checks the |outputs| argument of AudioWorkletProcessor.process() and
+ * send a message to an associated AudioWorkletNode. It needs to be all zero
+ * at all times.
+ *
+ * @class ZeroOutputsCheckProcessor
+ * @extends {AudioWorkletProcessor}
+ */
+class ZeroOutputsCheckProcessor extends AudioWorkletProcessor {
+  constructor() {
+    super();
+    this.startTime = currentTime;
+    this.counter = 0;
+  }
+
+  process(inputs, outputs) {
+    if (!IsAllZero(outputs)) {
+      this.port.postMessage({
+        type: 'assertion',
+        success: false,
+        message: 'Unexpected Non-zero sample found in |outputs|.'
+      });
+      return false;
+    }
+
+    if (currentTime - this.startTime >= kTestLengthInSec) {
+      this.port.postMessage({
+        type: 'assertion',
+        success: true,
+        message: `|outputs| has been all zeros for ${kTestLengthInSec} ` +
+            'seconds as expected.'
+      });
+      return false;
+    }
+
+    // Every ~0.25 second (100 render quanta), switch between outputting white
+    // noise and just exiting without doing anything. (from crbug.com/1099756)
+    this.counter++;
+    if (Math.floor(this.counter / kPulseDuration) % 2 == 0)
+      return true;
+
+    let output = outputs[0];
+    for (let channel = 0; channel < output.length; ++channel) {
+      for (let sample = 0; sample < 128; sample++) {
+        output[channel][sample] = 0.1 * (Math.random() - 0.5);
+      }
+    }
+
+    return true;
+  }
+}
+
+registerProcessor('zero-outputs-check-processor', ZeroOutputsCheckProcessor);

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/suspended-context-messageport.https.html (264468 => 264469)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/suspended-context-messageport.https.html	2020-07-16 17:25:51 UTC (rev 264468)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/suspended-context-messageport.https.html	2020-07-16 17:39:21 UTC (rev 264469)
@@ -3,13 +3,13 @@
 <script src=""
 <script src=""
 <script>
-const get_node_and_message = async (context) => {
+const get_node_and_message = (context) => {
   const node = new AudioWorkletNode(context, 'port-processor');
   return new Promise((resolve) => {
     node.port._onmessage_ = (event) => resolve({node: node, event: event});
   });
 };
-const ping_for_message = async (node) => {
+const ping_for_message = (node) => {
   return new Promise((resolve) => {
     node.port._onmessage_ = resolve;
     node.port.postMessage('ping');

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/w3c-import.log (264468 => 264469)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/w3c-import.log	2020-07-16 17:25:51 UTC (rev 264468)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/w3c-import.log	2020-07-16 17:39:21 UTC (rev 264469)
@@ -32,6 +32,8 @@
 /LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-onerror.https.html
 /LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-output-channel-count.https.html
 /LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletprocessor-options.https.html
+/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletprocessor-process-frozen-array.https.html
+/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletprocessor-process-zero-outputs.https.html
 /LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/audioworkletprocessor-promises.https.html
 /LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/baseaudiocontext-audioworklet.https.html
 /LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audioworklet-interface/process-getter.https.html

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/convolver-response-1-chan.html (264468 => 264469)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/convolver-response-1-chan.html	2020-07-16 17:25:51 UTC (rev 264468)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/convolver-response-1-chan.html	2020-07-16 17:39:21 UTC (rev 264469)
@@ -191,11 +191,16 @@
             description: '5.1->2 explicit downmix producing 2-channel output'
           },
           (task, should) => {
+            // Scale tolerance by maximum amplitude expected in down-mix
+            // output.
+            let threshold = (1.0 + Math.sqrt(0.5) * 2) * absoluteThreshold;
+
             downMixTest(
                 {
                   channelCountMode: 'explicit',
                   numberOfInputs: 6,
-                  prefix: '5.1 chan downmix explicit'
+                  prefix: '5.1 chan downmix explicit',
+                  absoluteThreshold: threshold
                 },
                 should)
                 .then(() => task.done());
@@ -219,11 +224,11 @@
                   should(out0.slice(1), '1->2 explicit upmix: channel 0')
                       .beCloseToArray(
                           input.slice(0, length - 1),
-                          {absoluteThreshold: 3.577e-7});
+                          {absoluteThreshold: absoluteThreshold});
                   should(out1.slice(1), '1->2 explicit upmix: channel 1')
                       .beCloseToArray(
                           input.slice(0, length - 1),
-                          {absoluteThreshold: 3.577e-7});
+                          {absoluteThreshold: absoluteThreshold});
                 })
                 .then(() => task.done());
           });
@@ -247,7 +252,7 @@
                   should(out0.slice(1), '1->2 clamped-max upmix: channel 0')
                       .beCloseToArray(
                           input.slice(0, length - 1),
-                          {absoluteThreshold: 3.577e-7});
+                          {absoluteThreshold: absoluteThreshold});
                   should(out1, '1->2 clamped-max upmix: channel 1')
                       .beConstantValueOf(0);
                 })

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/convolver-response-2-chan-expected.txt (264468 => 264469)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/convolver-response-2-chan-expected.txt	2020-07-16 17:25:51 UTC (rev 264468)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/convolver-response-2-chan-expected.txt	2020-07-16 17:39:21 UTC (rev 264469)
@@ -21,8 +21,8 @@
 PASS > [4-channel input] 4->2 downmix producing 2-channel output 
 PASS > [5.1-channel input] 5.1->2 downmix producing 2-channel output 
 PASS > [2-channel input, explicit mode] produces 2-channel output 
-PASS > [3-channel input explicit mode] 3->2 downmix producing 2-channel output 
-PASS > [4-channel input explicit mode] 4->2 downmix producing 2-channel output 
-PASS > [5.1-channel input explicit mode] 5.1->2 downmix producing 2-channel output 
+PASS > [3-channel input explicit mode] 3->1 downmix producing 2-channel output 
+PASS > [4-channel input explicit mode] 4->1 downmix producing 2-channel output 
+PASS > [5.1-channel input explicit mode] 5.1->1 downmix producing 2-channel output 
 FAIL # AUDIT TASK RUNNER FINISHED: 1 out of 10 tasks were failed. assert_true: expected true got false
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/convolver-response-2-chan.html (264468 => 264469)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/convolver-response-2-chan.html	2020-07-16 17:25:51 UTC (rev 264468)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/convolver-response-2-chan.html	2020-07-16 17:39:21 UTC (rev 264469)
@@ -116,8 +116,7 @@
             stereoResponseExplicitTest(
                 {
                   numberOfInputes: 2,
-                  prefix: '2-in explicit mode',
-                  absoluteThresholds: [0, 0]
+                  prefix: '2-in explicit mode'
                 },
                 should)
                 .then(() => task.done());
@@ -126,14 +125,13 @@
       audit.define(
           {
             label: '3-channel input explicit mode',
-            description: '3->2 downmix producing 2-channel output'
+            description: '3->1 downmix producing 2-channel output'
           },
           (task, should) => {
             stereoResponseExplicitTest(
                 {
                   numberOfInputs: 3,
-                  prefix: '3-in explicit',
-                  absoluteThresholds: [0, 0]
+                  prefix: '3-in explicit'
                 },
                 should)
                 .then(() => task.done());
@@ -142,14 +140,13 @@
       audit.define(
           {
             label: '4-channel input explicit mode',
-            description: '4->2 downmix producing 2-channel output'
+            description: '4->1 downmix producing 2-channel output'
           },
           (task, should) => {
             stereoResponseExplicitTest(
                 {
                   numberOfInputs: 4,
-                  prefix: '4-in explicit',
-                  absoluteThresholds: [3.5763e-7, 2.9803e-7]
+                  prefix: '4-in explicit'
                 },
                 should)
                 .then(() => task.done());
@@ -158,11 +155,20 @@
       audit.define(
           {
             label: '5.1-channel input explicit mode',
-            description: '5.1->2 downmix producing 2-channel output'
+            description: '5.1->1 downmix producing 2-channel output'
           },
           (task, should) => {
-            stereoResponseTest({numberOfInputs: 6, prefix: '5.1-in explicit', absoluteThresholds:
-            [0, 0]}, should)
+            // Scale tolerance by maximum amplitude expected in down-mix
+            // output.
+            let threshold = (Math.sqrt(0.5) * 2 + 2.0) * absoluteThreshold;
+
+            stereoResponseExplicitTest(
+                {
+                  numberOfInputs: 6,
+                  prefix: '5.1-in explicit',
+                  absoluteThreshold: threshold
+                },
+                should)
                 .then(() => task.done());
           });
 
@@ -349,16 +355,15 @@
           let expected0 = audioBuffer.getChannelData(2);
           let expected1 = audioBuffer.getChannelData(3);
 
+          let threshold = options.absoluteThreshold ?
+              options.absoluteThreshold : absoluteThreshold;
+
           // Verify that each output channel of the convolver matches
           // the delayed signal from the reference
           should(actual0, options.prefix + ': Channel 0')
-              .beCloseToArray(
-                  expected0,
-                  {absoluteThreshold: options.absoluteThresholds[0]});
+              .beCloseToArray(expected0, {absoluteThreshold: threshold});
           should(actual1, options.prefix + ': Channel 1')
-              .beCloseToArray(
-                  expected1,
-                  {absoluteThreshold: options.absoluteThresholds[1]});
+              .beCloseToArray(expected1, {absoluteThreshold: threshold});
         });
       }
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-delaynode-interface/no-dezippering.html (264468 => 264469)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-delaynode-interface/no-dezippering.html	2020-07-16 17:25:51 UTC (rev 264468)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-delaynode-interface/no-dezippering.html	2020-07-16 17:39:21 UTC (rev 264469)
@@ -93,7 +93,8 @@
       audit.define(
           {label: 'test1', description: 'Test value setter and setValueAtTime'},
           (task, should) => {
-            testWithAutomation(should, {prefix: ''}).then(() => task.done());
+            testWithAutomation(should, {prefix: '', threshold: 6.5819e-5})
+                .then(() => task.done());
           });
 
       audit.define(
@@ -168,7 +169,8 @@
           let expected = renderedBuffer.getChannelData(1);
 
           let match = should(actual, prefix + '.value setter output')
-                          .beEqualToArray(expected);
+                          .beCloseToArray(
+                              expected, {absoluteThreshold: options.threshold});
           should(
               match,
               prefix + '.value setter output matches setValueAtTime output')
@@ -177,7 +179,6 @@
       }
 
       audit.run();
-
     </script>
   </body>
 </html>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/osc-basic-waveform-expected.txt (0 => 264469)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/osc-basic-waveform-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/osc-basic-waveform-expected.txt	2020-07-16 17:39:21 UTC (rev 264469)
@@ -0,0 +1,17 @@
+
+PASS # AUDIT TASK RUNNER STARTED. 
+FAIL Executing "Test 0" promise_test: Unhandled rejection with value: object "TypeError: Not enough arguments"
+FAIL Executing "Test 1" promise_test: Unhandled rejection with value: object "TypeError: Not enough arguments"
+FAIL Executing "Test 2" promise_test: Unhandled rejection with value: object "TypeError: Not enough arguments"
+FAIL Executing "Test 3" promise_test: Unhandled rejection with value: object "TypeError: Not enough arguments"
+FAIL Executing "Test 4" promise_test: Unhandled rejection with value: object "TypeError: Not enough arguments"
+FAIL Executing "Test 5" promise_test: Unhandled rejection with value: object "TypeError: Not enough arguments"
+PASS Audit report 
+PASS > [Test 0] Sine wave: 100 Hz 
+PASS > [Test 1] Sine wave: -100 Hz 
+PASS > [Test 2] Sine wave: 2 Hz 
+PASS > [Test 3] Sine wave: 1 Hz 
+PASS > [Test 4] Custom wave: 100 Hz 
+PASS > [Test 5] Custom wave: 1 Hz 
+PASS # AUDIT TASK RUNNER FINISHED: 6 tasks ran successfully. 
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/osc-basic-waveform.html (0 => 264469)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/osc-basic-waveform.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/osc-basic-waveform.html	2020-07-16 17:39:21 UTC (rev 264469)
@@ -0,0 +1,229 @@
+<!doctype html>
+<html>
+  <head>
+    <title>
+      Test Basic Oscillator Sine Wave Test
+    </title>
+    <script src=""
+    <script src=""
+    <script src=""
+    <script src=""
+  </head>
+
+  <body>
+    <script>
+      // Don't change the sample rate.  The tests below depend on this sample
+      // rate to cover all the cases in Chrome's implementation.  But the tests
+      // are general and apply to any browser.
+      const sampleRate = 44100;
+
+      // Only need a few samples for testing, so just use two renders.
+      const durationFrames = 2 * RENDER_QUANTUM_FRAMES;
+
+      let audit = Audit.createTaskRunner();
+
+      // The following tests verify that the oscillator produces the same
+      // results as the mathematical oscillators.  We choose sine wave and a
+      // custom wave because we know they're bandlimited and won't change with
+      // the frequency.
+      //
+      // The tests for 1 and 2 Hz are intended to test Chrome's interpolation
+      // algorithm, but are still generally applicable to any browser.
+
+      audit.define(
+          {label: 'Test 0', description: 'Sine wave: 100 Hz'},
+          async (task, should) => {
+            let context = new OfflineAudioContext(
+                {length: durationFrames, sampleRate: sampleRate});
+
+            const freqHz = 100;
+
+            let src =
+                new OscillatorNode(context, {type: 'sine', frequency: freqHz});
+            src.connect(context.destination);
+
+            src.start();
+
+            let renderedBuffer = await context.startRendering();
+            checkResult(should, renderedBuffer, context, {
+              freqHz: freqHz,
+              a1: 0,
+              b1: 1,
+              prefix: 'Sine',
+              threshold: 1.8045e-6,
+              snrThreshold: 118.91
+            });
+            task.done();
+          });
+
+      audit.define(
+          {label: 'Test 1', description: 'Sine wave: -100 Hz'},
+          async (task, should) => {
+            let context = new OfflineAudioContext(
+                {length: durationFrames, sampleRate: sampleRate});
+
+            const freqHz = -100;
+
+            let src =
+                new OscillatorNode(context, {type: 'sine', frequency: freqHz});
+            src.connect(context.destination);
+
+            src.start();
+
+            let renderedBuffer = await context.startRendering();
+            checkResult(should, renderedBuffer, context, {
+              freqHz: freqHz,
+              a1: 0,
+              b1: 1,
+              prefix: 'Sine',
+              threshold: 4.7684e-7,
+              snrThreshold: 130.95
+            });
+            task.done();
+          });
+
+      audit.define(
+          {label: 'Test 2', description: 'Sine wave: 2 Hz'},
+          async (task, should) => {
+            let context = new OfflineAudioContext(
+                {length: durationFrames, sampleRate: sampleRate});
+
+            const freqHz = 2;
+
+            let src =
+                new OscillatorNode(context, {type: 'sine', frequency: freqHz});
+            src.connect(context.destination);
+
+            src.start();
+
+            let renderedBuffer = await context.startRendering();
+            checkResult(should, renderedBuffer, context, {
+              freqHz: freqHz,
+              a1: 0,
+              b1: 1,
+              prefix: 'Sine',
+              threshold: 1.4516e-7,
+              snrThreshold: 119.93
+            });
+            task.done();
+          });
+
+      audit.define(
+          {label: 'Test 3', description: 'Sine wave: 1 Hz'},
+          async (task, should) => {
+            let context = new OfflineAudioContext(
+                {length: durationFrames, sampleRate: sampleRate});
+
+            const freqHz = 1;
+
+            let src =
+                new OscillatorNode(context, {type: 'sine', frequency: freqHz});
+            src.connect(context.destination);
+
+            src.start();
+
+            let renderedBuffer = await context.startRendering();
+            checkResult(should, renderedBuffer, context, {
+              freqHz: freqHz,
+              a1: 0,
+              b1: 1,
+              prefix: 'Sine',
+              threshold: 1.4157e-7,
+              snrThreshold: 112.22
+            });
+            task.done();
+          });
+
+      audit.define(
+          {label: 'Test 4', description: 'Custom wave: 100 Hz'},
+          async (task, should) => {
+            let context = new OfflineAudioContext(
+                {length: durationFrames, sampleRate: sampleRate});
+
+            const freqHz = 100;
+
+            let wave = new PeriodicWave(
+                context,
+                {real: [0, 1], imag: [0, 1], disableNormalization: true});
+            let src = "" OscillatorNode(
+                context,
+                {type: 'custom', frequency: freqHz, periodicWave: wave});
+            src.connect(context.destination);
+
+            src.start();
+
+            let renderedBuffer = await context.startRendering();
+            checkResult(should, renderedBuffer, context, {
+              freqHz: freqHz,
+              a1: 1,
+              b1: 1,
+              prefix: 'Custom',
+              threshold: 1.8478e-6,
+              snrThreshold: 122.43
+            });
+            task.done();
+          });
+
+      audit.define(
+          {label: 'Test 5', description: 'Custom wave: 1 Hz'},
+          async (task, should) => {
+            let context = new OfflineAudioContext(
+                {length: durationFrames, sampleRate: sampleRate});
+
+            const freqHz = 1;
+
+            let wave = new PeriodicWave(
+                context,
+                {real: [0, 1], imag: [0, 1], disableNormalization: true});
+            let src = "" OscillatorNode(
+                context,
+                {type: 'custom', frequency: freqHz, periodicWave: wave});
+            src.connect(context.destination);
+
+            src.start();
+
+            let renderedBuffer = await context.startRendering();
+            checkResult(should, renderedBuffer, context, {
+              freqHz: freqHz,
+              a1: 1,
+              b1: 1,
+              prefix: 'Custom',
+              threshold: 4.7684e-7,
+              snrThreshold: 138.76
+            });
+            task.done();
+          });
+
+      audit.run();
+
+      function waveForm(context, freqHz, a1, b1, nsamples) {
+        let buffer =
+            new AudioBuffer({length: nsamples, sampleRate: context.sampleRate});
+        let signal = buffer.getChannelData(0);
+        const omega = 2 * Math.PI * freqHz / context.sampleRate;
+        for (let k = 0; k < nsamples; ++k) {
+          signal[k] = a1 * Math.cos(omega * k) + b1 * Math.sin(omega * k);
+        }
+
+        return buffer;
+      }
+
+      function checkResult(should, renderedBuffer, context, options) {
+        let {freqHz, a1, b1, prefix, threshold, snrThreshold} = options;
+
+        let actual = renderedBuffer.getChannelData(0);
+
+        let expected =
+            waveForm(context, freqHz, a1, b1, actual.length).getChannelData(0);
+
+        should(actual, `${prefix}: ${freqHz} Hz`).beCloseToArray(expected, {
+          absoluteThreshold: threshold
+        });
+
+        let snr = 10 * Math.log10(computeSNR(actual, expected));
+
+        should(snr, `${prefix}: SNR (db)`).beGreaterThanOrEqualTo(snrThreshold);
+      }
+    </script>
+  </body>
+</html>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/w3c-import.log (264468 => 264469)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/w3c-import.log	2020-07-16 17:25:51 UTC (rev 264468)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/w3c-import.log	2020-07-16 17:39:21 UTC (rev 264469)
@@ -16,3 +16,4 @@
 List of files:
 /LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/ctor-oscillator.html
 /LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/detune-limiting.html
+/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-oscillatornode-interface/osc-basic-waveform.html
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to