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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/decode-audio-data-basic.html

Issue 2540373002: Merge M56: "Fail decodeAudioFileData() when duration is unknown." (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 <!doctype html> 1 <!doctype html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../resources/js-test.js"></script> 4 <script src="../resources/js-test.js"></script>
5 <script src="resources/compatibility.js"></script> 5 <script src="resources/compatibility.js"></script>
6 <script src="resources/audio-testing.js"></script> 6 <script src="resources/audio-testing.js"></script>
7 <title>Test decodeAudioData promises</title> 7 <title>Test decodeAudioData promises</title>
8 </head> 8 </head>
9 9
10 <body> 10 <body>
11 <script> 11 <script>
12 description("Basic tests for decodeAudioData promise."); 12 description("Basic tests for decodeAudioData promise.");
13 window.jsTestIsAsync = true; 13 window.jsTestIsAsync = true;
14 14
15 // Use offline context for decoding because we want a fixed know sample rate , independent of the 15 // Use offline context for decoding because we want a fixed know sample rate , independent of the
16 // hardware because the test file is encoded at 44.1 kHz. If we don't decod eAudioData will 16 // hardware because the test file is encoded at 44.1 kHz. If we don't decod eAudioData will
17 // resample the data messing up the assumptions in this test. The length is unimportant. 17 // resample the data messing up the assumptions in this test. The length is unimportant.
18 var context = new OfflineAudioContext(1, 1, 44100); 18 var context = new OfflineAudioContext(1, 1, 44100);
19 19
20 // Test files for decodeAudioData 20 // Test files for decodeAudioData
21 var validAudioFile = "resources/media/24bit-44khz.wav"; 21 var validAudioFile = "resources/media/24bit-44khz.wav";
22 var invalidAudioFile = "resources/media/invalid-audio-file.txt"; 22 var invalidAudioFile = "resources/media/invalid-audio-file.txt";
23 var invalidLiveStream = '../media/resources/test-live.webm';
23 24
24 // Decoded data from validAudioFile 25 // Decoded data from validAudioFile
25 var referenceDecodedAudioBuffer; 26 var referenceDecodedAudioBuffer;
26 // Encoded audio data for testing decodeAudioData after the context has been closed. 27 // Encoded audio data for testing decodeAudioData after the context has been closed.
27 var encodedAudioData; 28 var encodedAudioData;
28 // Decoded data from decodeAudioData after the context has been closed. 29 // Decoded data from decodeAudioData after the context has been closed.
29 var decodedAudioBufferAfterClose; 30 var decodedAudioBufferAfterClose;
30 31
31 // Utility to load an encoded audio file from |url| and decode it. |success | and |failure| are 32 // Utility to load an encoded audio file from |url| and decode it. |success | and |failure| are
32 // functions to handle the then and else cases of the promise returned by de codeAudioData. 33 // functions to handle the then and else cases of the promise returned by de codeAudioData.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 runDecode(url, 101 runDecode(url,
101 function (buffer) { 102 function (buffer) {
102 testFailed(prefix + "Incorrectly succeeded in decoding " + url); 103 testFailed(prefix + "Incorrectly succeeded in decoding " + url);
103 }, 104 },
104 function (e) { 105 function (e) {
105 testPassed(prefix + "Correctly failed to decode " + url + ": " + e.toS tring()); 106 testPassed(prefix + "Correctly failed to decode " + url + ": " + e.toS tring());
106 }, 107 },
107 done); 108 done);
108 }); 109 });
109 110
111 // Decode an invalid file (due to an unknown duration) and verify that the
112 // promise is rejected correctly.
113 audit.defineTask("decode-invalid-file-unknown-duration", function (done) {
114 var url = invalidLiveStream;
115 var prefix = "Decode invalid file with promise: ";
116 runDecode(url,
117 function (buffer) {
118 testFailed(prefix + "Incorrectly succeeded in decoding " + url);
119 },
120 function (e) {
121 testPassed(prefix + "Correctly failed to decode " + url + ": " + e.toS tring());
122 },
123 done);
124 });
125
110 // Decode a valid file and verify that the promise is fulfilled and the succ essCallback is 126 // Decode a valid file and verify that the promise is fulfilled and the succ essCallback is
111 // invoked and both have identical decode audio buffers. 127 // invoked and both have identical decode audio buffers.
112 audit.defineTask("promise-and-success-callback", function (done) { 128 audit.defineTask("promise-and-success-callback", function (done) {
113 var request = new XMLHttpRequest(); 129 var request = new XMLHttpRequest();
114 request.open("GET", validAudioFile, true); 130 request.open("GET", validAudioFile, true);
115 request.responseType = "arraybuffer"; 131 request.responseType = "arraybuffer";
116 132
117 request.onload = function () { 133 request.onload = function () {
118 var prefix = "Decoding valid file with promise and callback: "; 134 var prefix = "Decoding valid file with promise and callback: ";
119 // The buffer returned by the success callback 135 // The buffer returned by the success callback
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 .then(done, done); 219 .then(done, done);
204 }); 220 });
205 221
206 audit.defineTask("finish", function (done) { 222 audit.defineTask("finish", function (done) {
207 finishJSTest(); 223 finishJSTest();
208 done(); 224 done();
209 }); 225 });
210 226
211 audit.runTasks(); 227 audit.runTasks();
212 228
213 successfullyParsed = true; 229 successfullyParsed = true;
214 </script> 230 </script>
215 </body> 231 </body>
216 </html> 232 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698