5 <script src=
"../resources/js-test.js"></script>
6 <script type=
"text/javascript" src=
"resources/audio-testing.js"></script>
7 <script src=
"resources/compatibility.js"></script>
11 <div id=
"description"></div>
12 <div id=
"console"></div>
15 description("Tests that AudioBufferSourceNode validates AudioBuffer in .buffer attribute setter.");
21 if (window
.testRunner
) {
22 testRunner
.dumpAsText();
23 testRunner
.waitUntilDone();
26 window
.jsTestIsAsync
= true;
28 context
= new AudioContext();
29 source
= context
.createBufferSource();
31 // Make sure we can't set to something which isn't an AudioBuffer.
32 shouldThrow("source.buffer = 57", '"TypeError: Failed to set the \'buffer\' property on \'AudioBufferSourceNode\': The provided value is not of type \'AudioBuffer\'."');
33 shouldThrow("source.buffer = null", '"TypeError: Failed to set the \'buffer\' property on \'AudioBufferSourceNode\': The provided value is not of type \'AudioBuffer\'."');
35 // Check that mono buffer can be set.
37 var monoBuffer
= context
.createBuffer(1, 1024, context
.sampleRate
);
38 var testSource
= context
.createBufferSource();
39 testSource
.buffer
= monoBuffer
;
40 testPassed("Mono buffer can be set.");
42 testFailed("Mono buffer can not be set.");
45 // Check that stereo buffer can be set.
47 var stereoBuffer
= context
.createBuffer(2, 1024, context
.sampleRate
);
48 var testSource
= context
.createBufferSource();
49 testSource
.buffer
= stereoBuffer
;
50 testPassed("Stereo buffer can be set.");
52 testFailed("Stereo buffer can not be set.");
55 // Check buffers with more than two channels.
56 for (var i
= 3; i
< 10; ++i
) {
58 var buffer
= context
.createBuffer(i
, 1024, context
.sampleRate
);
59 var testSource
= context
.createBufferSource();
60 testSource
.buffer
= buffer
;
61 var message
= i
+ " channels buffer can be set.";
64 var message
= i
+ " channels buffer can not be set.";