| Index: third_party/WebKit/LayoutTests/http/tests/webaudio/resources/autoplay-crossorigin-iframe.html
|
| diff --git a/third_party/WebKit/LayoutTests/http/tests/webaudio/resources/autoplay-crossorigin-iframe.html b/third_party/WebKit/LayoutTests/http/tests/webaudio/resources/autoplay-crossorigin-iframe.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f72d21a92959b5449cf65f65f104410ef7a2193d
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/http/tests/webaudio/resources/autoplay-crossorigin-iframe.html
|
| @@ -0,0 +1,65 @@
|
| +<!DOCTYPE html>
|
| +<body><span>click me</span></body>
|
| +<script>
|
| +function synthesizeClick(callback) {
|
| + document.onclick = callback;
|
| + window.parent.postMessage({ msg: 'clickme' }, '*');
|
| +}
|
| +
|
| +// AudioContext will start as suspended when lacking a user gesture.
|
| +var audioContext = new AudioContext();
|
| +window.parent.postMessage({ msg: 'initialState', value: audioContext.state },
|
| + '*');
|
| +
|
| +// OfflineAudioContext has no user gesture requirement but is always suspended.
|
| +var offlineAudioContext = new OfflineAudioContext(1, 512, 3000);
|
| +window.parent.postMessage({ msg: 'initialOfflineState',
|
| + value: offlineAudioContext.state }, '*');
|
| +
|
| +// Calling 'resume()' will fail to start the AudioContext.
|
| +audioContext.resume();
|
| +window.parent.postMessage({ msg: 'afterResume', value: audioContext.state },
|
| + '*');
|
| +
|
| +// Calling 'start()' will fail to start the AudioContext associated.
|
| +var oscillator = audioContext.createOscillator();
|
| +oscillator.type = 'square';
|
| +oscillator.frequency.value = 2000;
|
| +oscillator.connect(audioContext.destination);
|
| +oscillator.start();
|
| +window.parent.postMessage({ msg: 'afterOscillator', value: audioContext.state },
|
| + '*');
|
| +
|
| +var otherAudioContext = new AudioContext();
|
| +
|
| +synthesizeClick(_ => {
|
| + // Calling 'resume()' from a click event will start the audio context.
|
| + audioContext.resume();
|
| + window.parent.postMessage({ msg: 'stateAfterClick',
|
| + value: audioContext.state }, '*');
|
| +
|
| + window.parent.postMessage({ msg: 'stateOtherContextAfterClick',
|
| + value: otherAudioContext.state }, '*');
|
| +
|
| + synthesizeClick(_ => {
|
| + var oscillator = otherAudioContext.createOscillator();
|
| + oscillator.type = 'square';
|
| + oscillator.frequency.value = 2000;
|
| + oscillator.connect(otherAudioContext.destination);
|
| + // Calling 'start()' from a click event will not start the audio context.
|
| + oscillator.start();
|
| +
|
| + window.parent.postMessage({ msg: 'stateOtherContextAfterSecondClick',
|
| + value: otherAudioContext.state }, '*');
|
| +
|
| + synthesizeClick(_ => {
|
| + // Creating an AudioContext from a click event will start it.
|
| + var lastAudioContext = new AudioContext();
|
| + window.parent.postMessage({ msg: 'stateCreatedAfterClick',
|
| + value: lastAudioContext.state }, '*');
|
| +
|
| + window.parent.postMessage({ msg: 'done' }, '*');
|
| + });
|
| + });
|
| +});
|
| +</script>
|
|
|