| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <title> |
| 5 audionode.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 <div id="description"></div> |
| 14 <div id="console"></div> |
| 15 <script id="layout-test-code"> |
| 16 let audit = Audit.createTaskRunner(); |
| 2 | 17 |
| 3 <html> | 18 let context = 0; |
| 4 <head> | 19 let context2 = 0; |
| 5 <script src="../../resources/testharness.js"></script> | 20 let context3 = 0; |
| 6 <script src="../../resources/testharnessreport.js"></script> | |
| 7 <script src="../resources/audit-util.js"></script> | |
| 8 <script src="../resources/audit.js"></script> | |
| 9 </head> | |
| 10 | 21 |
| 11 <body> | 22 audit.define( |
| 12 <div id="description"></div> | 23 {label: 'test', description: 'Basic tests for AudioNode API.'}, |
| 13 <div id="console"></div> | 24 function(task, should) { |
| 14 | 25 |
| 15 <script> | 26 context = new AudioContext(); |
| 16 let audit = Audit.createTaskRunner(); | 27 window.audioNode = context.createBufferSource(); |
| 17 | 28 |
| 18 let context = 0; | 29 // Check input and output numbers of AudioSourceNode. |
| 19 let context2 = 0; | 30 should(audioNode.numberOfInputs, 'AudioBufferSource.numberOfInputs') |
| 20 let context3 = 0; | 31 .beEqualTo(0); |
| 32 should( |
| 33 audioNode.numberOfOutputs, 'AudioBufferSource.numberOfOutputs') |
| 34 .beEqualTo(1); |
| 21 | 35 |
| 22 audit.define({ | 36 // Check input and output numbers of AudioDestinationNode |
| 23 label: 'test', | 37 should( |
| 24 description: 'Basic tests for AudioNode API.' | 38 context.destination.numberOfInputs, |
| 25 }, function(task, should) { | 39 'AudioContext.destination.numberOfInputs') |
| 40 .beEqualTo(1); |
| 41 should( |
| 42 context.destination.numberOfOutputs, |
| 43 'AudioContext.destination.numberOfOutputs') |
| 44 .beEqualTo(0); |
| 26 | 45 |
| 27 context = new AudioContext(); | 46 // Try calling connect() method with illegal values. |
| 28 window.audioNode = context.createBufferSource(); | 47 should( |
| 48 () => audioNode.connect(0, 0, 0), 'audioNode.connect(0, 0, 0)') |
| 49 .throw('TypeError'); |
| 50 should( |
| 51 () => audioNode.connect(null, 0, 0), |
| 52 'audioNode.connect(null, 0, 0)') |
| 53 .throw('TypeError'); |
| 54 should( |
| 55 () => audioNode.connect(context.destination, 5, 0), |
| 56 'audioNode.connect(context.destination, 5, 0)') |
| 57 .throw('IndexSizeError'); |
| 58 should( |
| 59 () => audioNode.connect(context.destination, 0, 5), |
| 60 'audioNode.connect(context.destination, 0, 5)') |
| 61 .throw('IndexSizeError'); |
| 29 | 62 |
| 30 // Check input and output numbers of AudioSourceNode. | 63 should( |
| 31 should(audioNode.numberOfInputs, 'AudioBufferSource.numberOfInputs') | 64 () => audioNode.connect(context.destination, 0, 0), |
| 32 .beEqualTo(0); | 65 'audioNode.connect(context.destination, 0, 0)') |
| 33 should(audioNode.numberOfOutputs, 'AudioBufferSource.numberOfOutputs') | 66 .notThrow(); |
| 34 .beEqualTo(1); | |
| 35 | 67 |
| 36 // Check input and output numbers of AudioDestinationNode | 68 // Create a new context and try to connect the other context's node |
| 37 should( | 69 // to this one. |
| 38 context.destination.numberOfInputs, | 70 context2 = new AudioContext(); |
| 39 'AudioContext.destination.numberOfInputs') | 71 should( |
| 40 .beEqualTo(1); | 72 () => window.audioNode.connect(context2.destination), |
| 41 should( | 73 'Connecting a node to a different context') |
| 42 context.destination.numberOfOutputs, | 74 .throw('InvalidAccessError'); |
| 43 'AudioContext.destination.numberOfOutputs') | |
| 44 .beEqualTo(0); | |
| 45 | 75 |
| 46 // Try calling connect() method with illegal values. | 76 // 3-arg AudioContext doesn't create an offline context anymore. |
| 47 should(() => audioNode.connect(0, 0, 0), 'audioNode.connect(0, 0, 0)') | 77 should( |
| 48 .throw('TypeError'); | 78 () => context3 = new AudioContext(1, 44100, 44100), |
| 49 should(() => audioNode.connect(null, 0, 0), 'audioNode.connect(null, 0, 0)') | 79 'context3 = new AudioContext(1, 44100, 44100)') |
| 50 .throw('TypeError'); | 80 .throw('TypeError'); |
| 51 should( | |
| 52 () => audioNode.connect(context.destination, 5, 0), | |
| 53 'audioNode.connect(context.destination, 5, 0)') | |
| 54 .throw('IndexSizeError'); | |
| 55 should( | |
| 56 () => audioNode.connect(context.destination, 0, 5), | |
| 57 'audioNode.connect(context.destination, 0, 5)') | |
| 58 .throw('IndexSizeError'); | |
| 59 | 81 |
| 60 should( | 82 // Ensure it is an EventTarget |
| 61 () => audioNode.connect(context.destination, 0, 0), | 83 should( |
| 62 'audioNode.connect(context.destination, 0, 0)') | 84 audioNode instanceof EventTarget, 'AudioNode is an EventTarget') |
| 63 .notThrow(); | 85 .beTrue(); |
| 64 | 86 |
| 65 // Create a new context and try to connect the other context's node to this | 87 task.done(); |
| 66 // one. | 88 }); |
| 67 context2 = new AudioContext(); | |
| 68 should( | |
| 69 () => window.audioNode.connect(context2.destination), | |
| 70 'Connecting a node to a different context') | |
| 71 .throw('InvalidAccessError'); | |
| 72 | 89 |
| 73 // 3-arg AudioContext doesn't create an offline context anymore. | 90 audit.run(); |
| 74 should( | 91 </script> |
| 75 () => context3 = new AudioContext(1, 44100, 44100), | 92 </body> |
| 76 'context3 = new AudioContext(1, 44100, 44100)') | |
| 77 .throw('TypeError'); | |
| 78 | |
| 79 // Ensure it is an EventTarget | |
| 80 should(audioNode instanceof EventTarget, 'AudioNode is an EventTarget') | |
| 81 .beTrue(); | |
| 82 | |
| 83 task.done(); | |
| 84 }); | |
| 85 | |
| 86 audit.run(); | |
| 87 </script> | |
| 88 | |
| 89 </body> | |
| 90 </html> | 93 </html> |
| OLD | NEW |