Index: third_party/WebKit/LayoutTests/webaudio/AudioNode/audionode-connect-method-chaining.html |
diff --git a/third_party/WebKit/LayoutTests/webaudio/AudioNode/audionode-connect-method-chaining.html b/third_party/WebKit/LayoutTests/webaudio/AudioNode/audionode-connect-method-chaining.html |
index 9a51b963151de366145583bc9cae2aee8666fc0c..abd0da0884a4f23ea00d3531bfe0a4a9591f2320 100644 |
--- a/third_party/WebKit/LayoutTests/webaudio/AudioNode/audionode-connect-method-chaining.html |
+++ b/third_party/WebKit/LayoutTests/webaudio/AudioNode/audionode-connect-method-chaining.html |
@@ -1,159 +1,164 @@ |
<!DOCTYPE html> |
<html> |
- |
-<head> |
- <script src="../../resources/testharness.js"></script> |
- <script src="../../resources/testharnessreport.js"></script> |
- <script src="../resources/audit-util.js"></script> |
- <script src="../resources/audit.js"></script> |
-</head> |
- |
-<body> |
- <script> |
- |
- // AudioNode dictionary with associated arguments. |
- var nodeDictionary = [ |
- { name: 'Analyser' }, |
- { name: 'BiquadFilter' }, |
- { name: 'BufferSource' }, |
- { name: 'ChannelMerger', args: [6] }, |
- { name: 'ChannelSplitter', args: [6] }, |
- { name: 'Convolver' }, |
- { name: 'Delay', args: [] }, |
- { name: 'DynamicsCompressor' }, |
- { name: 'Gain' }, |
- { name: 'Oscillator' }, |
- { name: 'Panner' }, |
- { name: 'ScriptProcessor', args: [512, 1, 1] }, |
- { name: 'StereoPanner' }, |
- { name: 'WaveShaper' } |
- ]; |
- |
- |
- function verifyReturnedNode(should, config) { |
- should(config.destination === config.returned, |
- 'The return value of ' + config.desc + |
- ' matches the destination ' + |
- config.returned.constructor.name) |
- .beEqualTo(true); |
- } |
- |
- // Test utility for batch method checking: in order to test 3 method |
- // signatures, so we create 3 dummy destinations. |
- // 1) .connect(GainNode) |
- // 2) .connect(BiquadFilterNode, output) |
- // 3) .connect(ChannelMergerNode, output, input) |
- function testConnectMethod(context, should, options) { |
- var source = context['create' + options.name].apply(context, options.args); |
- var sourceName = source.constructor.name; |
- |
- var destination1 = context.createGain(); |
- verifyReturnedNode(should, { |
- source: source, |
- destination: destination1, |
- returned: source.connect(destination1), |
- desc: sourceName + '.connect(' + destination1.constructor.name + ')' |
- }); |
- |
- var destination2 = context.createBiquadFilter(); |
- verifyReturnedNode(should, { |
- source: source, |
- destination: destination2, |
- returned: source.connect(destination2, 0), |
- desc: sourceName + '.connect(' + destination2.constructor.name + ', 0)' |
+ <head> |
+ <title> |
+ audionode-connect-method-chaining.html |
+ </title> |
+ <script src="../../resources/testharness.js"></script> |
+ <script src="../../resources/testharnessreport.js"></script> |
+ <script src="../resources/audit-util.js"></script> |
+ <script src="../resources/audit.js"></script> |
+ </head> |
+ <body> |
+ <script id="layout-test-code"> |
+ // AudioNode dictionary with associated arguments. |
+ let nodeDictionary = [ |
+ {name: 'Analyser'}, {name: 'BiquadFilter'}, {name: 'BufferSource'}, |
+ {name: 'ChannelMerger', args: [6]}, |
+ {name: 'ChannelSplitter', args: [6]}, {name: 'Convolver'}, |
+ {name: 'Delay', args: []}, {name: 'DynamicsCompressor'}, {name: 'Gain'}, |
+ {name: 'Oscillator'}, {name: 'Panner'}, |
+ {name: 'ScriptProcessor', args: [512, 1, 1]}, {name: 'StereoPanner'}, |
+ {name: 'WaveShaper'} |
+ ]; |
+ |
+ |
+ function verifyReturnedNode(should, config) { |
+ should( |
+ config.destination === config.returned, |
+ 'The return value of ' + config.desc + ' matches the destination ' + |
+ config.returned.constructor.name) |
+ .beEqualTo(true); |
+ } |
+ |
+ // Test utility for batch method checking: in order to test 3 method |
+ // signatures, so we create 3 dummy destinations. |
+ // 1) .connect(GainNode) |
+ // 2) .connect(BiquadFilterNode, output) |
+ // 3) .connect(ChannelMergerNode, output, input) |
+ function testConnectMethod(context, should, options) { |
+ let source = |
+ context['create' + options.name].apply(context, options.args); |
+ let sourceName = source.constructor.name; |
+ |
+ let destination1 = context.createGain(); |
+ verifyReturnedNode(should, { |
+ source: source, |
+ destination: destination1, |
+ returned: source.connect(destination1), |
+ desc: sourceName + '.connect(' + destination1.constructor.name + ')' |
+ }); |
+ |
+ let destination2 = context.createBiquadFilter(); |
+ verifyReturnedNode(should, { |
+ source: source, |
+ destination: destination2, |
+ returned: source.connect(destination2, 0), |
+ desc: |
+ sourceName + '.connect(' + destination2.constructor.name + ', 0)' |
+ }); |
+ |
+ let destination3 = context.createChannelMerger(); |
+ verifyReturnedNode(should, { |
+ source: source, |
+ destination: destination3, |
+ returned: source.connect(destination3, 0, 1), |
+ desc: sourceName + '.connect(' + destination3.constructor.name + |
+ ', 0, 1)' |
+ }); |
+ } |
+ |
+ |
+ let audit = Audit.createTaskRunner(); |
+ |
+ // Task: testing entries from the dictionary. |
+ audit.define('from-dictionary', (task, should) => { |
+ let context = new AudioContext(); |
+ |
+ for (let i = 0; i < nodeDictionary.length; i++) |
+ testConnectMethod(context, should, nodeDictionary[i]); |
+ |
+ task.done(); |
}); |
- var destination3 = context.createChannelMerger(); |
- verifyReturnedNode(should, { |
- source: source, |
- destination: destination3, |
- returned: source.connect(destination3, 0, 1), |
- desc: sourceName + '.connect(' + destination3.constructor.name + ', 0, 1)' |
- }); |
- } |
- |
- |
- var audit = Audit.createTaskRunner(); |
- |
- // Task: testing entries from the dictionary. |
- audit.define('from-dictionary', (task, should) => { |
- var context = new AudioContext(); |
- |
- for (var i = 0; i < nodeDictionary.length; i++) |
- testConnectMethod(context, should, nodeDictionary[i]); |
- |
- task.done(); |
- }); |
- |
- // Task: testing Media* nodes. |
- audit.define('media-group', (task, should) => { |
- var context = new AudioContext(); |
- |
- // Test MediaElementSourceNode needs an <audio> element. |
- var mediaElement = document.createElement('audio'); |
- testConnectMethod(context, should, { name: 'MediaElementSource', args: [mediaElement] }); |
+ // Task: testing Media* nodes. |
+ audit.define('media-group', (task, should) => { |
+ let context = new AudioContext(); |
- testConnectMethod(context, should, { name: 'MediaStreamDestination' }); |
+ // Test MediaElementSourceNode needs an <audio> element. |
+ let mediaElement = document.createElement('audio'); |
+ testConnectMethod( |
+ context, should, |
+ {name: 'MediaElementSource', args: [mediaElement]}); |
- // MediaStreamSourceNode requires 'stream' object to be constructed, which |
- // is a part of MediaStreamDestinationNode. |
- var streamDestination = context.createMediaStreamDestination(); |
- var stream = streamDestination.stream; |
- testConnectMethod(context, should, { name: 'MediaStreamSource', args: [stream] }); |
+ testConnectMethod(context, should, {name: 'MediaStreamDestination'}); |
- task.done(); |
- }); |
+ // MediaStreamSourceNode requires 'stream' object to be constructed, |
+ // which is a part of MediaStreamDestinationNode. |
+ let streamDestination = context.createMediaStreamDestination(); |
+ let stream = streamDestination.stream; |
+ testConnectMethod( |
+ context, should, {name: 'MediaStreamSource', args: [stream]}); |
- // Task: test the exception thrown by invalid operation. |
- audit.define('invalid-operation', (task, should) => { |
- var contextA = new AudioContext(); |
- var contextB = new AudioContext(); |
- var gain1 = contextA.createGain(); |
- var gain2 = contextA.createGain(); |
- |
- // Test if the first connection throws correctly. The first gain node does |
- // not have the second output, so it should throw. |
- should(function () { |
- gain1.connect(gain2, 1).connect(contextA.destination); |
- }, 'Connecting with an invalid output').throw('IndexSizeError'); |
- |
- // Test if the second connection throws correctly. The contextB's |
- // destination is not compatible with the nodes from contextA, thus the |
- // first connection succeeds but the second one should throw. |
- should(function () { |
- gain1.connect(gain2).connect(contextB.destination); |
- }, 'Connecting to a node from the different context').throw('InvalidAccessError'); |
- |
- task.done(); |
- }); |
- |
- // Task: verify if the method chaining actually works. |
- audit.define('verification', (task, should) => { |
- // We pick the lowest sample rate allowed to run the test efficiently. |
- var context = new OfflineAudioContext(1, 128, 3000); |
- |
- var constantBuffer = createConstantBuffer(context, 1, 1.0); |
- |
- var source = context.createBufferSource(); |
- source.buffer = constantBuffer; |
- source.loop = true; |
- |
- var gain1 = context.createGain(); |
- gain1.gain.value = 0.5; |
- var gain2 = context.createGain(); |
- gain2.gain.value = 0.25; |
- |
- source.connect(gain1).connect(gain2).connect(context.destination); |
- source.start(); |
+ task.done(); |
+ }); |
- context.startRendering().then(function (buffer) { |
- should(buffer.getChannelData(0), 'The output of chained connection of gain nodes') |
- .beConstantValueOf(0.125); |
- }).then(() => task.done()); |
- }); |
+ // Task: test the exception thrown by invalid operation. |
+ audit.define('invalid-operation', (task, should) => { |
+ let contextA = new AudioContext(); |
+ let contextB = new AudioContext(); |
+ let gain1 = contextA.createGain(); |
+ let gain2 = contextA.createGain(); |
+ |
+ // Test if the first connection throws correctly. The first gain node |
+ // does not have the second output, so it should throw. |
+ should(function() { |
+ gain1.connect(gain2, 1).connect(contextA.destination); |
+ }, 'Connecting with an invalid output').throw('IndexSizeError'); |
+ |
+ // Test if the second connection throws correctly. The contextB's |
+ // destination is not compatible with the nodes from contextA, thus the |
+ // first connection succeeds but the second one should throw. |
+ should( |
+ function() { |
+ gain1.connect(gain2).connect(contextB.destination); |
+ }, |
+ 'Connecting to a node from the different context') |
+ .throw('InvalidAccessError'); |
+ |
+ task.done(); |
+ }); |
- audit.run(); |
- </script> |
-</body> |
+ // Task: verify if the method chaining actually works. |
+ audit.define('verification', (task, should) => { |
+ // We pick the lowest sample rate allowed to run the test efficiently. |
+ let context = new OfflineAudioContext(1, 128, 3000); |
+ |
+ let constantBuffer = createConstantBuffer(context, 1, 1.0); |
+ |
+ let source = context.createBufferSource(); |
+ source.buffer = constantBuffer; |
+ source.loop = true; |
+ |
+ let gain1 = context.createGain(); |
+ gain1.gain.value = 0.5; |
+ let gain2 = context.createGain(); |
+ gain2.gain.value = 0.25; |
+ |
+ source.connect(gain1).connect(gain2).connect(context.destination); |
+ source.start(); |
+ |
+ context.startRendering() |
+ .then(function(buffer) { |
+ should( |
+ buffer.getChannelData(0), |
+ 'The output of chained connection of gain nodes') |
+ .beConstantValueOf(0.125); |
+ }) |
+ .then(() => task.done()); |
+ }); |
+ audit.run(); |
+ </script> |
+ </body> |
</html> |