Index: third_party/WebKit/LayoutTests/webaudio/constructor/audiobuffersource.html |
diff --git a/third_party/WebKit/LayoutTests/webaudio/constructor/audiobuffersource.html b/third_party/WebKit/LayoutTests/webaudio/constructor/audiobuffersource.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d7c198386600d16a7a3f505eb636f942317f154d |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/webaudio/constructor/audiobuffersource.html |
@@ -0,0 +1,66 @@ |
+<!doctype html> |
+<html> |
+ <head> |
+ <title>Test Constructor: AudioBufferSource</title> |
+ <script src="../../resources/testharness.js"></script> |
+ <script src="../../resources/testharnessreport.js"></script> |
+ <script src="../resources/compatibility.js"></script> |
+ </head> |
+ |
+ <body> |
+ <script> |
+ var context; |
+ |
+ test(function () { |
+ context = new OfflineAudioContext(1, 1, 48000); |
+ assert_true(context instanceof AudioContext, |
+ "context created successfully"); |
+ }, "Construct offline context"); |
+ |
+ test(function () { |
+ assert_throws(null, |
+ function () { |
+ return new AudioBufferSourceNode(); |
+ }, "One argument required"); |
+ assert_throws(null, |
+ function () { |
+ return new AudioBufferSourceNode(1); |
+ }, "Invalid context argument"); |
+ assert_throws(null, |
+ function () { |
+ return new AudioBufferSourceNode(context, 42); |
+ }, "Second argument must be an object"); |
+ }); |
+ |
+ test(function () { |
+ // Construct a default AnalyserNode |
+ var node = new AudioBufferSourceNode(context); |
+ assert_true(node instanceof AudioBufferSourceNode, |
+ "new AudioBufferSourceNode(context)"); |
+ }, "Construct basic AudioBufferSourceNode"); |
+ |
+ test(function () { |
+ // Construct an AudioBufferSourceNode with options |
+ var buf = context.createBuffer(1, 1, context.sampleRate); |
+ var options = { |
+ buffer: buf, |
+ detune: 1, |
+ loop: true, |
+ loopEnd: 0.5, |
+ loopStart: 1.0, |
+ playbackRate: .25 |
+ }; |
+ var node = new AudioBufferSourceNode(context, options); |
+ assert_true(node instanceof AudioBufferSourceNode, |
+ "new AudioBufferSourceNode(context, options)"); |
+ // Verify node has the correct values. |
+ assert_equals(node.buffer, options.buffer); |
+ assert_equals(node.detune.value, options.detune); |
+ assert_equals(node.loop, options.loop); |
+ assert_equals(node.loopEnd, options.loopEnd); |
+ assert_equals(node.loopStart, options.loopStart); |
+ assert_equals(node.playbackRate.value, options.playbackRate); |
+ }, "Construct AudioBufferSourceNode with options"); |
+ </script> |
+ </body> |
+</html> |