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

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: move click simulation to top frame Created 4 years, 2 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><span>click me</span></body>
3 <script>
4 function synthesizeClick(callback) {
5 document.onclick = callback;
6 window.parent.postMessage({ msg: 'clickme' }, '*');
7 }
8
9 // AudioContext will start as suspended when lacking a user gesture.
10 var audioContext = new AudioContext();
11 window.parent.postMessage({ msg: 'initialState', value: audioContext.state },
12 '*');
13
14 // OfflineAudioContext has no user gesture requirement but is always suspended.
15 var offlineAudioContext = new OfflineAudioContext(1, 512, 3000);
16 window.parent.postMessage({ msg: 'initialOfflineState',
17 value: offlineAudioContext.state }, '*');
18
19 // Calling 'resume()' will fail to start the AudioContext.
20 audioContext.resume();
21 window.parent.postMessage({ msg: 'afterResume', value: audioContext.state },
22 '*');
23
24 // Calling 'start()' will fail to start the AudioContext associated.
25 var oscillator = audioContext.createOscillator();
26 oscillator.type = 'square';
27 oscillator.frequency.value = 2000;
28 oscillator.connect(audioContext.destination);
29 oscillator.start();
30 window.parent.postMessage({ msg: 'afterOscillator', value: audioContext.state },
31 '*');
32
33 var otherAudioContext = new AudioContext();
34
35 synthesizeClick(_ => {
36 // Calling 'resume()' from a click event will start the audio context.
37 audioContext.resume();
38 window.parent.postMessage({ msg: 'stateAfterClick',
39 value: audioContext.state }, '*');
40
41 window.parent.postMessage({ msg: 'stateOtherContextAfterClick',
42 value: otherAudioContext.state }, '*');
43
44 synthesizeClick(_ => {
45 var oscillator = otherAudioContext.createOscillator();
46 oscillator.type = 'square';
47 oscillator.frequency.value = 2000;
48 oscillator.connect(otherAudioContext.destination);
49 // Calling 'start()' from a click event will not start the audio context.
50 oscillator.start();
51
52 window.parent.postMessage({ msg: 'stateOtherContextAfterSecondClick',
53 value: otherAudioContext.state }, '*');
54
55 synthesizeClick(_ => {
56 // Creating an AudioContext from a click event will start it.
57 var lastAudioContext = new AudioContext();
58 window.parent.postMessage({ msg: 'stateCreatedAfterClick',
59 value: lastAudioContext.state }, '*');
60
61 window.parent.postMessage({ msg: 'done' }, '*');
62 });
63 });
64 });
65 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698