blob: c5cb4dc370eacb1fb6264e4c509a30772ff32319 [file] [log] [blame]
eric.carlson@apple.com10162952014-01-08 05:45:55 +00001<html>
2 <head>
3 <script src=media-file.js></script>
4 <script src=video-test.js></script>
5 <script>
6 var state = 0;
eric.carlson@apple.com8eea6112015-02-10 15:47:51 +00007 var resumeCount = 0;
eric.carlson@apple.com10162952014-01-08 05:45:55 +00008
9 function checkState()
10 {
eric.carlson@apple.com22d66602014-02-04 19:09:34 +000011 switch (state) {
12 case "playing":
13 testExpected("video.paused", false);
14 state = "interrupted";
bfulgham@apple.comc87aece2015-10-01 22:32:56 +000015 run("internals.beginMediaSessionInterruption('System')");;
eric.carlson@apple.com22d66602014-02-04 19:09:34 +000016 setTimeout(checkState, 100);
eric.carlson@apple.com10162952014-01-08 05:45:55 +000017 consoleWrite("");
eric.carlson@apple.com22d66602014-02-04 19:09:34 +000018 break;
eric.carlson@apple.com8eea6112015-02-10 15:47:51 +000019
eric.carlson@apple.com22d66602014-02-04 19:09:34 +000020 case "interrupted":
21 consoleWrite("100ms timer fired...");
22 testExpected("video.paused", true);
23 state = "resuming";
24 run("internals.endMediaSessionInterruption('MayResumePlaying')");
25 consoleWrite("");
26 break;
eric.carlson@apple.com8eea6112015-02-10 15:47:51 +000027
eric.carlson@apple.com22d66602014-02-04 19:09:34 +000028 case "resuming":
29 testExpected("video.paused", false);
30 consoleWrite("");
eric.carlson@apple.com8eea6112015-02-10 15:47:51 +000031 if (++resumeCount == 2)
32 endTest();
33 state = "playing";
34 setTimeout(checkState, 100);
eric.carlson@apple.com22d66602014-02-04 19:09:34 +000035 break;
eric.carlson@apple.com10162952014-01-08 05:45:55 +000036 }
eric.carlson@apple.com10162952014-01-08 05:45:55 +000037 }
38
39 function canplaythrough()
40 {
eric.carlson@apple.com22d66602014-02-04 19:09:34 +000041 state = "playing";
commit-queue@webkit.orga9f25132014-02-04 15:52:21 +000042 run("video.play()");
eric.carlson@apple.com22d66602014-02-04 19:09:34 +000043 consoleWrite("");
eric.carlson@apple.com10162952014-01-08 05:45:55 +000044 }
45
46 function start()
47 {
48 if (!window.internals) {
49 failTest('This test requires window.internals.');
50 return;
51 }
52
53 findMediaElement();
54 waitForEvent('canplaythrough', canplaythrough);
eric.carlson@apple.com22d66602014-02-04 19:09:34 +000055 waitForEvent('playing', checkState);
eric.carlson@apple.com10162952014-01-08 05:45:55 +000056 video.src = findMediaFile("video", "content/test");
57 }
58 </script>
59 </head>
60
61 <body onload="start()">
62 <video controls ></video>
63 <p>Test that play() during interruption does nothing, ending interruption allows playback to resume.</p>
64 </body>
65</html>