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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/constructor/audiobuffersource.html

Issue 2102133002: Add constructors for WebAudio nodes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update files to the right GN files. Created 4 years, 3 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
OLDNEW
(Empty)
1 <!doctype html>
2 <html>
3 <head>
4 <title>Test Constructor: AudioBufferSource</title>
5 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script>
7 <script src="../resources/compatibility.js"></script>
8 </head>
9
10 <body>
11 <script>
12 var context;
13
14 test(function () {
15 context = new OfflineAudioContext(1, 1, 48000);
16 assert_true(context instanceof AudioContext,
17 "context created successfully");
18 }, "Construct offline context");
19
20 test(function () {
21 assert_throws(null,
22 function () {
23 return new AudioBufferSourceNode();
24 }, "One argument required");
25 assert_throws(null,
26 function () {
27 return new AudioBufferSourceNode(1);
28 }, "Invalid context argument");
29 assert_throws(null,
30 function () {
31 return new AudioBufferSourceNode(context, 42);
32 }, "Second argument must be an object");
33 });
34
35 test(function () {
36 // Construct a default AnalyserNode
37 var node = new AudioBufferSourceNode(context);
38 assert_true(node instanceof AudioBufferSourceNode,
39 "new AudioBufferSourceNode(context)");
40 }, "Construct basic AudioBufferSourceNode");
41
42 test(function () {
43 // Construct an AudioBufferSourceNode with options
44 var buf = context.createBuffer(1, 1, context.sampleRate);
45 var options = {
46 buffer: buf,
47 detune: 1,
48 loop: true,
49 loopEnd: 0.5,
50 loopStart: 1.0,
51 playbackRate: .25
52 };
53 var node = new AudioBufferSourceNode(context, options);
54 assert_true(node instanceof AudioBufferSourceNode,
55 "new AudioBufferSourceNode(context, options)");
56 // Verify node has the correct values.
57 assert_equals(node.buffer, options.buffer);
58 assert_equals(node.detune.value, options.detune);
59 assert_equals(node.loop, options.loop);
60 assert_equals(node.loopEnd, options.loopEnd);
61 assert_equals(node.loopStart, options.loopStart);
62 assert_equals(node.playbackRate.value, options.playbackRate);
63 }, "Construct AudioBufferSourceNode with options");
64 </script>
65 </body>
66 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698