71940c937648712cf5950789d8127f2a114873ac
[WebKit-https.git] / LayoutTests / media / controls / ipad / close-page-with-picture-in-picture-video-assertion-failure.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../resources/js-test-pre.js"></script>
5 <script>
6 window.jsTestIsAsync = true;
7
8 var child;
9
10 if (window.testRunner) {
11     testRunner.setCanOpenWindows(true);
12     testRunner.setCloseRemainingWindowsWhenComplete(true);
13 }
14
15 // Called by resources/picture-in-picture.html
16 function notifyDidChangePresentationMode()
17 {
18     // For some reason waiting ~200ms to allow the video to transition from the page to its
19     // picture-in-picture window seems to make triggering the assertion more reliable (why?).
20     function closeWindowAndDone()
21     {
22         child.close(); // Trigger assertion failure
23         testPassed("did not cause an assertion failure.");
24         // For some reason waiting ~500ms after closing the window seems to make triggering the assertion more reliable (why?).
25         window.setTimeout(finishJSTest, 500);
26     }
27     window.setTimeout(closeWindowAndDone, 200);
28 }
29
30 function openNewWindow()
31 {
32     child = window.open("resources/picture-in-picture.html");
33     document.body.removeChild(openNewWindowButton);
34 }
35
36 window.onload = function () {
37     var openNewWindowButton = document.getElementById("openNewWindowButton");
38     if (window.testRunner)
39         openNewWindow();
40     else
41         openNewWindowButton.onclick = openNewWindow;
42 }
43 </script>
44 </head>
45 <body>
46 <p id="description"></p>
47 <div id="console"></div>
48 <script>
49 description("This tests that closing a window that is presenting a video in picture-in-picture does not cause an assertion failure in a debug build. To run this test by hand, click the Open new window button then click the picture-in-picture button (tap the video on iOS).");
50 </script>
51 <button id="openNewWindowButton">Open new window</button>
52 <script src="../../../resources/js-test-post.js"></script>
53 </body>
54 </html>