OLD | NEW |
---|---|
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title> | 4 <title> |
5 audiobuffersource-channels.html | 5 audiobuffersource-channels.html |
6 </title> | 6 </title> |
7 <script src="../../resources/testharness.js"></script> | 7 <script src="../../resources/testharness.js"></script> |
8 <script src="../../resources/testharnessreport.js"></script> | 8 <script src="../../resources/testharnessreport.js"></script> |
9 <script src="../resources/audit-util.js"></script> | 9 <script src="../resources/audit-util.js"></script> |
10 <script src="../resources/audit.js"></script> | 10 <script src="../resources/audit.js"></script> |
(...skipping 12 matching lines...) Expand all Loading... | |
23 }, | 23 }, |
24 function(task, should) { | 24 function(task, should) { |
25 context = new AudioContext(); | 25 context = new AudioContext(); |
26 source = context.createBufferSource(); | 26 source = context.createBufferSource(); |
27 | 27 |
28 // Make sure we can't set to something which isn't an AudioBuffer. | 28 // Make sure we can't set to something which isn't an AudioBuffer. |
29 should(function() { | 29 should(function() { |
30 source.buffer = 57; | 30 source.buffer = 57; |
31 }, 'source.buffer = 57').throw('TypeError'); | 31 }, 'source.buffer = 57').throw('TypeError'); |
32 | 32 |
33 // It's ok to set the buffer to null. | |
33 should(function() { | 34 should(function() { |
34 source.buffer = null; | 35 source.buffer = null; |
35 }, 'source.buffer = null').throw('TypeError'); | 36 }, 'source.buffer = null').notThrow(); |
37 | |
38 // Set the buffer to a valid AudioBuffer | |
39 let buffer = | |
40 new AudioBuffer({length: 128, sampleRate: context.sampleRate}); | |
41 | |
42 should(function() { | |
hongchan
2017/07/28 18:45:32
We prefer |()=>| over |function()|.
Raymond Toy
2017/07/28 19:16:55
I was fallowing the existing code which was using
| |
43 source.buffer = buffer; | |
44 }, 'source.buffer = buffer').notThrow(); | |
45 | |
46 // The buffer has been set; we can't set it again. | |
47 should(function() { | |
48 source.buffer = | |
49 new AudioBuffer({length: 128, sampleRate: context.sampleRate}) | |
50 }, 'source.buffer = new buffer').throw('InvalidStateError'); | |
51 | |
52 // The buffer has been set; it's ok to set it to null. | |
53 should(function() { | |
54 source.buffer = null; | |
55 }, 'source.buffer = null again').notThrow(); | |
56 | |
57 // The buffer was already set (and set to null). Can't set it | |
58 // again. | |
59 should(function() { | |
60 source.buffer = buffer; | |
61 }, 'source.buffer = buffer again').throw('InvalidStateError'); | |
62 | |
63 // But setting to null is ok. | |
64 should(function() { | |
65 }, 'source.buffer = null after setting to null').notThrow(); | |
36 | 66 |
37 // Check that mono buffer can be set. | 67 // Check that mono buffer can be set. |
38 should(function() { | 68 should(function() { |
39 let monoBuffer = | 69 let monoBuffer = |
40 context.createBuffer(1, 1024, context.sampleRate); | 70 context.createBuffer(1, 1024, context.sampleRate); |
41 let testSource = context.createBufferSource(); | 71 let testSource = context.createBufferSource(); |
42 testSource.buffer = monoBuffer; | 72 testSource.buffer = monoBuffer; |
43 }, 'Setting source with mono buffer').notThrow(); | 73 }, 'Setting source with mono buffer').notThrow(); |
44 | 74 |
45 // Check that stereo buffer can be set. | 75 // Check that stereo buffer can be set. |
(...skipping 12 matching lines...) Expand all Loading... | |
58 testSource.buffer = buffer; | 88 testSource.buffer = buffer; |
59 }, 'Setting source with ' + i + ' channels buffer').notThrow(); | 89 }, 'Setting source with ' + i + ' channels buffer').notThrow(); |
60 } | 90 } |
61 task.done(); | 91 task.done(); |
62 }); | 92 }); |
63 | 93 |
64 audit.run(); | 94 audit.run(); |
65 </script> | 95 </script> |
66 </body> | 96 </body> |
67 </html> | 97 </html> |
OLD | NEW |