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

Unified Diff: third_party/WebKit/LayoutTests/webaudio/panner-distance-clamping.html

Issue 2512793003: Throw RangeError for invalid refDistance/maxDistance (Closed)
Patch Set: Rebase Created 4 years 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 | « no previous file | third_party/WebKit/Source/modules/webaudio/PannerNode.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/webaudio/panner-distance-clamping.html
diff --git a/third_party/WebKit/LayoutTests/webaudio/panner-distance-clamping.html b/third_party/WebKit/LayoutTests/webaudio/panner-distance-clamping.html
index c3f21923e3d55d6206f9a2a30a99a647dbe9fef5..6f456936180eb94f4e45e65cbba3d959568136d2 100644
--- a/third_party/WebKit/LayoutTests/webaudio/panner-distance-clamping.html
+++ b/third_party/WebKit/LayoutTests/webaudio/panner-distance-clamping.html
@@ -15,6 +15,64 @@
var audit = Audit.createTaskRunner();
+ audit.defineTask("ref-distance-error", function (taskDone) {
+ testDistanceLimits({name: "refDistance"});
+ taskDone();
+ });
+
+ audit.defineTask("max-distance-error", function (taskDone) {
+ testDistanceLimits({name: "maxDistance"});
+ taskDone();
+ });
+
+ function testDistanceLimits(options) {
+ // Verify that exceptions are thrown for invalid values of refDistance.
+ var context = new OfflineAudioContext(1, renderFrames, sampleRate);
+
+ var attrName = options.name;
+ var prefix = "new PannerNode(c, {" + attrName + ": ";
+
+ success = Should(prefix + "-1})", function () {
+ var nodeOptions = {};
+ nodeOptions[attrName] = -1;
+ new PannerNode(context, nodeOptions);
+ }).throw("RangeError");
+
+ success = Should(prefix + "0})", function () {
+ var nodeOptions = {};
+ nodeOptions[attrName] = 0;
+ new PannerNode(context, nodeOptions);
+ }).throw("RangeError") && success;
+
+ // The smallest representable positive single float.
+ var leastPositiveDoubleFloat = 4.9406564584124654e-324;
+
+ success = Should(prefix + leastPositiveDoubleFloat + "})",
+ function () {
+ var nodeOptions = {};
+ nodeOptions[attrName] = leastPositiveDoubleFloat;
+ new PannerNode(context, nodeOptions);
+ }).notThrow() && success;
+
+ prefix = "panner." + attrName + " = ";
+ panner = new PannerNode(context);
+ success = Should(prefix + "-1", function () {
+ panner[attrName] = -1;
+ }).throw("RangeError") && success;
+
+ success = Should(prefix + "0", function () {
+ panner[attrName] = 0;
+ }).throw("RangeError") && success;
+
+ success = Should(prefix + leastPositiveDoubleFloat, function () {
+ panner[attrName] = leastPositiveDoubleFloat;
+ }).notThrow() && success;
+
+ Should("Invalid " + attrName + " values handled", success)
+ .summarize("correctly", "incorrectly");
+
+ }
+
audit.defineTask("min-distance", function (taskDone) {
// Test clamping of panner distance to refDistance for all of the
// distance models. The actual distance is arbitrary as long as it's
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/webaudio/PannerNode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698