- Revision
- 124237
- Author
- [email protected]
- Date
- 2012-07-31 12:14:07 -0700 (Tue, 31 Jul 2012)
Log Message
AudioPannerNode should raise exception when distanceModel is set incorrectly
https://bugs.webkit.org/show_bug.cgi?id=90952
Patch by Li Yin <[email protected]> on 2012-07-31
Reviewed by Chris Rogers.
Source/WebCore:
Spec: http://www.w3.org/TR/webaudio/#AudioPannerNode-section
The distance model can be only set to LINEAR_DISTANCE, INVERSE_DISTANCE or EXPONENTIAL_DISTANCE.
If the incorrect value is set, it will raise the exception.
Use the unsigned short to replace unsigned long in AudioPannerNode.idl.
Test: webaudio/audiopannernode-basic.html
* Modules/webaudio/AudioPannerNode.cpp:
(WebCore::AudioPannerNode::setDistanceModel): raise exception
(WebCore):
* Modules/webaudio/AudioPannerNode.h:
(AudioPannerNode):
* Modules/webaudio/AudioPannerNode.idl: using unsigned short to replace unsigned long
LayoutTests:
Spec: http://www.w3.org/TR/webaudio/#AudioPannerNode-section
Add tests for distanceModel,numberOfInputs and numberOfInputs of AudioPannerNode.
* webaudio/audiopannernode-basic-expected.txt: Added.
* webaudio/audiopannernode-basic.html: Added.
* webaudio/panner-set-model-expected.txt: Removed.
* webaudio/panner-set-model.html: Removed.
Modified Paths
Added Paths
Removed Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (124236 => 124237)
--- trunk/LayoutTests/ChangeLog 2012-07-31 19:11:09 UTC (rev 124236)
+++ trunk/LayoutTests/ChangeLog 2012-07-31 19:14:07 UTC (rev 124237)
@@ -1,3 +1,18 @@
+2012-07-31 Li Yin <[email protected]>
+
+ AudioPannerNode should raise exception when distanceModel is set incorrectly
+ https://bugs.webkit.org/show_bug.cgi?id=90952
+
+ Reviewed by Chris Rogers.
+
+ Spec: http://www.w3.org/TR/webaudio/#AudioPannerNode-section
+ Add tests for distanceModel,numberOfInputs and numberOfInputs of AudioPannerNode.
+
+ * webaudio/audiopannernode-basic-expected.txt: Added.
+ * webaudio/audiopannernode-basic.html: Added.
+ * webaudio/panner-set-model-expected.txt: Removed.
+ * webaudio/panner-set-model.html: Removed.
+
2012-07-31 Max Vujovic <[email protected]>
[CSS Shaders] CSS parser rejects parameter names that are also CSS keywords
Added: trunk/LayoutTests/webaudio/audiopannernode-basic-expected.txt (0 => 124237)
--- trunk/LayoutTests/webaudio/audiopannernode-basic-expected.txt (rev 0)
+++ trunk/LayoutTests/webaudio/audiopannernode-basic-expected.txt 2012-07-31 19:14:07 UTC (rev 124237)
@@ -0,0 +1,19 @@
+Basic test for AudioPannerNode.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS AudioPannerNode has one input.
+PASS AudioPannerNode has one output.
+PASS panningModel default value is HRTF.
+PASS panningModel set to EQUALPOWER model and read correctly.
+PASS panningModel set to HRTF model and read correctly.
+PASS Setting panningModel to SOUNDFIELD correctly throws exception because it is not implemented.
+PASS Illegal panningModel correctly throws exception.
+PASS distanceModel set to LINEAR_DISTANCE and read correctly.
+PASS distanceModel set to INVERSE_DISTANCE and read correctly.
+PASS distanceModel set to EXPONENTIAL_DISTANCE and read correctly.
+PASS Illegal distanceModel correctly throws exception.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/webaudio/audiopannernode-basic.html (0 => 124237)
--- trunk/LayoutTests/webaudio/audiopannernode-basic.html (rev 0)
+++ trunk/LayoutTests/webaudio/audiopannernode-basic.html 2012-07-31 19:14:07 UTC (rev 124237)
@@ -0,0 +1,105 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+
+<body>
+<div id="description"></div>
+<div id="console"></div>
+
+<script>
+description("Basic test for AudioPannerNode.");
+
+function runTest() {
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ }
+
+ window.jsTestIsAsync = true;
+
+ var context = new webkitAudioContext();
+ var panner = context.createPanner();
+
+ if (panner.numberOfInputs === 1)
+ testPassed("AudioPannerNode has one input.");
+ else
+ testFailed("AudioPannerNode should have one input.");
+
+ if (panner.numberOfOutputs === 1)
+ testPassed("AudioPannerNode has one output.");
+ else
+ testFailed("AudioPannerNode should have one output.");
+
+ if (panner.panningModel === panner.HRTF)
+ testPassed("panningModel default value is HRTF.");
+ else
+ testFailed("panningModel default value is not HRTF.");
+
+ // Set the panning model and see if it can be read back correctly.
+ panner.panningModel = panner.EQUALPOWER;
+ if (panner.panningModel === 0)
+ testPassed("panningModel set to EQUALPOWER model and read correctly.");
+ else
+ testFailed("panningModel set to EQUALPOWER (0) but returned " + panner.panningModel);
+
+ panner.panningModel = panner.HRTF;
+ if (panner.panningModel === 1)
+ testPassed("panningModel set to HRTF model and read correctly.");
+ else
+ testFailed("panningModel set to HRTF (1) but returned " + panner.panningModel);
+
+ // SOUNDFIELD should throw exception because it is not
+ // currently implemented. (See https://bugs.webkit.org/show_bug.cgi?id=77367)
+ try {
+ panner.panningModel = panner.SOUNDFIELD;
+ testFailed("Setting panningModel to SOUNDFIELD should throw exception because it is not implemented.");
+ } catch(e) {
+ testPassed("Setting panningModel to SOUNDFIELD correctly throws exception because it is not implemented.");
+ }
+
+ // Other invalid models should throw an exception.
+ try {
+ panner.panningModel = panner.SOUNDFIELD + 1;
+ testFailed("Illegal panningModel should throw exception.");
+ } catch(e) {
+ testPassed("Illegal panningModel correctly throws exception.");
+ }
+
+ panner.distanceModel = panner.LINEAR_DISTANCE;
+ if (panner.distanceModel === 0)
+ testPassed("distanceModel set to LINEAR_DISTANCE and read correctly.");
+ else
+ testFailed("distanceModel set to LINEAR_DISTANCE (0) but returned " + panner.distanceModel);
+
+ panner.distanceModel = panner.INVERSE_DISTANCE;
+ if (panner.distanceModel === 1)
+ testPassed("distanceModel set to INVERSE_DISTANCE and read correctly.");
+ else
+ testFailed("distanceModel set to INVERSE_DISTANCE (1) but returned " + panner.distanceModel);
+
+ panner.distanceModel = panner.EXPONENTIAL_DISTANCE;
+ if (panner.distanceModel === 2)
+ testPassed("distanceModel set to EXPONENTIAL_DISTANCE and read correctly.");
+ else
+ testFailed("distanceModel set to EXPONENTIAL_DISTANCE (2) but returned " + panner.distanceModel);
+
+ try {
+ panner.distanceModel = panner.EXPONENTIAL_DISTANCE + 1;
+ testFailed("Illegal distanceModel should throw exception.");
+ } catch(e) {
+ testPassed("Illegal distanceModel correctly throws exception.");
+ }
+
+ finishJSTest();
+}
+
+runTest();
+successfullyParsed = true;
+</script>
+
+<script src=""
+</body>
+</html>
Deleted: trunk/LayoutTests/webaudio/panner-set-model-expected.txt (124236 => 124237)
--- trunk/LayoutTests/webaudio/panner-set-model-expected.txt 2012-07-31 19:11:09 UTC (rev 124236)
+++ trunk/LayoutTests/webaudio/panner-set-model-expected.txt 2012-07-31 19:14:07 UTC (rev 124237)
@@ -1,13 +0,0 @@
-Test if panningModel can be set and read.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-PASS Panner set to EQUALPOWER model and read correctly.
-PASS Panner set to HRTF model and read correctly.
-PASS Setting panner model to SOUNDFIELD correctly throws exception because it is not implemented.
-PASS Illegal panner model correctly throws exception.
-PASS Panning model tests passed.
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
Deleted: trunk/LayoutTests/webaudio/panner-set-model.html (124236 => 124237)
--- trunk/LayoutTests/webaudio/panner-set-model.html 2012-07-31 19:11:09 UTC (rev 124236)
+++ trunk/LayoutTests/webaudio/panner-set-model.html 2012-07-31 19:14:07 UTC (rev 124237)
@@ -1,83 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
- <head>
- <link rel="stylesheet" href=""
- <script src=""
- <script src=""
- <title>Test Panner setPanningModel values.</title>
- </head>
-
- <body>
- <div id="description"></div>
- <div id="console"></div>
-
- <script>
- description("Test if panningModel can be set and read.");
-
- // Test to see if we panningModel is updated when we set it.
- function runTest() {
- if (window.testRunner) {
- testRunner.dumpAsText();
- testRunner.waitUntilDone();
- }
-
- window.jsTestIsAsync = true;
-
- var context = new webkitAudioContext();
- var success = true;
- var panner = context.createPanner();
-
- // Set the panning model and see if it can be read back
- // correctly.
- panner.panningModel = panner.EQUALPOWER;
- if (panner.panningModel == 0) {
- testPassed("Panner set to EQUALPOWER model and read correctly.");
- } else {
- testFailed("Panner model set to EQUALPOWER (0) but returned " + panner.panningModel);
- success = false;
- }
-
- panner.panningModel = panner.HRTF;
- if (panner.panningModel == 1) {
- testPassed("Panner set to HRTF model and read correctly.");
- } else {
- testFailed("Panner model set to HRTF (1) but returned " + panner.panningModel);
- success = false;
- }
-
- // SOUNDFIELD should throw exception because it is not
- // currently implemented. (See https://bugs.webkit.org/show_bug.cgi?id=77367)
- try {
- panner.panningModel = panner.SOUNDFIELD;
- testFailed("Setting panner model to SOUNDFIELD should throw exception because it is not implemented.");
- success = false;
- } catch(e) {
- testPassed("Setting panner model to SOUNDFIELD correctly throws exception because it is not implemented.");
- }
-
- // Other invalid models should throw an exception.
- try {
- panner.panningModel = 99;
- testFailed("Illegal panner model should throw exception.");
- success = false;
- } catch(e) {
- testPassed("Illegal panner model correctly throws exception.");
- }
-
- if (success) {
- testPassed("Panning model tests passed.");
- } else {
- testFailed("Panning model tests failed.");
- }
-
- finishJSTest();
- }
-
- runTest();
- successfullyParsed = true;
-
- </script>
-
- <script src=""
- </body>
-</html>
Modified: trunk/Source/WebCore/ChangeLog (124236 => 124237)
--- trunk/Source/WebCore/ChangeLog 2012-07-31 19:11:09 UTC (rev 124236)
+++ trunk/Source/WebCore/ChangeLog 2012-07-31 19:14:07 UTC (rev 124237)
@@ -1,3 +1,24 @@
+2012-07-31 Li Yin <[email protected]>
+
+ AudioPannerNode should raise exception when distanceModel is set incorrectly
+ https://bugs.webkit.org/show_bug.cgi?id=90952
+
+ Reviewed by Chris Rogers.
+
+ Spec: http://www.w3.org/TR/webaudio/#AudioPannerNode-section
+ The distance model can be only set to LINEAR_DISTANCE, INVERSE_DISTANCE or EXPONENTIAL_DISTANCE.
+ If the incorrect value is set, it will raise the exception.
+ Use the unsigned short to replace unsigned long in AudioPannerNode.idl.
+
+ Test: webaudio/audiopannernode-basic.html
+
+ * Modules/webaudio/AudioPannerNode.cpp:
+ (WebCore::AudioPannerNode::setDistanceModel): raise exception
+ (WebCore):
+ * Modules/webaudio/AudioPannerNode.h:
+ (AudioPannerNode):
+ * Modules/webaudio/AudioPannerNode.idl: using unsigned short to replace unsigned long
+
2012-07-31 Max Vujovic <[email protected]>
[CSS Shaders] CSS parser rejects parameter names that are also CSS keywords
Modified: trunk/Source/WebCore/Modules/webaudio/AudioPannerNode.cpp (124236 => 124237)
--- trunk/Source/WebCore/Modules/webaudio/AudioPannerNode.cpp 2012-07-31 19:11:09 UTC (rev 124236)
+++ trunk/Source/WebCore/Modules/webaudio/AudioPannerNode.cpp 2012-07-31 19:14:07 UTC (rev 124237)
@@ -171,6 +171,20 @@
}
}
+void AudioPannerNode::setDistanceModel(unsigned short model, ExceptionCode& ec)
+{
+ switch (model) {
+ case DistanceEffect::ModelLinear:
+ case DistanceEffect::ModelInverse:
+ case DistanceEffect::ModelExponential:
+ m_distanceEffect.setModel(static_cast<DistanceEffect::ModelType>(model), true);
+ break;
+ default:
+ ec = NOT_SUPPORTED_ERR;
+ break;
+ }
+}
+
void AudioPannerNode::getAzimuthElevation(double* outAzimuth, double* outElevation)
{
// FIXME: we should cache azimuth and elevation (if possible), so we only re-calculate if a change has been made.
Modified: trunk/Source/WebCore/Modules/webaudio/AudioPannerNode.h (124236 => 124237)
--- trunk/Source/WebCore/Modules/webaudio/AudioPannerNode.h 2012-07-31 19:11:09 UTC (rev 124236)
+++ trunk/Source/WebCore/Modules/webaudio/AudioPannerNode.h 2012-07-31 19:14:07 UTC (rev 124237)
@@ -96,8 +96,8 @@
// Distance parameters
unsigned short distanceModel() { return m_distanceEffect.model(); }
- void setDistanceModel(unsigned short model) { m_distanceEffect.setModel(static_cast<DistanceEffect::ModelType>(model), true); }
-
+ void setDistanceModel(unsigned short, ExceptionCode&);
+
float refDistance() { return static_cast<float>(m_distanceEffect.refDistance()); }
void setRefDistance(float refDistance) { m_distanceEffect.setRefDistance(refDistance); }
Modified: trunk/Source/WebCore/Modules/webaudio/AudioPannerNode.idl (124236 => 124237)
--- trunk/Source/WebCore/Modules/webaudio/AudioPannerNode.idl 2012-07-31 19:11:09 UTC (rev 124236)
+++ trunk/Source/WebCore/Modules/webaudio/AudioPannerNode.idl 2012-07-31 19:14:07 UTC (rev 124237)
@@ -38,8 +38,7 @@
const unsigned short EXPONENTIAL_DISTANCE = 2;
// Default model for stereo is HRTF
- // FIXME: use unsigned short when glue generation supports it
- attribute unsigned long panningModel
+ attribute unsigned short panningModel
setter raises(DOMException);
// Uses a 3D cartesian coordinate system
@@ -48,7 +47,9 @@
void setVelocity(in float x, in float y, in float z);
// Distance model
- attribute unsigned long distanceModel; // FIXME: use unsigned short when glue generation supports it
+ attribute unsigned short distanceModel
+ setter raises(DOMException);
+
attribute float refDistance;
attribute float maxDistance;
attribute float rolloffFactor;