Diff
Modified: trunk/LayoutTests/ChangeLog (152488 => 152489)
--- trunk/LayoutTests/ChangeLog 2013-07-09 09:41:46 UTC (rev 152488)
+++ trunk/LayoutTests/ChangeLog 2013-07-09 09:59:33 UTC (rev 152489)
@@ -1,3 +1,18 @@
+2013-07-09 Praveen R Jadhav <[email protected]>
+
+ Update Exception handling in WebAudio.
+ https://bugs.webkit.org/show_bug.cgi?id=118405.
+
+ Reviewed by Chris Rogers.
+
+ New test cases to check exception handling in AnalyserNode and
+ AudioBufferSourceNode.
+
+ * webaudio/analyser-exception-expected.txt: Added.
+ * webaudio/analyser-exception.html: Added.
+ * webaudio/audiobuffersource-exception-expected.txt: Added.
+ * webaudio/audiobuffersource-exception.html: Added.
+
2013-07-09 Zoltan Arvai <[email protected]>
[Qt] Unreviewed gardening. Rebaselining after r152479.
Added: trunk/LayoutTests/webaudio/analyser-exception-expected.txt (0 => 152489)
--- trunk/LayoutTests/webaudio/analyser-exception-expected.txt (rev 0)
+++ trunk/LayoutTests/webaudio/analyser-exception-expected.txt 2013-07-09 09:59:33 UTC (rev 152489)
@@ -0,0 +1,11 @@
+Tests that AnalyserNode validates minDecibels, maxDecibels and smoothingTimeConstant values.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS analyser.minDecibels = -20 threw exception Error: IndexSizeError: DOM Exception 1.
+PASS analyser.maxDecibels = -120 threw exception Error: IndexSizeError: DOM Exception 1.
+PASS analyser.smoothingTimeConstant = 2 threw exception Error: IndexSizeError: DOM Exception 1.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/webaudio/analyser-exception.html (0 => 152489)
--- trunk/LayoutTests/webaudio/analyser-exception.html (rev 0)
+++ trunk/LayoutTests/webaudio/analyser-exception.html 2013-07-09 09:59:33 UTC (rev 152489)
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+<script src=""
+<script src=""
+<script src=""
+</head>
+
+<body>
+
+<div id="description"></div>
+<div id="console"></div>
+
+<script>
+description("Tests that AnalyserNode validates minDecibels, maxDecibels and smoothingTimeConstant values.");
+
+var analyser;
+
+function runTest() {
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ }
+
+ window.jsTestIsAsync = true;
+
+ var sampleRate = 44100.0;
+ var numberOfFrames = 32;
+ var context = new webkitOfflineAudioContext(1, numberOfFrames, sampleRate);
+ analyser = context.createAnalyser();
+ analyser.connect(context.destination);
+
+ // 'minDecibels' shouldn't be greater than 'maxDecibels' which defaults to -30dB.
+ shouldThrow("analyser.minDecibels = -20", "'Error: IndexSizeError: DOM Exception 1'");
+
+ // 'maxDecibels' shouldn't be less than 'minDecibels' which defaults to -100dB.
+ shouldThrow("analyser.maxDecibels = -120", "'Error: IndexSizeError: DOM Exception 1'");
+
+ // 'smoothingTimeConstant' range is between 0 and 1.
+ shouldThrow("analyser.smoothingTimeConstant = 2", "'Error: IndexSizeError: DOM Exception 1'");
+
+ context._oncomplete_ = finishJSTest;
+ context.startRendering();
+}
+
+runTest();
+
+</script>
+
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/webaudio/audiobuffersource-exception-expected.txt (0 => 152489)
--- trunk/LayoutTests/webaudio/audiobuffersource-exception-expected.txt (rev 0)
+++ trunk/LayoutTests/webaudio/audiobuffersource-exception-expected.txt 2013-07-09 09:59:33 UTC (rev 152489)
@@ -0,0 +1,10 @@
+Tests that AudioBufferSourceNode validates start and stop calls.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS bufferSource.stop(0) threw exception Error: InvalidStateError: DOM Exception 11.
+PASS bufferSource.start(0) threw exception Error: InvalidStateError: DOM Exception 11.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/webaudio/audiobuffersource-exception.html (0 => 152489)
--- trunk/LayoutTests/webaudio/audiobuffersource-exception.html (rev 0)
+++ trunk/LayoutTests/webaudio/audiobuffersource-exception.html 2013-07-09 09:59:33 UTC (rev 152489)
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+<script src=""
+<script src=""
+<script src=""
+</head>
+
+<body>
+
+<div id="description"></div>
+<div id="console"></div>
+
+<script>
+description("Tests that AudioBufferSourceNode validates start and stop calls.");
+
+var bufferSource;
+
+function runTest() {
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ }
+
+ window.jsTestIsAsync = true;
+
+ var sampleRate = 44100.0;
+ var numberOfFrames = 32;
+ var context = new webkitOfflineAudioContext(1, numberOfFrames, sampleRate);
+ bufferSource = context.createBufferSource();
+ bufferSource.buffer = createTestBuffer(context, numberOfFrames);
+ bufferSource.connect(context.destination);
+
+ // 'stop' should be called only after 'start'.
+ shouldThrow("bufferSource.stop(0)", "'Error: InvalidStateError: DOM Exception 11'");
+ bufferSource.start(0);
+
+ // 'start' should be called only once.
+ shouldThrow("bufferSource.start(0)", "'Error: InvalidStateError: DOM Exception 11'");
+ bufferSource.stop(0);
+
+ context._oncomplete_ = finishJSTest;
+ context.startRendering();
+}
+
+runTest();
+
+</script>
+
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (152488 => 152489)
--- trunk/Source/WebCore/ChangeLog 2013-07-09 09:41:46 UTC (rev 152488)
+++ trunk/Source/WebCore/ChangeLog 2013-07-09 09:59:33 UTC (rev 152489)
@@ -1,3 +1,41 @@
+2013-07-09 Praveen R Jadhav <[email protected]>
+
+ Update Exception handling in WebAudio.
+ https://bugs.webkit.org/show_bug.cgi?id=118405.
+
+ Reviewed by Chris Rogers.
+
+ AudioBufferSourceNode, OscillatorNode and AnalyserNode don't
+ propagate exception mentioned in WebAudio spec.
+ Code updated to throw DOM exception as expected.
+
+ Tests: webaudio/analyser-exception.html
+ webaudio/audiobuffersource-exception.html
+
+ * Modules/webaudio/AnalyserNode.cpp:
+ (WebCore::AnalyserNode::setFftSize):
+ (WebCore::AnalyserNode::setMinDecibels):
+ (WebCore::AnalyserNode::setMaxDecibels):
+ (WebCore::AnalyserNode::setSmoothingTimeConstant):
+ * Modules/webaudio/AnalyserNode.h:
+ * Modules/webaudio/AnalyserNode.idl:
+ * Modules/webaudio/AudioBufferSourceNode.cpp:
+ (WebCore::AudioBufferSourceNode::startGrain):
+ (WebCore::AudioBufferSourceNode::noteGrainOn):
+ * Modules/webaudio/AudioBufferSourceNode.h:
+ * Modules/webaudio/AudioBufferSourceNode.idl:
+ * Modules/webaudio/AudioContext.cpp:
+ (WebCore::AudioContext::createBuffer):
+ (WebCore::AudioContext::createScriptProcessor):
+ (WebCore::AudioContext::createPeriodicWave):
+ * Modules/webaudio/AudioScheduledSourceNode.cpp:
+ (WebCore::AudioScheduledSourceNode::start):
+ (WebCore::AudioScheduledSourceNode::stop):
+ (WebCore::AudioScheduledSourceNode::noteOn):
+ (WebCore::AudioScheduledSourceNode::noteOff):
+ * Modules/webaudio/AudioScheduledSourceNode.h:
+ * Modules/webaudio/OscillatorNode.idl:
+
2013-07-08 Martin Robinson <[email protected]>
[CSS Grid Layout] Rename grid-{rows|columns} to grid-definition-{rows|columns}
Modified: trunk/Source/WebCore/Modules/webaudio/AnalyserNode.cpp (152488 => 152489)
--- trunk/Source/WebCore/Modules/webaudio/AnalyserNode.cpp 2013-07-09 09:41:46 UTC (rev 152488)
+++ trunk/Source/WebCore/Modules/webaudio/AnalyserNode.cpp 2013-07-09 09:59:33 UTC (rev 152489)
@@ -75,9 +75,39 @@
void AnalyserNode::setFftSize(unsigned size, ExceptionCode& ec)
{
if (!m_analyser.setFftSize(size))
- ec = NOT_SUPPORTED_ERR;
+ ec = INDEX_SIZE_ERR;
}
+void AnalyserNode::setMinDecibels(float k, ExceptionCode& ec)
+{
+ if (k > maxDecibels()) {
+ ec = INDEX_SIZE_ERR;
+ return;
+ }
+
+ m_analyser.setMinDecibels(k);
+}
+
+void AnalyserNode::setMaxDecibels(float k, ExceptionCode& ec)
+{
+ if (k < minDecibels()) {
+ ec = INDEX_SIZE_ERR;
+ return;
+ }
+
+ m_analyser.setMaxDecibels(k);
+}
+
+void AnalyserNode::setSmoothingTimeConstant(float k, ExceptionCode& ec)
+{
+ if (k < 0 || k > 1) {
+ ec = INDEX_SIZE_ERR;
+ return;
+ }
+
+ m_analyser.setSmoothingTimeConstant(k);
+}
+
} // namespace WebCore
#endif // ENABLE(WEB_AUDIO)
Modified: trunk/Source/WebCore/Modules/webaudio/AnalyserNode.h (152488 => 152489)
--- trunk/Source/WebCore/Modules/webaudio/AnalyserNode.h 2013-07-09 09:41:46 UTC (rev 152488)
+++ trunk/Source/WebCore/Modules/webaudio/AnalyserNode.h 2013-07-09 09:59:33 UTC (rev 152489)
@@ -50,13 +50,13 @@
unsigned frequencyBinCount() const { return m_analyser.frequencyBinCount(); }
- void setMinDecibels(float k) { m_analyser.setMinDecibels(k); }
+ void setMinDecibels(float k, ExceptionCode&);
float minDecibels() const { return m_analyser.minDecibels(); }
- void setMaxDecibels(float k) { m_analyser.setMaxDecibels(k); }
+ void setMaxDecibels(float k, ExceptionCode&);
float maxDecibels() const { return m_analyser.maxDecibels(); }
- void setSmoothingTimeConstant(float k) { m_analyser.setSmoothingTimeConstant(k); }
+ void setSmoothingTimeConstant(float k, ExceptionCode&);
float smoothingTimeConstant() const { return m_analyser.smoothingTimeConstant(); }
void getFloatFrequencyData(Float32Array* array) { m_analyser.getFloatFrequencyData(array); }
Modified: trunk/Source/WebCore/Modules/webaudio/AnalyserNode.idl (152488 => 152489)
--- trunk/Source/WebCore/Modules/webaudio/AnalyserNode.idl 2013-07-09 09:41:46 UTC (rev 152488)
+++ trunk/Source/WebCore/Modules/webaudio/AnalyserNode.idl 2013-07-09 09:59:33 UTC (rev 152489)
@@ -30,11 +30,11 @@
readonly attribute unsigned long frequencyBinCount;
// minDecibels / maxDecibels represent the range to scale the FFT analysis data for conversion to unsigned byte values.
- attribute float minDecibels;
- attribute float maxDecibels;
+ [SetterRaisesException] attribute float minDecibels;
+ [SetterRaisesException] attribute float maxDecibels;
// A value from 0.0 -> 1.0 where 0.0 represents no time averaging with the last analysis frame.
- attribute float smoothingTimeConstant;
+ [SetterRaisesException] attribute float smoothingTimeConstant;
// Copies the current frequency data into the passed array.
// If the array has fewer elements than the frequencyBinCount, the excess elements will be dropped.
Modified: trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.cpp (152488 => 152489)
--- trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.cpp 2013-07-09 09:41:46 UTC (rev 152488)
+++ trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.cpp 2013-07-09 09:59:33 UTC (rev 152489)
@@ -373,21 +373,23 @@
return output(0)->numberOfChannels();
}
-void AudioBufferSourceNode::startGrain(double when, double grainOffset)
+void AudioBufferSourceNode::startGrain(double when, double grainOffset, ExceptionCode& ec)
{
// Duration of 0 has special value, meaning calculate based on the entire buffer's duration.
- startGrain(when, grainOffset, 0);
+ startGrain(when, grainOffset, 0, ec);
}
-void AudioBufferSourceNode::startGrain(double when, double grainOffset, double grainDuration)
+void AudioBufferSourceNode::startGrain(double when, double grainOffset, double grainDuration, ExceptionCode& ec)
{
ASSERT(isMainThread());
if (ScriptController::processingUserGesture())
context()->removeBehaviorRestriction(AudioContext::RequireUserGestureForAudioStartRestriction);
- if (m_playbackState != UNSCHEDULED_STATE)
+ if (m_playbackState != UNSCHEDULED_STATE) {
+ ec = INVALID_STATE_ERR;
return;
+ }
if (!buffer())
return;
@@ -421,9 +423,9 @@
}
#if ENABLE(LEGACY_WEB_AUDIO)
-void AudioBufferSourceNode::noteGrainOn(double when, double grainOffset, double grainDuration)
+void AudioBufferSourceNode::noteGrainOn(double when, double grainOffset, double grainDuration, ExceptionCode& ec)
{
- startGrain(when, grainOffset, grainDuration);
+ startGrain(when, grainOffset, grainDuration, ec);
}
#endif
Modified: trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.h (152488 => 152489)
--- trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.h 2013-07-09 09:41:46 UTC (rev 152488)
+++ trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.h 2013-07-09 09:59:33 UTC (rev 152489)
@@ -29,6 +29,7 @@
#include "AudioBus.h"
#include "AudioParam.h"
#include "AudioScheduledSourceNode.h"
+#include "ExceptionCode.h"
#include "PannerNode.h"
#include <wtf/OwnArrayPtr.h>
#include <wtf/PassRefPtr.h>
@@ -62,11 +63,11 @@
unsigned numberOfChannels();
// Play-state
- void startGrain(double when, double grainOffset);
- void startGrain(double when, double grainOffset, double grainDuration);
+ void startGrain(double when, double grainOffset, ExceptionCode&);
+ void startGrain(double when, double grainOffset, double grainDuration, ExceptionCode&);
#if ENABLE(LEGACY_WEB_AUDIO)
- void noteGrainOn(double when, double grainOffset, double grainDuration);
+ void noteGrainOn(double when, double grainOffset, double grainDuration, ExceptionCode&);
#endif
// Note: the attribute was originally exposed as .looping, but to be more consistent in naming with <audio>
Modified: trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.idl (152488 => 152489)
--- trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.idl 2013-07-09 09:41:46 UTC (rev 152488)
+++ trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.idl 2013-07-09 09:59:33 UTC (rev 152489)
@@ -44,16 +44,16 @@
attribute double loopStart;
attribute double loopEnd;
- void start(double when);
- [ImplementedAs=startGrain] void start(double when, double grainOffset);
- [ImplementedAs=startGrain] void start(double when, double grainOffset, double grainDuration);
- void stop(double when);
+ [RaisesException] void start(double when);
+ [ImplementedAs=startGrain, RaisesException] void start(double when, double grainOffset);
+ [ImplementedAs=startGrain, RaisesException] void start(double when, double grainOffset, double grainDuration);
+ [RaisesException] void stop(double when);
[Conditional=LEGACY_WEB_AUDIO] attribute boolean looping; // This is an alias for the .loop attribute for backwards compatibility.
- [Conditional=LEGACY_WEB_AUDIO] void noteOn(double when);
- [Conditional=LEGACY_WEB_AUDIO] void noteGrainOn(double when, double grainOffset, double grainDuration);
- [Conditional=LEGACY_WEB_AUDIO] void noteOff(double when);
+ [Conditional=LEGACY_WEB_AUDIO, RaisesException] void noteOn(double when);
+ [Conditional=LEGACY_WEB_AUDIO, RaisesException] void noteGrainOn(double when, double grainOffset, double grainDuration);
+ [Conditional=LEGACY_WEB_AUDIO, RaisesException] void noteOff(double when);
attribute EventListener onended;
};
Modified: trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp (152488 => 152489)
--- trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp 2013-07-09 09:41:46 UTC (rev 152488)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp 2013-07-09 09:59:33 UTC (rev 152489)
@@ -91,6 +91,7 @@
const int UndefinedThreadIdentifier = 0xffffffff;
const unsigned MaxNodesToDeletePerQuantum = 10;
+const unsigned MaxPeriodicWaveLength = 4096;
namespace WebCore {
@@ -328,7 +329,7 @@
{
RefPtr<AudioBuffer> audioBuffer = AudioBuffer::create(numberOfChannels, numberOfFrames, sampleRate);
if (!audioBuffer.get()) {
- ec = SYNTAX_ERR;
+ ec = NOT_SUPPORTED_ERR;
return 0;
}
@@ -464,7 +465,7 @@
RefPtr<ScriptProcessorNode> node = ScriptProcessorNode::create(this, m_destinationNode->sampleRate(), bufferSize, numberOfInputChannels, numberOfOutputChannels);
if (!node.get()) {
- ec = SYNTAX_ERR;
+ ec = INDEX_SIZE_ERR;
return 0;
}
@@ -597,7 +598,7 @@
{
ASSERT(isMainThread());
- if (!real || !imag || (real->length() != imag->length())) {
+ if (!real || !imag || (real->length() != imag->length() || (real->length() > MaxPeriodicWaveLength) || (real->length() <= 0))) {
ec = SYNTAX_ERR;
return 0;
}
Modified: trunk/Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.cpp (152488 => 152489)
--- trunk/Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.cpp 2013-07-09 09:41:46 UTC (rev 152488)
+++ trunk/Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.cpp 2013-07-09 09:59:33 UTC (rev 152489)
@@ -135,39 +135,43 @@
return;
}
-void AudioScheduledSourceNode::start(double when)
+void AudioScheduledSourceNode::start(double when, ExceptionCode& ec)
{
ASSERT(isMainThread());
if (ScriptController::processingUserGesture())
context()->removeBehaviorRestriction(AudioContext::RequireUserGestureForAudioStartRestriction);
- if (m_playbackState != UNSCHEDULED_STATE)
+ if (m_playbackState != UNSCHEDULED_STATE) {
+ ec = INVALID_STATE_ERR;
return;
+ }
m_startTime = when;
m_playbackState = SCHEDULED_STATE;
}
-void AudioScheduledSourceNode::stop(double when)
+void AudioScheduledSourceNode::stop(double when, ExceptionCode& ec)
{
ASSERT(isMainThread());
- if (!(m_playbackState == SCHEDULED_STATE || m_playbackState == PLAYING_STATE))
+ if (!(m_playbackState == SCHEDULED_STATE || m_playbackState == PLAYING_STATE)) {
+ ec = INVALID_STATE_ERR;
return;
+ }
when = max(0.0, when);
m_endTime = when;
}
#if ENABLE(LEGACY_WEB_AUDIO)
-void AudioScheduledSourceNode::noteOn(double when)
+void AudioScheduledSourceNode::noteOn(double when, ExceptionCode& ec)
{
- start(when);
+ start(when, ec);
}
-void AudioScheduledSourceNode::noteOff(double when)
+void AudioScheduledSourceNode::noteOff(double when, ExceptionCode& ec)
{
- stop(when);
+ stop(when, ec);
}
#endif
Modified: trunk/Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.h (152488 => 152489)
--- trunk/Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.h 2013-07-09 09:41:46 UTC (rev 152488)
+++ trunk/Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.h 2013-07-09 09:59:33 UTC (rev 152489)
@@ -30,6 +30,7 @@
#define AudioScheduledSourceNode_h
#include "AudioNode.h"
+#include "ExceptionCode.h"
namespace WebCore {
@@ -57,12 +58,12 @@
AudioScheduledSourceNode(AudioContext*, float sampleRate);
// Scheduling.
- void start(double when);
- void stop(double when);
+ void start(double when, ExceptionCode&);
+ void stop(double when, ExceptionCode&);
#if ENABLE(LEGACY_WEB_AUDIO)
- void noteOn(double when);
- void noteOff(double when);
+ void noteOn(double when, ExceptionCode&);
+ void noteOff(double when, ExceptionCode&);
#endif
unsigned short playbackState() const { return static_cast<unsigned short>(m_playbackState); }
Modified: trunk/Source/WebCore/Modules/webaudio/OscillatorNode.idl (152488 => 152489)
--- trunk/Source/WebCore/Modules/webaudio/OscillatorNode.idl 2013-07-09 09:41:46 UTC (rev 152488)
+++ trunk/Source/WebCore/Modules/webaudio/OscillatorNode.idl 2013-07-09 09:59:33 UTC (rev 152489)
@@ -48,11 +48,11 @@
readonly attribute AudioParam frequency; // in Hertz
readonly attribute AudioParam detune; // in Cents
- void start(double when);
- void stop(double when);
+ [RaisesException] void start(double when);
+ [RaisesException] void stop(double when);
- [Conditional=LEGACY_WEB_AUDIO] void noteOn(double when);
- [Conditional=LEGACY_WEB_AUDIO] void noteOff(double when);
+ [Conditional=LEGACY_WEB_AUDIO, RaisesException] void noteOn(double when);
+ [Conditional=LEGACY_WEB_AUDIO, RaisesException] void noteOff(double when);
void setPeriodicWave(PeriodicWave wave);