browser/devtools/webaudioeditor/test/browser_audionode-actor-get-set-param.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.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /**
     5  * Test AudioNode#getParam() / AudioNode#setParam()
     6  */
     8 function spawnTest () {
     9   let [target, debuggee, front] = yield initBackend(SIMPLE_CONTEXT_URL);
    10   let [_, [destNode, oscNode, gainNode]] = yield Promise.all([
    11     front.setup({ reload: true }),
    12     get3(front, "create-node")
    13   ]);
    15   let freq = yield oscNode.getParam("frequency");
    16   info(typeof freq);
    17   ise(freq, 440, "AudioNode:getParam correctly fetches AudioParam");
    19   let type = yield oscNode.getParam("type");
    20   ise(type, "sine", "AudioNode:getParam correctly fetches non-AudioParam");
    22   let type = yield oscNode.getParam("not-a-valid-param");
    23   is(type, undefined, "AudioNode:getParam correctly returns false for invalid param");
    25   let resSuccess = yield oscNode.setParam("frequency", 220);
    26   let freq = yield oscNode.getParam("frequency");
    27   ise(freq, 220, "AudioNode:setParam correctly sets a `number` AudioParam");
    28   is(resSuccess, undefined, "AudioNode:setParam returns undefined for correctly set AudioParam");
    30   resSuccess = yield oscNode.setParam("type", "square");
    31   let type = yield oscNode.getParam("type");
    32   ise(type, "square", "AudioNode:setParam correctly sets a `string` non-AudioParam");
    33   is(resSuccess, undefined, "AudioNode:setParam returns undefined for correctly set AudioParam");
    35   resSuccess = yield oscNode.setParam("type", "\"triangle\"");
    36   type = yield oscNode.getParam("type");
    37   ise(type, "triangle", "AudioNode:setParam correctly removes quotes in `string` non-AudioParam");
    39   try {
    40     yield oscNode.setParam("frequency", "hello");
    41     ok(false, "setParam with invalid types should throw");
    42   } catch (e) {
    43     ok(/is not a finite floating-point/.test(e.message), "AudioNode:setParam returns error with correct message when attempting an invalid assignment");
    44     is(e.type, "TypeError", "AudioNode:setParam returns error with correct type when attempting an invalid assignment");
    45     freq = yield oscNode.getParam("frequency");
    46     ise(freq, 220, "AudioNode:setParam does not modify value when an error occurs");
    47   }
    49   yield removeTab(target.tab);
    50   finish();
    51 }

mercurial