browser_audionode-actor-get-param-flags.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. /**
  4. * Test AudioNode#getParamFlags()
  5. */
  6. add_task(function* () {
  7. let { target, front } = yield initBackend(SIMPLE_NODES_URL);
  8. let [_, nodes] = yield Promise.all([
  9. front.setup({ reload: true }),
  10. getN(front, "create-node", 15)
  11. ]);
  12. let allNodeParams = yield Promise.all(nodes.map(node => node.getParams()));
  13. let nodeTypes = [
  14. "AudioDestinationNode",
  15. "AudioBufferSourceNode", "ScriptProcessorNode", "AnalyserNode", "GainNode",
  16. "DelayNode", "BiquadFilterNode", "WaveShaperNode", "PannerNode", "ConvolverNode",
  17. "ChannelSplitterNode", "ChannelMergerNode", "DynamicsCompressorNode", "OscillatorNode",
  18. "StereoPannerNode"
  19. ];
  20. // For some reason nodeTypes.forEach and params.forEach fail here so we use
  21. // simple for loops.
  22. for (let i = 0; i < nodeTypes.length; i++) {
  23. let type = nodeTypes[i];
  24. let params = allNodeParams[i];
  25. for (let {param, value, flags} of params) {
  26. let testFlags = yield nodes[i].getParamFlags(param);
  27. ok(typeof testFlags === "object", type + " has flags from #getParamFlags(" + param + ")");
  28. if (param === "buffer") {
  29. is(flags.Buffer, true, "`buffer` params have Buffer flag");
  30. }
  31. else if (param === "bufferSize" || param === "frequencyBinCount") {
  32. is(flags.readonly, true, param + " is readonly");
  33. }
  34. else if (param === "curve") {
  35. is(flags["Float32Array"], true, "`curve` param has Float32Array flag");
  36. }
  37. }
  38. }
  39. yield removeTab(target.tab);
  40. });