mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-11 16:32:59 +00:00
Bug 1128974 - Fetch default values for AudioNode params instead of hardcoding. r=jsantell
This commit is contained in:
parent
37b9df3be3
commit
1e8acdbc6e
@ -12,6 +12,8 @@ add_task(function*() {
|
||||
getN(front, "create-node", 15)
|
||||
]);
|
||||
|
||||
yield loadFrameScripts();
|
||||
|
||||
let allNodeParams = yield Promise.all(nodes.map(node => node.getParams()));
|
||||
let nodeTypes = [
|
||||
"AudioDestinationNode",
|
||||
@ -21,10 +23,13 @@ add_task(function*() {
|
||||
"StereoPannerNode"
|
||||
];
|
||||
|
||||
nodeTypes.forEach((type, i) => {
|
||||
let defaults = yield Promise.all(nodeTypes.map(type => nodeDefaultValues(type)));
|
||||
|
||||
nodeTypes.map((type, i) => {
|
||||
let params = allNodeParams[i];
|
||||
|
||||
params.forEach(({param, value, flags}) => {
|
||||
ok(param in NODE_DEFAULT_VALUES[type], "expected parameter for " + type);
|
||||
ok(param in defaults[i], "expected parameter for " + type);
|
||||
|
||||
ok(typeof flags === "object", type + " has a flags object");
|
||||
|
||||
|
@ -13,6 +13,8 @@ add_task(function*() {
|
||||
getN(front, "create-node", 15)
|
||||
]);
|
||||
|
||||
yield loadFrameScripts();
|
||||
|
||||
let allParams = yield Promise.all(nodes.map(node => node.getParams()));
|
||||
let types = [
|
||||
"AudioDestinationNode", "AudioBufferSourceNode", "ScriptProcessorNode",
|
||||
@ -21,8 +23,12 @@ add_task(function*() {
|
||||
"DynamicsCompressorNode", "OscillatorNode", "StereoPannerNode"
|
||||
];
|
||||
|
||||
let defaults = yield Promise.all(types.map(type => nodeDefaultValues(type)));
|
||||
|
||||
info(JSON.stringify(defaults));
|
||||
|
||||
allParams.forEach((params, i) => {
|
||||
compare(params, NODE_DEFAULT_VALUES[types[i]], types[i]);
|
||||
compare(params, defaults[i], types[i]);
|
||||
});
|
||||
|
||||
yield removeTab(target.tab);
|
||||
@ -39,6 +45,8 @@ function compare (actual, expected, type) {
|
||||
}
|
||||
});
|
||||
|
||||
info(Object.keys(expected).join(',') + " - " + JSON.stringify(expected));
|
||||
|
||||
is(actual.length, Object.keys(expected).length,
|
||||
type + " has correct amount of properties.");
|
||||
}
|
||||
|
@ -46,6 +46,8 @@ add_task(function*() {
|
||||
|
||||
reload(target);
|
||||
|
||||
yield loadFrameScripts();
|
||||
|
||||
let [actors] = yield Promise.all([
|
||||
getN(gFront, "create-node", 4),
|
||||
waitForGraphRendered(panelWin, 4, 0)
|
||||
@ -57,10 +59,12 @@ add_task(function*() {
|
||||
"MediaStreamAudioSourceNode", "MediaStreamAudioDestinationNode"
|
||||
];
|
||||
|
||||
let defaults = yield Promise.all(types.map(type => nodeDefaultValues(type)));
|
||||
|
||||
for (let i = 0; i < types.length; i++) {
|
||||
click(panelWin, findGraphNode(panelWin, nodeIds[i]));
|
||||
yield waitForInspectorRender(panelWin, EVENTS);
|
||||
checkVariableView(gVars, 0, NODE_DEFAULT_VALUES[types[i]], types[i]);
|
||||
checkVariableView(gVars, 0, defaults[i], types[i]);
|
||||
}
|
||||
|
||||
// Reset permissions on getUserMedia
|
||||
|
@ -16,6 +16,8 @@ add_task(function*() {
|
||||
|
||||
reload(target);
|
||||
|
||||
yield loadFrameScripts();
|
||||
|
||||
let [actors] = yield Promise.all([
|
||||
getN(gFront, "create-node", 15),
|
||||
waitForGraphRendered(panelWin, 15, 0)
|
||||
@ -28,10 +30,12 @@ add_task(function*() {
|
||||
"DynamicsCompressorNode", "OscillatorNode"
|
||||
];
|
||||
|
||||
let defaults = yield Promise.all(types.map(type => nodeDefaultValues(type)));
|
||||
|
||||
for (let i = 0; i < types.length; i++) {
|
||||
click(panelWin, findGraphNode(panelWin, nodeIds[i]));
|
||||
yield waitForInspectorRender(panelWin, EVENTS);
|
||||
checkVariableView(gVars, 0, NODE_DEFAULT_VALUES[types[i]], types[i]);
|
||||
checkVariableView(gVars, 0, defaults[i], types[i]);
|
||||
}
|
||||
|
||||
yield teardown(target);
|
||||
|
@ -20,6 +20,7 @@ let { generateUUID } = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUID
|
||||
|
||||
let { WebAudioFront } = devtools.require("devtools/server/actors/webaudio");
|
||||
let TargetFactory = devtools.TargetFactory;
|
||||
let audioNodes = devtools.require("devtools/server/actors/utils/audionodes.json");
|
||||
let mm = null;
|
||||
|
||||
const FRAME_SCRIPT_UTILS_URL = "chrome://browser/content/devtools/frame-script-utils.js";
|
||||
@ -130,6 +131,15 @@ function navigate(aTarget, aUrl, aWaitForTargetEvent = "navigate") {
|
||||
return once(aTarget, aWaitForTargetEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call manually in tests that use frame script utils after initializing
|
||||
* the shader editor. Call after init but before navigating to different pages.
|
||||
*/
|
||||
function loadFrameScripts () {
|
||||
mm = gBrowser.selectedBrowser.messageManager;
|
||||
mm.loadFrameScript(FRAME_SCRIPT_UTILS_URL, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new tab, and instantiate a WebAudiFront object.
|
||||
* This requires calling removeTab before the test ends.
|
||||
@ -483,80 +493,51 @@ function evalInDebuggee (script) {
|
||||
}
|
||||
|
||||
/**
|
||||
* List of audio node properties to test against expectations of the AudioNode actor
|
||||
* Takes an AudioNode type and returns it's properties (from audionode.json)
|
||||
* as keys and their default values as keys
|
||||
*/
|
||||
function nodeDefaultValues(nodeName) {
|
||||
let fn = NODE_CONSTRUCTORS[nodeName];
|
||||
|
||||
const NODE_DEFAULT_VALUES = {
|
||||
"AudioDestinationNode": {},
|
||||
"MediaElementAudioSourceNode": {},
|
||||
"MediaStreamAudioSourceNode": {},
|
||||
"MediaStreamAudioDestinationNode": {
|
||||
"stream": "MediaStream"
|
||||
},
|
||||
"AudioBufferSourceNode": {
|
||||
"playbackRate": 1,
|
||||
"loop": false,
|
||||
"loopStart": 0,
|
||||
"loopEnd": 0,
|
||||
"buffer": null
|
||||
},
|
||||
"ScriptProcessorNode": {
|
||||
"bufferSize": 4096
|
||||
},
|
||||
"AnalyserNode": {
|
||||
"fftSize": 2048,
|
||||
"minDecibels": -100,
|
||||
"maxDecibels": -30,
|
||||
"smoothingTimeConstant": 0.8,
|
||||
"frequencyBinCount": 1024
|
||||
},
|
||||
"GainNode": {
|
||||
"gain": 1
|
||||
},
|
||||
"DelayNode": {
|
||||
"delayTime": 0
|
||||
},
|
||||
"BiquadFilterNode": {
|
||||
"type": "lowpass",
|
||||
"frequency": 350,
|
||||
"Q": 1,
|
||||
"detune": 0,
|
||||
"gain": 0
|
||||
},
|
||||
"WaveShaperNode": {
|
||||
"curve": null,
|
||||
"oversample": "none"
|
||||
},
|
||||
"PannerNode": {
|
||||
"panningModel": "equalpower",
|
||||
"distanceModel": "inverse",
|
||||
"refDistance": 1,
|
||||
"maxDistance": 10000,
|
||||
"rolloffFactor": 1,
|
||||
"coneInnerAngle": 360,
|
||||
"coneOuterAngle": 360,
|
||||
"coneOuterGain": 0
|
||||
},
|
||||
"ConvolverNode": {
|
||||
"buffer": null,
|
||||
"normalize": true
|
||||
},
|
||||
"ChannelSplitterNode": {},
|
||||
"ChannelMergerNode": {},
|
||||
"DynamicsCompressorNode": {
|
||||
"threshold": -24,
|
||||
"knee": 30,
|
||||
"ratio": 12,
|
||||
"reduction": 0,
|
||||
"attack": 0.003000000026077032,
|
||||
"release": 0.25
|
||||
},
|
||||
"OscillatorNode": {
|
||||
"type": "sine",
|
||||
"frequency": 440,
|
||||
"detune": 0
|
||||
},
|
||||
"StereoPannerNode": {
|
||||
"pan": 0
|
||||
}
|
||||
};
|
||||
if(typeof fn === 'undefined') return {};
|
||||
|
||||
let init = nodeName === "AudioDestinationNode" ? "destination" : `create${fn}()`;
|
||||
|
||||
let definition = JSON.stringify(audioNodes[nodeName].properties);
|
||||
|
||||
let evalNode = evalInDebuggee(`
|
||||
let ins = (new AudioContext()).${init};
|
||||
let props = ${definition};
|
||||
let answer = {};
|
||||
|
||||
for(let k in props) {
|
||||
if (props[k].param) {
|
||||
answer[k] = ins[k].defaultValue;
|
||||
} else if (typeof ins[k] === "object" && ins[k] !== null) {
|
||||
answer[k] = ins[k].toString().slice(8, -1);
|
||||
} else {
|
||||
answer[k] = ins[k];
|
||||
}
|
||||
}
|
||||
answer;`);
|
||||
|
||||
return evalNode;
|
||||
}
|
||||
|
||||
const NODE_CONSTRUCTORS = {
|
||||
"MediaStreamAudioDestinationNode": "MediaStreamDestination",
|
||||
"AudioBufferSourceNode": "BufferSource",
|
||||
"ScriptProcessorNode": "ScriptProcessor",
|
||||
"AnalyserNode": "Analyser",
|
||||
"GainNode": "Gain",
|
||||
"DelayNode": "Delay",
|
||||
"BiquadFilterNode": "BiquadFilter",
|
||||
"WaveShaperNode": "WaveShaper",
|
||||
"PannerNode": "Panner",
|
||||
"ConvolverNode": "Convolver",
|
||||
"ChannelSplitterNode": "ChannelSplitter",
|
||||
"ChannelMergerNode": "ChannelMerger",
|
||||
"DynamicsCompressorNode": "DynamicsCompressor",
|
||||
"OscillatorNode": "Oscillator",
|
||||
"StereoPannerNode": "StereoPanner"
|
||||
};
|
@ -53,7 +53,7 @@
|
||||
"threshold": { "param": true },
|
||||
"knee": { "param": true },
|
||||
"ratio": { "param": true },
|
||||
"reduction": {},
|
||||
"reduction": { "param": true },
|
||||
"attack": { "param": true },
|
||||
"release": { "param": true }
|
||||
}
|
||||
@ -101,7 +101,7 @@
|
||||
},
|
||||
"StereoPannerNode": {
|
||||
"properties": {
|
||||
"pan": {}
|
||||
"pan": { "param": true }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user