Files
firefox/devtools/client/webaudioeditor/test/browser_audionode-actor-get-set-param.js
T
J. Ryan Stinnett 530b903fcf Bug 1271084 - Apply ESLint autofixes to ignored /devtools files. r=tromey
For simple rules like function spacing, we can auto-fix these across the code
base so they are followed in a consistent way.

To generate this patch, I ran:

./mach eslint devtools --no-ignore --fix

After this, I reverted any changes to third party files that we really do want
to ignore.

MozReview-Commit-ID: 6Q8BApkAW20
2016-05-18 12:49:23 -05:00

48 lines
1.9 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Test AudioNode#getParam() / AudioNode#setParam()
*/
add_task(function* () {
let { target, front } = yield initBackend(SIMPLE_CONTEXT_URL);
let [_, [destNode, oscNode, gainNode]] = yield Promise.all([
front.setup({ reload: true }),
get3(front, "create-node")
]);
let freq = yield oscNode.getParam("frequency");
info(typeof freq);
is(freq, 440, "AudioNode:getParam correctly fetches AudioParam");
let type = yield oscNode.getParam("type");
is(type, "sine", "AudioNode:getParam correctly fetches non-AudioParam");
type = yield oscNode.getParam("not-a-valid-param");
ok(type.type === "undefined",
"AudioNode:getParam correctly returns a grip value for `undefined` for an invalid param.");
let resSuccess = yield oscNode.setParam("frequency", 220);
freq = yield oscNode.getParam("frequency");
is(freq, 220, "AudioNode:setParam correctly sets a `number` AudioParam");
is(resSuccess, undefined, "AudioNode:setParam returns undefined for correctly set AudioParam");
resSuccess = yield oscNode.setParam("type", "square");
type = yield oscNode.getParam("type");
is(type, "square", "AudioNode:setParam correctly sets a `string` non-AudioParam");
is(resSuccess, undefined, "AudioNode:setParam returns undefined for correctly set AudioParam");
try {
yield oscNode.setParam("frequency", "hello");
ok(false, "setParam with invalid types should throw");
} catch (e) {
ok(/is not a finite floating-point/.test(e.message), "AudioNode:setParam returns error with correct message when attempting an invalid assignment");
is(e.type, "TypeError", "AudioNode:setParam returns error with correct type when attempting an invalid assignment");
freq = yield oscNode.getParam("frequency");
is(freq, 220, "AudioNode:setParam does not modify value when an error occurs");
}
yield removeTab(target.tab);
});