Diff
Modified: trunk/LayoutTests/ChangeLog (125459 => 125460)
--- trunk/LayoutTests/ChangeLog 2012-08-13 22:16:02 UTC (rev 125459)
+++ trunk/LayoutTests/ChangeLog 2012-08-13 22:16:37 UTC (rev 125460)
@@ -1,3 +1,16 @@
+2012-08-13 Raymond Toy <[email protected]>
+
+ Oscillator node should throw exception if type is assigned an invalid value
+ https://bugs.webkit.org/show_bug.cgi?id=93490
+
+ Reviewed by Chris Rogers.
+
+ Add tests for invalid oscillator types.
+
+ * webaudio/oscillator-basic-expected.txt: Updated
+ * webaudio/oscillator-basic.html: Test CUSTOM and invalid
+ oscillator type.
+
2012-08-13 Brady Eidson <[email protected]>
With asynchronous plug-in initialization, WebProcess and PluginProcess can deadlock
Modified: trunk/LayoutTests/webaudio/oscillator-basic-expected.txt (125459 => 125460)
--- trunk/LayoutTests/webaudio/oscillator-basic-expected.txt 2012-08-13 22:16:02 UTC (rev 125459)
+++ trunk/LayoutTests/webaudio/oscillator-basic-expected.txt 2012-08-13 22:16:37 UTC (rev 125460)
@@ -6,7 +6,9 @@
PASS Oscillator correctly set to SQUARE type.
PASS Oscillator correctly set to SAWTOOTH type.
PASS Oscillator correctly set to TRIANGLE type.
-PASS Oscillator correctly set to CUSTOM type.
+PASS Oscillator correctly set to CUSTOM type using setWaveTable.
+PASS Directly setting oscillator type to CUSTOM correctly throws exception.
+PASS Setting oscillator to invalid type 5 correctly throws exception.
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/webaudio/oscillator-basic.html (125459 => 125460)
--- trunk/LayoutTests/webaudio/oscillator-basic.html 2012-08-13 22:16:02 UTC (rev 125459)
+++ trunk/LayoutTests/webaudio/oscillator-basic.html 2012-08-13 22:16:37 UTC (rev 125460)
@@ -54,10 +54,26 @@
var wavetable = context.createWaveTable(coeffA, coeffB);
osc.setWaveTable(wavetable);
if (osc.type == osc.CUSTOM)
- testPassed("Oscillator correctly set to CUSTOM type.");
+ testPassed("Oscillator correctly set to CUSTOM type using setWaveTable.");
else
testFailed("Oscillator set to CUSTOM type, but returns " + oscTypes[osc.type].name + " type.");
+ // Try setting some invalid types
+ try {
+ osc.type = osc.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.");
+ }
+
finishJSTest();
}
Modified: trunk/Source/WebCore/ChangeLog (125459 => 125460)
--- trunk/Source/WebCore/ChangeLog 2012-08-13 22:16:02 UTC (rev 125459)
+++ trunk/Source/WebCore/ChangeLog 2012-08-13 22:16:37 UTC (rev 125460)
@@ -1,3 +1,19 @@
+2012-08-13 Raymond Toy <[email protected]>
+
+ Oscillator node should throw exception if type is assigned an invalid value
+ https://bugs.webkit.org/show_bug.cgi?id=93490
+
+ Reviewed by Chris Rogers.
+
+ New tests added to oscillator-basic to catch exceptions.
+
+ * Modules/webaudio/Oscillator.cpp:
+ (WebCore::Oscillator::Oscillator):
+ (WebCore::Oscillator::setType): Return exception
+ * Modules/webaudio/Oscillator.h:
+ (Oscillator): Update setType declaration
+ * Modules/webaudio/Oscillator.idl: setType can raise exception.
+
2012-08-13 Chris Rogers <[email protected]>
AudioContext::createMediaStreamSource() must create a provider for local MediaStreams
Modified: trunk/Source/WebCore/Modules/webaudio/Oscillator.cpp (125459 => 125460)
--- trunk/Source/WebCore/Modules/webaudio/Oscillator.cpp 2012-08-13 22:16:02 UTC (rev 125459)
+++ trunk/Source/WebCore/Modules/webaudio/Oscillator.cpp 2012-08-13 22:16:37 UTC (rev 125460)
@@ -31,6 +31,7 @@
#include "AudioContext.h"
#include "AudioNodeOutput.h"
#include "AudioUtilities.h"
+#include "ExceptionCode.h"
#include "VectorMath.h"
#include "WaveTable.h"
#include <algorithm>
@@ -68,7 +69,8 @@
m_detune = AudioParam::create(context, "detune", 0, -4800, 4800);
// Sets up default wavetable.
- setType(m_type);
+ ExceptionCode ec;
+ setType(m_type, ec);
// An oscillator is always mono.
addOutput(adoptPtr(new AudioNodeOutput(this, 1)));
@@ -81,7 +83,7 @@
uninitialize();
}
-void Oscillator::setType(unsigned short type)
+void Oscillator::setType(unsigned short type, ExceptionCode& ec)
{
WaveTable* waveTable = 0;
float sampleRate = this->sampleRate();
@@ -109,10 +111,10 @@
break;
case CUSTOM:
default:
- // FIXME: throw exception for invalid types or if the type is CUSTOM since setWaveTable()
- // method must be called explicitly in that case.
+ // Throw exception for invalid types, including CUSTOM since setWaveTable() method must be
+ // called explicitly.
+ ec = NOT_SUPPORTED_ERR;
return;
- break;
}
setWaveTable(waveTable);
Modified: trunk/Source/WebCore/Modules/webaudio/Oscillator.h (125459 => 125460)
--- trunk/Source/WebCore/Modules/webaudio/Oscillator.h 2012-08-13 22:16:02 UTC (rev 125459)
+++ trunk/Source/WebCore/Modules/webaudio/Oscillator.h 2012-08-13 22:16:37 UTC (rev 125460)
@@ -61,7 +61,7 @@
virtual void reset();
unsigned short type() const { return m_type; }
- void setType(unsigned short);
+ void setType(unsigned short, ExceptionCode&);
AudioParam* frequency() { return m_frequency.get(); }
AudioParam* detune() { return m_detune.get(); }
Modified: trunk/Source/WebCore/Modules/webaudio/Oscillator.idl (125459 => 125460)
--- trunk/Source/WebCore/Modules/webaudio/Oscillator.idl 2012-08-13 22:16:02 UTC (rev 125459)
+++ trunk/Source/WebCore/Modules/webaudio/Oscillator.idl 2012-08-13 22:16:37 UTC (rev 125460)
@@ -36,7 +36,8 @@
const unsigned short TRIANGLE = 3;
const unsigned short CUSTOM = 4;
- attribute unsigned short type;
+ attribute unsigned short type
+ setter raises(DOMException);
// Playback state constants.
const unsigned short UNSCHEDULED_STATE = 0;