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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/audioparam-setValueCurve-exceptions.html

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, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webaudio/audioparam-setValueCurve-exceptions-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!doctype html> 1 <!doctype html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Test Exceptions from setValueCurveAtTime</title> 4 <title>Test Exceptions from setValueCurveAtTime</title>
5 <script src="../resources/js-test.js"></script> 5 <script src="../resources/js-test.js"></script>
6 <script src="resources/compatibility.js"></script> 6 <script src="resources/compatibility.js"></script>
7 <script src="resources/audio-testing.js"></script> 7 <script src="resources/audio-testing.js"></script>
8 </head> 8 </head>
9 9
10 <body> 10 <body>
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // Now try to setValueCurve that overlaps each of the above automations 98 // Now try to setValueCurve that overlaps each of the above automations
99 startTime = timeInterval / 2; 99 startTime = timeInterval / 2;
100 100
101 for (var k = 0; k < 4; ++k) { 101 for (var k = 0; k < 4; ++k) {
102 var time = startTime + timeInterval * k; 102 var time = startTime + timeInterval * k;
103 success = Should("setValueCurveAtTime(curve, " + time + ", 0.01)", fun ction () { 103 success = Should("setValueCurveAtTime(curve, " + time + ", 0.01)", fun ction () {
104 g.gain.setValueCurveAtTime(curve, time, 0.01); 104 g.gain.setValueCurveAtTime(curve, time, 0.01);
105 }).throw("NotSupportedError") && success; 105 }).throw("NotSupportedError") && success;
106 } 106 }
107 107
108 // Elements of setValueCurve should be finite.
109 success = Should("setValueCurveAtTime([NaN, NaN], " + time + ", 0.01)", function () {
110 g.gain.setValueCurveAtTime(Float32Array.from([NaN, NaN]), time, 0.01);
111 }).throw("TypeError") && success;
112
113 success = Should("setValueCurveAtTime([1, Infinity], " + time + ", 0.01) ", function () {
114 g.gain.setValueCurveAtTime(Float32Array.from([1, Infinity]), time, 0.0 1);
115 }).throw("TypeError") && success;
116
117 var d = context.createDelay();
118 // Check that we get warnings for out-of-range values and also throw for
119 // non-finite values.
120 success = Should("delayTime.setValueCurveAtTime([1, 5], " + time + ", 0. 01)", function() {
121 d.delayTime.setValueCurveAtTime(Float32Array.from([1, 5]), time, 0.01) ;
122 }).notThrow() && success;
123
124 success = Should("delayTime.setValueCurveAtTime([1, 5, Infinity], " + ti me + ", 0.01)",
125 function() {
126 d.delayTime.setValueCurveAtTime(Float32Array.from([1, 5, Infinity]), time, 0.01);
127 }).throw("TypeError") && success;
128
108 // One last test that prints out lots of digits for the time. 129 // One last test that prints out lots of digits for the time.
109 var time = Math.PI / 100; 130 var time = Math.PI / 100;
110 success = Should("setValueCurveAtTime(curve, " + time + ", 0.01)", funct ion () { 131 success = Should("setValueCurveAtTime(curve, " + time + ", 0.01)", funct ion () {
111 g.gain.setValueCurveAtTime(curve, time, 0.01); 132 g.gain.setValueCurveAtTime(curve, time, 0.01);
112 }).throw("NotSupportedError") && success; 133 }).throw("NotSupportedError") && success;
113 134
114 var prefix = "setValueCurve overlapping existing automation functions"; 135 var prefix = "setValueCurve overlapping existing automation functions";
115 if (success) 136 if (success)
116 testPassed(prefix + " correctly signaled errors.\n"); 137 testPassed(prefix + " correctly signaled errors.\n");
117 else 138 else
118 testFailed(prefix + " failed to signal errors.\n"); 139 testFailed(prefix + " failed to signal errors.\n");
119 140
120 done(); 141 done();
121 }); 142 });
122 143
144 audit.defineTask("catch-exception", function (done) {
145 // Verify that the curve isn't inserted into the time line even if we ca tch the exception.
146 var success = true;
147 var context = new OfflineAudioContext(1, testDurationFrames, sampleRate) ;
148 var gain = context.createGain();
149 var source = context.createBufferSource();
150 var buffer = context.createBuffer(1, 1, context.sampleRate);
151 buffer.getChannelData(0)[0] = 1;
152 source.buffer = buffer;
153 source.loop = true;
154
155 source.connect(gain);
156 gain.connect(context.destination);
157
158 gain.gain.setValueAtTime(1, 0);
159 try {
160 // The value curve has an invalid element. This automation shouldn't b e inserted into the
161 // timeline at all.
162 gain.gain.setValueCurveAtTime(Float32Array.from([0, NaN]), 128 / conte xt.sampleRate, .5);
163 } catch (e) {
164 };
165 source.start();
166
167 context.startRendering().then(function (resultBuffer) {
168 // Since the setValueCurve wasn't inserted, the output should be exact ly 1 for the entire
169 // duration.
170 var success = Should("Handled setValueCurve exception so output", resu ltBuffer.getChannelData(0))
171 .beConstantValueOf(1);
172
173 if (success)
174 testPassed("setValueCurveAtTime correctly not inserted into timeline .\n");
175 else
176 testFailed("setValueCurveAtTime incorrectly still inserted into time line.\n");
177 }).then(done);
178 });
179
123 audit.defineTask("start-end", function (done) { 180 audit.defineTask("start-end", function (done) {
124 var success = true; 181 var success = true;
125 var context = new OfflineAudioContext(1, testDurationFrames, sampleRate) ; 182 var context = new OfflineAudioContext(1, testDurationFrames, sampleRate) ;
126 var g = context.createGain(); 183 var g = context.createGain();
127 var curve = new Float32Array(2); 184 var curve = new Float32Array(2);
128 185
129 // Verify that a setValueCurve can start at the end of an automation. 186 // Verify that a setValueCurve can start at the end of an automation.
130 var time = 0; 187 var time = 0;
131 var timeInterval = testDurationSec / 50; 188 var timeInterval = testDurationSec / 50;
132 success = Should("setValueAtTime(1, " + time + ")", function () { 189 success = Should("setValueAtTime(1, " + time + ")", function () {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 </html> 255 </html>
199 256
200 257
201 258
202 259
203 260
204 261
205 262
206 263
207 264
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webaudio/audioparam-setValueCurve-exceptions-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698