https://bugs.webkit.org/show_bug.cgi?id=90952
Patch by Li Yin <li.yin@intel.com> 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.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@124237
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-07-31 Li Yin <li.yin@intel.com>
+
+ 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 <mvujovic@adobe.com>
[CSS Shaders] CSS parser rejects parameter names that are also CSS keywords
--- /dev/null
+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
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<script src="resources/audio-testing.js"></script>
+<script src="../fast/js/resources/js-test-pre.js"></script>
+</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="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
+++ /dev/null
-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
-
+++ /dev/null
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
- <head>
- <link rel="stylesheet" href="../fast/js/resources/js-test-style.css"/>
- <script src="resources/audio-testing.js"></script>
- <script src="../fast/js/resources/js-test-pre.js"></script>
- <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="../fast/js/resources/js-test-post.js"></script>
- </body>
-</html>
+2012-07-31 Li Yin <li.yin@intel.com>
+
+ 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 <mvujovic@adobe.com>
[CSS Shaders] CSS parser rejects parameter names that are also CSS keywords
}
}
+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.
// 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); }
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
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;