[Modern Media Controls] Turn media/modern-media-controls/ios-inline-media-controls...
[WebKit-https.git] / LayoutTests / media / airplay-autoplay.html
1 <!DOCTYPE html><!-- webkit-test-runner [ enableModernMediaControls=false ] -->
2 <html>
3 <head>
4     <title>AirPlay target should persist across src change</title>
5     <script src="media-file.js"></script>
6     <script src="video-test.js"></script>
7     <script>
8
9     var phase = 'video-1';
10
11     function start() 
12     {
13         findMediaElement();
14
15         consoleWrite('** set video.src');
16         run(`video.src = findMediaFile('video', 'content/test')`);
17         video.addEventListener('webkitcurrentplaybacktargetiswirelesschanged', currentTargetChanged, true);
18         waitForEventOnce('canplaythrough', canplaythrough);
19         waitForEventOnce('ended', ended);
20         consoleWrite('');
21     }
22
23     function canplaythrough()
24     {
25         consoleWrite('<br>** simulate choosing a device from the menu');
26         runWithKeyDown(function() {
27             run(`video.webkitShowPlaybackTargetPicker()`);
28             setTimeout(function() {
29                 if (window.internals)
30                     internals.setMockMediaPlaybackTargetPickerState('Sleepy TV', 'DeviceAvailable');
31             }, 100);
32         });
33         video.currentTime = video.duration - 1;
34     }
35
36     function currentTargetChanged(ev)
37     {
38         if (!video.webkitCurrentPlaybackTargetIsWireless)
39             return;
40
41         consoleWrite(`EVENT(${ev.type})`);
42         switch (phase) {
43         case 'video-1':
44             phase = 'video-2';
45             consoleWrite('<br>** start playing');
46             run(`video.play()`);
47             consoleWrite('');
48             break;
49         case 'video-2':
50             endTest();
51             break;
52         }
53     }
54
55     function ended()
56     {
57         consoleWrite('<br>** reset video source');
58         run(`video.src = findMediaFile('video', 'content/test')`);
59         run(`video.play()`);
60         consoleWrite('');
61     }
62
63     </script>
64 </head>
65 <body onload="start()">
66     <video controls></video>
67 </body>
68 </html>