| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <title> |
| 5 mediastreamaudiosourcenode.html |
| 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(); |
| 2 | 15 |
| 3 <html> | 16 audit.define( |
| 4 <head> | 17 { |
| 5 <script src="../../resources/testharness.js"></script> | 18 label: 'test', |
| 6 <script src="../../resources/testharnessreport.js"></script> | 19 description: 'Basic tests for MediaStreamAudioSourceNode API' |
| 7 <script src="../resources/audit-util.js"></script> | 20 }, |
| 8 <script src="../resources/audit.js"></script> | 21 (task, should) => { |
| 9 </head> | 22 should( |
| 23 () => {navigator.webkitGetUserMedia( |
| 24 {audio: true}, |
| 25 (stream) => { |
| 26 gotStream(stream, should); |
| 27 task.done(); |
| 28 }, |
| 29 () => { |
| 30 should(false, 'Stream generation') |
| 31 .message('succeeded', 'failed'); |
| 32 task.done(); |
| 33 })}, |
| 34 'getUserMedia()') |
| 35 .notThrow(); |
| 36 }); |
| 10 | 37 |
| 11 <body> | 38 audit.run(); |
| 12 <script> | |
| 13 let audit = Audit.createTaskRunner(); | |
| 14 | 39 |
| 15 audit.define( | 40 function gotStream(stream, should) { |
| 16 { | 41 should(true, '{audio:true} generated stream').message('correctly', ''); |
| 17 label: 'test', | |
| 18 description: 'Basic tests for MediaStreamAudioSourceNode API' | |
| 19 }, | |
| 20 (task, should) => { | |
| 21 should( | |
| 22 () => {navigator.webkitGetUserMedia( | |
| 23 {audio: true}, | |
| 24 (stream) => { | |
| 25 gotStream(stream, should); | |
| 26 task.done(); | |
| 27 }, | |
| 28 () => { | |
| 29 should(false, 'Stream generation') | |
| 30 .message('succeeded', 'failed'); | |
| 31 task.done(); | |
| 32 })}, | |
| 33 'getUserMedia()') | |
| 34 .notThrow(); | |
| 35 }); | |
| 36 | 42 |
| 37 audit.run(); | 43 let context = new AudioContext(); |
| 38 | 44 |
| 39 function gotStream(stream, should) { | 45 // Create an AudioNode from the stream. |
| 40 should(true, '{audio:true} generated stream').message('correctly', ''); | 46 let mediaStreamSource = context.createMediaStreamSource(stream); |
| 41 | 47 |
| 42 let context = new AudioContext(); | 48 // Check number of inputs and outputs. |
| 49 should( |
| 50 mediaStreamSource.numberOfInputs, |
| 51 'mediaStreamSource.numberOfInputs') |
| 52 .beEqualTo(0); |
| 53 should( |
| 54 mediaStreamSource.numberOfOutputs, |
| 55 'mediaStreamSource.numberOfOutputs') |
| 56 .beEqualTo(1); |
| 43 | 57 |
| 44 // Create an AudioNode from the stream. | 58 // Verify the same object is returned |
| 45 let mediaStreamSource = context.createMediaStreamSource(stream); | 59 let element = mediaStreamSource.mediaStream; |
| 60 should( |
| 61 element instanceof MediaStream, |
| 62 'mediaStreamSource.mediaStream instanceof MediaStream') |
| 63 .beTrue(); |
| 64 should( |
| 65 mediaStreamSource.mediaStream === element, |
| 66 'mediaStreamSource.mediaStream is same object') |
| 67 .beTrue(); |
| 46 | 68 |
| 47 // Check number of inputs and outputs. | 69 // Try calling connect() method with illegal values. |
| 48 should(mediaStreamSource.numberOfInputs, 'mediaStreamSource.numberOfInputs') | 70 should( |
| 49 .beEqualTo(0); | 71 () => mediaStreamSource.connect(0, 0, 0), |
| 50 should(mediaStreamSource.numberOfOutputs, 'mediaStreamSource.numberOfOutputs') | 72 'mediaStreamSource.connect(0, 0, 0)') |
| 51 .beEqualTo(1); | 73 .throw(); |
| 74 should( |
| 75 () => mediaStreamSource.connect(context.destination, 5, 0), |
| 76 'mediaStreamSource.connect(context.destination, 5, 0)') |
| 77 .throw(); |
| 78 should( |
| 79 () => mediaStreamSource.connect(context.destination, 0, 5), |
| 80 'mediaStreamSource.connect(context.destination, 0, 5)') |
| 81 .throw(); |
| 52 | 82 |
| 53 // Verify the same object is returned | 83 // Try calling connect() with proper values. |
| 54 let element = mediaStreamSource.mediaStream; | 84 should( |
| 55 should(element instanceof MediaStream, | 85 () => mediaStreamSource.connect(context.destination, 0, 0), |
| 56 'mediaStreamSource.mediaStream instanceof MediaStream') | 86 'mediaStreamSource.connect(context.destination, 0, 0)') |
| 57 .beTrue(); | 87 .notThrow(); |
| 58 should(mediaStreamSource.mediaStream === element, | 88 } |
| 59 'mediaStreamSource.mediaStream is same object') | 89 </script> |
| 60 .beTrue(); | 90 </body> |
| 61 | |
| 62 // Try calling connect() method with illegal values. | |
| 63 should( | |
| 64 () => mediaStreamSource.connect(0, 0, 0), | |
| 65 'mediaStreamSource.connect(0, 0, 0)') | |
| 66 .throw(); | |
| 67 should( | |
| 68 () => mediaStreamSource.connect(context.destination, 5, 0), | |
| 69 'mediaStreamSource.connect(context.destination, 5, 0)') | |
| 70 .throw(); | |
| 71 should( | |
| 72 () => mediaStreamSource.connect(context.destination, 0, 5), | |
| 73 'mediaStreamSource.connect(context.destination, 0, 5)') | |
| 74 .throw(); | |
| 75 | |
| 76 // Try calling connect() with proper values. | |
| 77 should( | |
| 78 () => mediaStreamSource.connect(context.destination, 0, 0), | |
| 79 'mediaStreamSource.connect(context.destination, 0, 0)') | |
| 80 .notThrow(); | |
| 81 } | |
| 82 | |
| 83 | |
| 84 </script> | |
| 85 | |
| 86 </body> | |
| 87 </html> | 91 </html> |
| OLD | NEW |