Wed, 31 Dec 2014 06:09:35 +0100
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#getParam() / AudioNode#setParam() |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | function spawnTest () { |
michael@0 | 9 | let [target, debuggee, front] = yield initBackend(SIMPLE_CONTEXT_URL); |
michael@0 | 10 | let [_, [destNode, oscNode, gainNode]] = yield Promise.all([ |
michael@0 | 11 | front.setup({ reload: true }), |
michael@0 | 12 | get3(front, "create-node") |
michael@0 | 13 | ]); |
michael@0 | 14 | |
michael@0 | 15 | let freq = yield oscNode.getParam("frequency"); |
michael@0 | 16 | info(typeof freq); |
michael@0 | 17 | ise(freq, 440, "AudioNode:getParam correctly fetches AudioParam"); |
michael@0 | 18 | |
michael@0 | 19 | let type = yield oscNode.getParam("type"); |
michael@0 | 20 | ise(type, "sine", "AudioNode:getParam correctly fetches non-AudioParam"); |
michael@0 | 21 | |
michael@0 | 22 | let type = yield oscNode.getParam("not-a-valid-param"); |
michael@0 | 23 | is(type, undefined, "AudioNode:getParam correctly returns false for invalid param"); |
michael@0 | 24 | |
michael@0 | 25 | let resSuccess = yield oscNode.setParam("frequency", 220); |
michael@0 | 26 | let freq = yield oscNode.getParam("frequency"); |
michael@0 | 27 | ise(freq, 220, "AudioNode:setParam correctly sets a `number` AudioParam"); |
michael@0 | 28 | is(resSuccess, undefined, "AudioNode:setParam returns undefined for correctly set AudioParam"); |
michael@0 | 29 | |
michael@0 | 30 | resSuccess = yield oscNode.setParam("type", "square"); |
michael@0 | 31 | let type = yield oscNode.getParam("type"); |
michael@0 | 32 | ise(type, "square", "AudioNode:setParam correctly sets a `string` non-AudioParam"); |
michael@0 | 33 | is(resSuccess, undefined, "AudioNode:setParam returns undefined for correctly set AudioParam"); |
michael@0 | 34 | |
michael@0 | 35 | resSuccess = yield oscNode.setParam("type", "\"triangle\""); |
michael@0 | 36 | type = yield oscNode.getParam("type"); |
michael@0 | 37 | ise(type, "triangle", "AudioNode:setParam correctly removes quotes in `string` non-AudioParam"); |
michael@0 | 38 | |
michael@0 | 39 | try { |
michael@0 | 40 | yield oscNode.setParam("frequency", "hello"); |
michael@0 | 41 | ok(false, "setParam with invalid types should throw"); |
michael@0 | 42 | } catch (e) { |
michael@0 | 43 | ok(/is not a finite floating-point/.test(e.message), "AudioNode:setParam returns error with correct message when attempting an invalid assignment"); |
michael@0 | 44 | is(e.type, "TypeError", "AudioNode:setParam returns error with correct type when attempting an invalid assignment"); |
michael@0 | 45 | freq = yield oscNode.getParam("frequency"); |
michael@0 | 46 | ise(freq, 220, "AudioNode:setParam does not modify value when an error occurs"); |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | yield removeTab(target.tab); |
michael@0 | 50 | finish(); |
michael@0 | 51 | } |