Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/webaudio/resources/autoplay-crossorigin-iframe.html

Issue 2314903002: Web Audio: when media playback requires a user gesture, apply rule to cross origin iframes. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <body></body>
3 <script>
4 function synthesizeClick(callback) {
5 var button = document.createElement('input');
6 button.type = 'button';
7 button.value = 'click me';
8 button.onclick = callback;
9 document.body.appendChild(button);
10
11 if ('eventSender' in window) {
12 var boundingRect = button.getBoundingClientRect();
13 var x = boundingRect.left + boundingRect.width / 2;
14 var y = boundingRect.top + boundingRect.height / 2;
15
16 eventSender.mouseMoveTo(x, y);
17 eventSender.mouseDown();
18 eventSender.mouseUp();
19 }
20 // else, the user should manually click.
21 }
22
23 var audioContext = new AudioContext();
24 window.parent.postMessage({ msg: 'initialState', value: audioContext.state },
25 '*');
26
27 audioContext.resume();
28 window.parent.postMessage({ msg: 'afterResume', value: audioContext.state },
29 '*');
30
31 var oscillator = audioContext.createOscillator();
32 oscillator.type = 'square';
33 oscillator.frequency.value = 2000;
34 oscillator.connect(audioContext.destination);
35 oscillator.start();
36 window.parent.postMessage({ msg: 'afterOscillator', value: audioContext.state },
37 '*');
38
39 var otherAudioContext = new AudioContext();
40
41 synthesizeClick(_ => {
42 audioContext.resume();
43 window.parent.postMessage({ msg: 'stateAfterClick',
44 value: audioContext.state }, '*');
45
46 window.parent.postMessage({ msg: 'stateOtherContextAfterClick',
47 value: otherAudioContext.state }, '*');
48
49 synthesizeClick(_ => {
50 var oscillator = otherAudioContext.createOscillator();
51 oscillator.type = 'square';
52 oscillator.frequency.value = 2000;
53 oscillator.connect(otherAudioContext.destination);
54 oscillator.start();
55
56 window.parent.postMessage({ msg: 'stateOtherContextAfterSecondClick',
57 value: otherAudioContext.state }, '*');
58
59 window.parent.postMessage({ msg: 'done' }, '*');
60 });
61 });
62 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698