| Index: LayoutTests/webaudio/oscillator-basic.html
|
| diff --git a/LayoutTests/webaudio/oscillator-basic.html b/LayoutTests/webaudio/oscillator-basic.html
|
| index 2414fd183d5a75de0405b8a7ce2b4e0cccdb3198..8a04ccbfc324d10a2a234b288d7b44c4acdcb1d3 100644
|
| --- a/LayoutTests/webaudio/oscillator-basic.html
|
| +++ b/LayoutTests/webaudio/oscillator-basic.html
|
| @@ -20,11 +20,7 @@ description("Basic test of setting Oscillator node types.");
|
| var sampleRate = 44100;
|
| var renderLengthSeconds = 0.25;
|
|
|
| -var oscTypes = [{type: "sine", integerType: 0, name: "SINE"},
|
| - {type: "square", integerType: 1, name: "SQUARE"},
|
| - {type: "sawtooth", integerType: 2, name: "SAWTOOTH"},
|
| - {type: "triangle", integerType: 3, name: "TRIANGLE"},
|
| - {type: "custom", integerType: 4, name: "CUSTOM"}];
|
| +var oscTypes = ["sine", "square", "sawtooth", "triangle", "custom"];
|
|
|
| function runTest()
|
| {
|
| @@ -42,22 +38,21 @@ function runTest()
|
| // Set each possible oscillator type (except CUSTOM) and verify that the type is correct.
|
| // Here we're setting the type using WebIDL enum values which are strings.
|
| for (var k = 0; k < oscTypes.length - 1; ++k) {
|
| - osc.type = oscTypes[k].type;
|
| - if (osc.type == oscTypes[k].type)
|
| - testPassed("Oscillator correctly set to " + oscTypes[k].name + " type.");
|
| + osc.type = oscTypes[k];
|
| + if (osc.type == oscTypes[k])
|
| + testPassed('Oscillator correctly set to "' + oscTypes[k] + '" type.');
|
| else
|
| - testFailed("Oscillator set to " + oscTypes[k].name + " type, but returns " + oscTypes[osc.type].name + " type.");
|
| + testFailed('Oscillator set to "' + oscTypes[k] + '" type, but returns "' + osc.type + '" type.');
|
| }
|
|
|
| - // For legacy support, verify that we can set the type attribute as an integer value and
|
| - // verify that this translates correctly to the WebIDL enum value.
|
| - for (var k = 0; k < oscTypes.length - 1; ++k) {
|
| - osc.type = oscTypes[k].integerType;
|
| - if (osc.type == oscTypes[k].type)
|
| - testPassed("Oscillator correctly set to " + oscTypes[k].name + " type using legacy integer value.");
|
| - else
|
| - testFailed("Oscillator set to " + oscTypes[k].name + " type, but returns " + oscTypes[osc.type].name + " type using legacy integer value.");
|
| - }
|
| + // Verify that setting a custom type directly does not set the custom type. This test has to be
|
| + // done before using setPeriodicWave.
|
| +
|
| + osc.type = "custom";
|
| + if (osc.type == "custom")
|
| + testFailed('Directly setting oscillator type to "custom" incorrectly succeeded.');
|
| + else
|
| + testPassed('Directly setting oscillator type to "custom" correctly failed.');
|
|
|
| // Now set a custom oscillator
|
| var coeffA = new Float32Array([0, 1, 0.5]);
|
| @@ -65,29 +60,17 @@ function runTest()
|
| var wave = context.createPeriodicWave(coeffA, coeffB);
|
| osc.setPeriodicWave(wave);
|
| if (osc.type == "custom")
|
| - testPassed("Oscillator correctly set to CUSTOM type using setPeriodicWave.");
|
| + testPassed('Oscillator correctly set to "custom" type using setPeriodicWave.');
|
| else
|
| - testFailed("Oscillator set to CUSTOM type, but returns " + oscTypes[osc.type].name + " type.");
|
| + testFailed('Oscillator set to "custom" type, but returns "' + osc.type + '" type.');
|
|
|
| - // Try setting some invalid types
|
| - try {
|
| - osc.type = "custom";
|
| - testFailed("Directly setting oscillator type to CUSTOM did not throw exception.");
|
| - } catch (e) {
|
| - testPassed("Directly setting oscillator type to CUSTOM correctly throws exception.");
|
| - }
|
| -
|
| - var oscType = osc.CUSTOM + 1;
|
| - try {
|
| - osc.type = oscType;
|
| - testFailed("Setting oscillator to invalid type " + oscType + " did not throw exception.");
|
| - } catch (e) {
|
| - testPassed("Setting oscillator to invalid type " + oscType + " correctly throws exception.");
|
| - }
|
| -
|
| - // Check specifically that we throw a TypeError.
|
| - shouldThrowTypeError(function() { osc.type = "xyz12349jfksd"; }, "Setting .type to illegal string value");
|
| - shouldThrowTypeError(function() { osc.type = new Float32Array(1); }, "Setting .type to illegal type of Float32Array");
|
| +
|
| + // Check that numerical values are no longer supported
|
| + osc.type = 0;
|
| + if (osc.type == 0)
|
| + testFailed("Oscillator incorrectly set to 0.")
|
| + else
|
| + testPassed("Oscillator correctly not set to 0.");
|
|
|
| finishJSTest();
|
| }
|
|
|