Set input method state when webpage move by history
[framework/web/webkit-efl.git] / LayoutTests / webaudio / biquadfilternode-basic.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../fast/js/resources/js-test-pre.js"></script>
5 <script src="resources/audio-testing.js"></script>
6 </head>
7
8 <body>
9 <div id="description"></div>
10 <div id="console"></div>
11
12 <script>
13 description("Basic tests for BiquadFilterNode.");
14
15 var context = 0;
16
17 function runTest() {
18     if (window.testRunner) {
19         testRunner.dumpAsText();
20         testRunner.waitUntilDone();
21     }
22     
23     window.jsTestIsAsync = true;
24
25     context = new webkitAudioContext();
26     var filter = context.createBiquadFilter();
27    
28     if (filter.numberOfInputs === 1) 
29         testPassed("BiquadFilterNode has one input.");
30     else
31         testFailed("BiquadFilterNode should have one input.");
32     
33     if (filter.numberOfOutputs === 1) 
34         testPassed("BiquadFilterNode has one output.");
35     else
36         testFailed("BiquadFilterNode should have one output.");
37     
38     if (filter.type === "lowpass")
39         testPassed("Biquad filter defaults to low-pass filter.");
40     else
41         testFailed("Biquad filter should default to low-pass filter.");
42
43     // Check that all legal filter types can be set.
44     var filterTypeArray = [{type: "lowpass", integerType: filter.LOWPASS},
45                            {type: "highpass", integerType: filter.HIGHPASS},
46                            {type: "bandpass", integerType: filter.BANDPASS},
47                            {type: "lowshelf", integerType: filter.LOWSHELF},
48                            {type: "highshelf", integerType: filter.HIGHSHELF},
49                            {type: "peaking", integerType: filter.PEAKING},
50                            {type: "notch", integerType: filter.NOTCH},
51                            {type: "allpass", integerType: filter.ALLPASS}];
52
53     for (var i = 0; i < filterTypeArray.length; ++i) {
54         try {
55             filter.type = filterTypeArray[i].type;
56             if (filter.type === filterTypeArray[i].type) {
57                 var message = "Biquad filter type '" + filterTypeArray[i].type + "' is settable.";
58                 testPassed(message);
59             } else {
60                 var message = "Biquad filter type '" + filterTypeArray[i].type + "' was not correctly set.";
61                 testFailed(message);
62             }
63         } catch(e) {
64             var message = "Biquad filter type " + i + " should not throw exception.";
65             testFailed(message);
66         }
67     }
68
69     // For legacy support, verify that we can set the type attribute as an integer value and
70     // verify that this translates correctly to the WebIDL enum value.
71     for (var i = 0; i < filterTypeArray.length; ++i) {
72         try {
73             filter.type = filterTypeArray[i].integerType;
74             if (filter.type === filterTypeArray[i].type && filterTypeArray[i].integerType === i) {
75                 var message = "Biquad filter type " + i + " is settable using legacy integer value.";
76                 testPassed(message);
77             } else {
78                 var message = "Biquad filter type " + i + " was not correctly set using legacy integer value.";
79                 testFailed(message);
80             }
81         } catch(e) {
82             var message = "Biquad filter type " + i + " should not throw exception using legacy integer value.";
83             testFailed(message);
84         }
85     }
86
87     // Check that illegal filter type throws.
88     try {
89         filter.type = filter.ALLPASS + 1;
90         testFailed("Illegal filter type should throw exception.");
91     } catch(e) {
92         testPassed("Illegal filter type correctly throws exception.");
93     }
94
95     // Check specifically that we throw a TypeError.
96     shouldThrowTypeError(function() { filter.type = "xyz12349jfksd"; }, "Setting .type to illegal string value");
97     shouldThrowTypeError(function() { filter.type = new Float32Array(1); }, "Setting .type to illegal type of Float32Array");
98
99     finishJSTest();
100 }
101
102 runTest();
103
104 </script>
105
106 <script src="../fast/js/resources/js-test-post.js"></script>
107 </body>
108 </html>