Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / webaudio / dynamicscompressor-clear-internal-state.html
1 <!doctype html>
2 <html>
3   <head>
4     <title>Validate Reduction Value of DynamicsComporessor after Disabling</title>
5     <script src="resources/compatibility.js"></script>
6     <script src="resources/audio-testing.js"></script>
7     <script src="../resources/js-test.js"></script>
8   </head>
9
10   <body>
11     <script>
12       description("Validate Reduction Value of DynamicsComporessor after Disabling");
13
14       var context;
15       var buffer;
16       var source;
17       var compressor;
18       var renderedData;
19
20       var sampleRate = 44100;
21       var testDurationSamples = 44100;
22
23       function checkResult (event) {
24
25           renderedData = event.renderedBuffer.getChannelData(0);
26
27           // Check that the reduction value is 0.0.
28           if (compressor.reduction.value !== 0.0) {
29               testFailed("Expected reduction of 0.0, but the value is " + compressor.reduction.value);
30           }
31           else {
32               testPassed("Reduction is 0.0");
33           }
34
35           finishJSTest();
36       }
37
38       function runTest() {
39           window.jsTestIsAsync = true;
40
41           // Create the offline context for the test.
42           context = new OfflineAudioContext(1, testDurationSamples, sampleRate);
43           context.oncomplete = checkResult;
44
45           // Create the constant sample buffer of 0.5 sec.
46           buffer = createConstantBuffer(context, testDurationSamples / 2, 1);
47
48           // Create compressor and use default parameters for the compression.
49           compressor = context.createDynamicsCompressor();
50
51           // Create the source and connect it to the destination
52           source = context.createBufferSource();
53           source.buffer = buffer;
54           source.connect(compressor);
55           compressor.connect(context.destination);
56           source.start(0.0);
57
58           // Render it!
59           context.startRendering();
60       }
61
62       runTest();
63       succesfullyParsed = true;
64     </script>
65   </body>
66 </html>