| 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..508ec2ce93ba75e95aa0c7754f586bef6ee78cdf
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/http/tests/webaudio/resources/autoplay-crossorigin-iframe.html
|
| @@ -0,0 +1,62 @@
|
| +<!DOCTYPE html>
|
| +<body></body>
|
| +<script>
|
| +function synthesizeClick(callback) {
|
| + var button = document.createElement('input');
|
| + button.type = 'button';
|
| + button.value = 'click me';
|
| + button.onclick = callback;
|
| + document.body.appendChild(button);
|
| +
|
| + if ('eventSender' in window) {
|
| + var boundingRect = button.getBoundingClientRect();
|
| + var x = boundingRect.left + boundingRect.width / 2;
|
| + var y = boundingRect.top + boundingRect.height / 2;
|
| +
|
| + eventSender.mouseMoveTo(x, y);
|
| + eventSender.mouseDown();
|
| + eventSender.mouseUp();
|
| + }
|
| + // else, the user should manually click.
|
| +}
|
| +
|
| +var audioContext = new AudioContext();
|
| +window.parent.postMessage({ msg: 'initialState', value: audioContext.state },
|
| + '*');
|
| +
|
| +audioContext.resume();
|
| +window.parent.postMessage({ msg: 'afterResume', value: audioContext.state },
|
| + '*');
|
| +
|
| +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(_ => {
|
| + 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);
|
| + oscillator.start();
|
| +
|
| + window.parent.postMessage({ msg: 'stateOtherContextAfterSecondClick',
|
| + value: otherAudioContext.state }, '*');
|
| +
|
| + window.parent.postMessage({ msg: 'done' }, '*');
|
| + });
|
| +});
|
| +</script>
|
|
|