[Modern Media Controls] Turn media/modern-media-controls/ios-inline-media-controls...
[WebKit-https.git] / LayoutTests / media / element-containing-pip-video-going-into-fullscreen.html
1 <html>
2 <head>
3     <title>Test element containing pip video going into fullscreen should exit pip</title>
4     <script src="media-file.js"></script>
5     <script src="video-test.js"></script>
6     <script>
7         if (window.internals)
8             window.internals.settings.setAllowsPictureInPictureMediaPlayback(true);
9
10         var enteredFullscreen = false;
11         var exitedPIP = false;
12
13         function init()
14         {
15             findMediaElement();
16             video.addEventListener('canplaythrough', oncanplaythrough);
17             video.src = findMediaFile('video', 'content/test');
18         }
19
20         function oncanplaythrough()
21         {
22             if (!('webkitSupportsPresentationMode' in video && 'webkitPresentationMode' in video)) {
23                 failTest("Presentation mode is not supported in this video element.")
24                 return;
25             }
26
27             consoleWrite("Video going into Picture-in-Picture");
28             video.addEventListener('webkitpresentationmodechanged', onfirstpresentationmodechanged);
29             runWithKeyDown(function(){ video.webkitSetPresentationMode('picture-in-picture'); });
30         }
31
32         function onfirstpresentationmodechanged()
33         {
34             testExpected("video.webkitPresentationMode", "picture-in-picture");
35             video.removeEventListener('webkitpresentationmodechanged', onfirstpresentationmodechanged);
36
37             consoleWrite("Element containing picture-in-picture video going into Full Screen");
38             videoContainer.addEventListener('webkitfullscreenchange', onfullscreenchange);
39             video.addEventListener('webkitpresentationmodechanged', onsecondpresentationmodechanged);
40             runWithKeyDown(function(){ videoContainer.webkitRequestFullscreen(); });
41         }
42
43         function onfullscreenchange()
44         {
45             enteredFullscreen = true;
46             if (exitedPIP)
47                 checkFinalState();
48         }
49
50         function onsecondpresentationmodechanged()
51         {
52             exitedPIP = true;
53             if (enteredFullscreen)
54                 checkFinalState();
55         }
56
57         function checkFinalState()
58         {
59             testExpected("document.webkitCurrentFullScreenElement", videoContainer);
60             testExpected("video.webkitPresentationMode", "inline");
61             endTest();
62         }
63
64     </script>
65 </head>
66 <body onload="init()">
67     Tests pip video going into fullscreen should exit pip<br>
68     <div id="videoContainer">
69         <video controls></video>
70     </div>
71 </body>
72 </html>
73