summaryrefslogtreecommitdiffstats
path: root/devtools/client/webaudioeditor/test/browser_audionode-actor-get-set-param.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /devtools/client/webaudioeditor/test/browser_audionode-actor-get-set-param.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/webaudioeditor/test/browser_audionode-actor-get-set-param.js')
-rw-r--r--devtools/client/webaudioeditor/test/browser_audionode-actor-get-set-param.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/devtools/client/webaudioeditor/test/browser_audionode-actor-get-set-param.js b/devtools/client/webaudioeditor/test/browser_audionode-actor-get-set-param.js
new file mode 100644
index 000000000..0d4c7c5c7
--- /dev/null
+++ b/devtools/client/webaudioeditor/test/browser_audionode-actor-get-set-param.js
@@ -0,0 +1,47 @@
+/* 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);
+});