Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / webaudio / oscillator-basic.html
bloba55042b71550bc29cf99818b76de83120e45d32a
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
3 <!--
4 Create an oscillator of each type and verify that the type is set correctly.
5 -->
6 <html>
7 <head>
8 <script src="resources/compatibility.js"></script>
9 <script type="text/javascript" src="resources/audio-testing.js"></script>
10 <script type="text/javascript" src="../resources/js-test.js"></script>
11 </head>
13 <body>
14 <div id="description"></div>
15 <div id="console"></div>
17 <script>
18 description("Basic test of setting Oscillator node types.");
20 var sampleRate = 44100;
21 var renderLengthSeconds = 0.25;
23 var oscTypes = ["sine", "square", "sawtooth", "triangle", "custom"];
25 function runTest()
27 if (window.testRunner) {
28 testRunner.dumpAsText();
29 testRunner.waitUntilDone();
32 window.jsTestIsAsync = true;
34 // Create offline audio context.
35 var context = new OfflineAudioContext(2, sampleRate * renderLengthSeconds, sampleRate);
36 var osc = context.createOscillator();
38 // Set each possible oscillator type (except CUSTOM) and verify that the type is correct.
39 // Here we're setting the type using WebIDL enum values which are strings.
40 for (var k = 0; k < oscTypes.length - 1; ++k) {
41 osc.type = oscTypes[k];
42 Should("osc.type = '" + oscTypes[k] + "'", osc.type).beEqualTo(oscTypes[k]);
45 // Verify that setting a custom type directly does not set the custom type. This test has to be
46 // done before using setPeriodicWave.
48 Should("osc.type = 'custom'", function () {
49 osc.type = "custom";
50 }).throw('InvalidStateError');
52 // Now set a custom oscillator
53 var coeffA = new Float32Array([0, 1, 0.5]);
54 var coeffB = new Float32Array([0, 0, 0]);
55 var wave = context.createPeriodicWave(coeffA, coeffB);
57 Should("osc.setPeriodicWave(wave)", function () {
58 osc.setPeriodicWave(wave);
59 }).notThrow();
60 Should("osc.type", osc.type).beEqualTo("custom");
62 // Check that numerical values are no longer supported
63 var oldType = osc.type;
64 osc.type = 0;
65 Should("osc.type = 0", osc.type).notBeEqualTo(0);
66 Should("osc.type", osc.type).beEqualTo(oldType);
68 finishJSTest();
71 runTest();
72 successfullyParsed = true;
74 </script>
77 </body>
78 </html>