[Modern Media Controls] Turn media/modern-media-controls/ios-inline-media-controls...
[WebKit-https.git] / LayoutTests / media / video-restricted-no-preload-auto.html
1 <html>
2     <head>
3         <script src="media-file.js"></script>
4         <script src="video-test.js"></script>
5         <script>
6             var playCalled = false;
7
8             function canplaythrough()
9             {
10                 consoleWrite("");
11                 if (!playCalled)
12                     consoleWrite("*** FAIL: media data loaded before play() was called ***<br>");
13
14                 endTest();
15             }
16
17             function play()
18             {
19                 consoleWrite("** 250ms timer fired");
20                 testExpected("video.readyState", HTMLMediaElement.HAVE_CURRENT_DATA, "<");
21                 testExpected("video.buffered.length", 0, "==");
22                 playCalled = true;
23                 run("video.play()");
24                 consoleWrite("");
25             }
26
27             function loadedmetadata()
28             {
29                 testExpected("video.readyState", HTMLMediaElement.HAVE_CURRENT_DATA, "<");
30
31                 // Wait 250ms before play()ing to make sure setting src did not kick off the load.
32                 consoleWrite("** Pausing...<br>");
33                 setTimeout(play, 250);
34                 consoleWrite("");
35             }
36
37             function start()
38             {
39                 if (!window.internals) {
40                     failTest('This test requires window.internals.');
41                     return;
42                 }
43
44                 findMediaElement();
45                 consoleWrite("** setting video.src");
46                 video.src = findMediaFile("video", "content/test");
47
48                 testExpected("video.preload", "auto");
49                 waitForEvent('loadedmetadata', loadedmetadata);
50                 waitForEvent('canplaythrough', canplaythrough);
51                 failTestIn(2000);
52                 run("internals.setMediaElementRestrictions(video, 'AutoPreloadingNotPermitted')");
53                 consoleWrite("");
54             }
55         </script>
56     </head>
57
58     <body onload="start()">
59         <video controls preload=auto></video>
60         <p>Test that "no auto-loading restriction" only allows metadata to load in spite of preload='auto'.</p>
61     </body>
62 </html>