Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(562)

Unified Diff: third_party/WebKit/Source/modules/webaudio/AudioParam.cpp

Issue 1995583002: Throw exception for non-finite values in setValueCurve (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update expected results Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/webaudio/audioparam-setValueCurve-exceptions-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/webaudio/AudioParam.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/AudioParam.cpp b/third_party/WebKit/Source/modules/webaudio/AudioParam.cpp
index 309aa186cf6793732b6f4b2a0226bc6602be56b1..7a1d8bd52c1e7849369a5f0cf9b5e2ae4fc4a52f 100644
--- a/third_party/WebKit/Source/modules/webaudio/AudioParam.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/AudioParam.cpp
@@ -25,6 +25,7 @@
#include "modules/webaudio/AudioParam.h"
+#include "core/dom/ExceptionCode.h"
#include "core/inspector/ConsoleMessage.h"
#include "modules/webaudio/AudioNode.h"
#include "modules/webaudio/AudioNodeOutput.h"
@@ -454,15 +455,34 @@ AudioParam* AudioParam::setTargetAtTime(float target, double time, double timeCo
AudioParam* AudioParam::setValueCurveAtTime(DOMFloat32Array* curve, double time, double duration, ExceptionState& exceptionState)
{
- // Just find the first value in the curve (if any) that is outside the nominal range. It's
- // probably not necessary to produce a warning on every value outside the nominal range.
float* curveData = curve->data();
float min = minValue();
float max = maxValue();
+ // First, find any non-finite value in the curve and throw an exception if
+ // there are any.
for (unsigned k = 0; k < curve->length(); ++k) {
- if (curveData[k] < min || curveData[k] > max) {
- warnIfOutsideRange("setValueCurveAtTime value", curveData[k]);
+ float value = curveData[k];
+
+ if (!std::isfinite(value)) {
+ exceptionState.throwDOMException(
+ V8TypeError,
+ "The provided float value for the curve at element "
+ + String::number(k)
+ + " is non-finite: "
+ + String::number(value));
+ return nullptr;
+ }
+ }
+
+ // Second, find the first value in the curve (if any) that is outside the
+ // nominal range. It's probably not necessary to produce a warning on every
+ // value outside the nominal range.
+ for (unsigned k = 0; k < curve->length(); ++k) {
+ float value = curveData[k];
+
+ if (value < min || value > max) {
+ warnIfOutsideRange("setValueCurveAtTime value", value);
break;
}
}
« no previous file with comments | « third_party/WebKit/LayoutTests/webaudio/audioparam-setValueCurve-exceptions-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698