browser/devtools/webaudioeditor/test/browser_audionode-actor-get-params.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 /**
michael@0 5 * Test AudioNode#getParams()
michael@0 6 */
michael@0 7
michael@0 8 function spawnTest () {
michael@0 9 let [target, debuggee, front] = yield initBackend(SIMPLE_NODES_URL);
michael@0 10 let [_, nodes] = yield Promise.all([
michael@0 11 front.setup({ reload: true }),
michael@0 12 getN(front, "create-node", 14)
michael@0 13 ]);
michael@0 14
michael@0 15 let allNodeParams = yield Promise.all(nodes.map(node => node.getParams()));
michael@0 16 let nodeTypes = [
michael@0 17 "AudioDestinationNode",
michael@0 18 "AudioBufferSourceNode", "ScriptProcessorNode", "AnalyserNode", "GainNode",
michael@0 19 "DelayNode", "BiquadFilterNode", "WaveShaperNode", "PannerNode", "ConvolverNode",
michael@0 20 "ChannelSplitterNode", "ChannelMergerNode", "DynamicsCompressorNode", "OscillatorNode"
michael@0 21 ];
michael@0 22
michael@0 23 nodeTypes.forEach((type, i) => {
michael@0 24 let params = allNodeParams[i];
michael@0 25 params.forEach(({param, value, flags}) => {
michael@0 26 ok(~NODE_PROPERTIES[type].indexOf(param), "expected parameter for " + type);
michael@0 27
michael@0 28 // Skip over some properties that are undefined by default
michael@0 29 if (!/buffer|loop|smoothing|curve|cone/.test(param)) {
michael@0 30 ok(value != undefined, param + " is not undefined");
michael@0 31 }
michael@0 32
michael@0 33 ok(typeof flags === "object", type + " has a flags object");
michael@0 34
michael@0 35 if (param === "buffer") {
michael@0 36 is(flags.Buffer, true, "`buffer` params have Buffer flag");
michael@0 37 }
michael@0 38 else if (param === "bufferSize" || param === "frequencyBinCount") {
michael@0 39 is(flags.readonly, true, param + " is readonly");
michael@0 40 }
michael@0 41 else if (param === "curve") {
michael@0 42 is(flags["Float32Array"], true, "`curve` param has Float32Array flag");
michael@0 43 } else {
michael@0 44 is(Object.keys(flags), 0, type + "-" + param + " has no flags set")
michael@0 45 }
michael@0 46 });
michael@0 47 });
michael@0 48
michael@0 49 yield removeTab(target.tab);
michael@0 50 finish();
michael@0 51 }

mercurial