4 <script src=
"../resources/js-test.js"></script>
5 <script src=
"resources/compatibility.js"></script>
6 <script src=
"resources/audio-testing.js"></script>
10 <div id=
"description"></div>
11 <div id=
"console"></div>
14 description("Basic tests for PannerNode.");
19 if (window
.testRunner
) {
20 testRunner
.dumpAsText();
21 testRunner
.waitUntilDone();
24 window
.jsTestIsAsync
= true;
26 context
= new AudioContext();
27 var panner
= context
.createPanner();
29 if (panner
.numberOfInputs
=== 1)
30 testPassed("PannerNode has one input.");
32 testFailed("PannerNode should have one input.");
34 if (panner
.numberOfOutputs
=== 1)
35 testPassed("PannerNode has one output.");
37 testFailed("PannerNode should have one output.");
39 if (panner
.refDistance
=== 1)
40 testPassed("refDistance default value is 1.");
42 testFailed("refDistance default value should be 1.");
44 panner
.refDistance
= 270.52
45 if (panner
.refDistance
=== 270.52)
46 testPassed("refDistance value is set to 270.52.");
48 testFailed("refDistance value should be set to 270.52.");
50 if (panner
.maxDistance
=== 10000)
51 testPassed("maxDistance default value is 10000.");
53 testFailed("maxDistance default value should be 10000.");
55 panner
.maxDistance
= 100.55
56 if (panner
.maxDistance
=== 100.55)
57 testPassed("maxDistance value is set to 100.55.");
59 testFailed("maxDistance value should be set to 100.55.");
61 if (panner
.rolloffFactor
=== 1)
62 testPassed("rolloffFactor default value is 1.");
64 testFailed("rolloffFactor default value should be 1.");
66 panner
.rolloffFactor
= 0.83
67 if (panner
.rolloffFactor
=== 0.83)
68 testPassed("rolloffFactor value is set to 0.83.");
70 testFailed("rolloffFactor value should be set to 0.83.");
72 if (panner
.coneInnerAngle
=== 360)
73 testPassed("coneInnerAngle default value is 360.");
75 testFailed("coneInnerAngle default value should be 360.");
77 panner
.coneInnerAngle
= 240.45
78 if (panner
.coneInnerAngle
=== 240.45)
79 testPassed("coneInnerAngle value is set to 240.45.");
81 testFailed("coneInnerAngle value should be set to 240.45.");
83 if (panner
.coneOuterAngle
=== 360)
84 testPassed("coneOuterAngle default value is 360.");
86 testFailed("coneOuterAngle default value should be 360.");
88 panner
.coneOuterAngle
= 166.66
89 if (panner
.coneOuterAngle
=== 166.66)
90 testPassed("coneOuterAngle value is set to 166.66.");
92 testFailed("coneOuterAngle value should be set to 166.66.");
94 if (panner
.coneOuterGain
=== 0)
95 testPassed("coneOuterGain default value is 0.");
97 testFailed("coneOuterGain default value should be 0.");
99 panner
.coneOuterGain
= 0.35
100 if (panner
.coneOuterGain
=== 0.35)
101 testPassed("coneOuterGain value is set to 0.35.");
103 testFailed("coneOuterGain value should be set to 0.35.");
105 if (panner
.panningModel
=== "equalpower")
106 testPassed("PannerNode defaults to 'equalpower' panningModel.");
108 testFailed("PannerNode should default to 'equalpower' panningModel.");
110 if (panner
.distanceModel
=== "inverse")
111 testPassed("PannerNode defaults to 'inverse' distanceModel.");
113 testFailed("PannerNode should default to 'inverse' distanceModel.");
115 // Check that the .panningModel attribute can be set to all legal values.
116 var panningModels
= [{value
: "equalpower", integerValue
: panner
.EQUALPOWER
},
117 {value
: "HRTF", integerValue
: panner
.HRTF
},
120 for (var i
= 0; i
< panningModels
.length
; ++i
) {
122 panner
.panningModel
= panningModels
[i
].value
;
123 if (panner
.panningModel
=== panningModels
[i
].value
) {
124 var message
= "panningModel: '" + panningModels
[i
].value
+ "' is settable.";
127 var message
= "panningModel: '" + panningModels
[i
].value
+ "' was not correctly set.";
131 var message
= "Setting panningModel to '" + panningModels
[i
].value
+ "' should not throw exception.";
136 // Check that numerical values are no longer supported.
137 panner
.panningModel
= "HRTF";
138 panner
.panningModel
= 1;
139 if (panner
.panningModel
== 1) {
140 testFailed("panningModel incorrectly set to " + panner
.panningModel
+ ".");
142 testPassed("panningModel correctly not set to 1.");
145 // Check that the .distanceModel attribute can be set to all legal values.
146 var distanceModels
= [{value
: "linear"},
148 {value
: "exponential"}
151 for (var i
= 0; i
< distanceModels
.length
; ++i
) {
153 panner
.distanceModel
= distanceModels
[i
].value
;
154 if (panner
.distanceModel
=== distanceModels
[i
].value
) {
155 var message
= "distanceModel: '" + distanceModels
[i
].value
+ "' is settable.";
158 var message
= "distanceModel: '" + distanceModels
[i
].value
+ "' was not correctly set.";
162 var message
= "Setting distanceModel to '" + distanceModels
[i
].value
+ "' should not throw exception.";
167 // Check that numerical values are no longer supported.
168 panner
.distanceModel
= "inverse";
169 panner
.distanceModel
= 1;
170 if (panner
.distanceModel
== 1) {
171 testFailed("distanceModel incorrectly set to " + panner
.distanceModel
+ ".");
173 testPassed("distanceModel correctly not set to 1.");