waveshaper-simple.html (2141B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title> 5 Simple Tests of WaveShaperNode 6 </title> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="../../resources/audit-util.js"></script> 10 <script src="../../resources/audit.js"></script> 11 </head> 12 <body> 13 <script id="layout-test-code"> 14 let audit = Audit.createTaskRunner(); 15 16 audit.define('simple', (task, should) => { 17 let context = new OfflineAudioContext(1, 1, 48000); 18 let shaper = context.createWaveShaper(); 19 20 // Verify default values are correct. 21 should(shaper.curve, 'Initial WaveShaper.curve').beEqualTo(null); 22 should(shaper.oversample, 'Initial WaveShaper.oversample') 23 .beEqualTo('none'); 24 25 // Set oversample and verify that it is set correctly. 26 should(() => shaper.oversample = '2x', 'Setting oversample to "2x"') 27 .notThrow(); 28 should(shaper.oversample, 'Waveshaper.oversample = "2x"') 29 .beEqualTo('2x'); 30 31 should(() => shaper.oversample = '4x', 'Setting oversample to "4x"') 32 .notThrow(); 33 should(shaper.oversample, 'Waveshaper.oversample = "4x"') 34 .beEqualTo('4x'); 35 36 should( 37 () => shaper.oversample = 'invalid', 38 'Setting oversample to "invalid"') 39 .notThrow(); 40 should(shaper.oversample, 'Waveshaper.oversample = "invalid"') 41 .beEqualTo('4x'); 42 43 // Set the curve and verify that the returned curve is the same as what 44 // it was set to. 45 let curve = Float32Array.from([-1, 0.25, .75]); 46 should(() => shaper.curve = curve, 'Setting curve to [' + curve + ']') 47 .notThrow(); 48 should(shaper.curve, 'WaveShaper.curve').beEqualToArray(curve); 49 50 // Verify setting the curve to null works. 51 should(() => shaper.curve = null, 'Setting curve back to null') 52 .notThrow(); 53 should(shaper.curve, 'Waveshaper.curve = null').beEqualTo(null); 54 55 task.done(); 56 }); 57 58 audit.run(); 59 </script> 60 </body> 61 </html>