Add new access object callback
[framework/web/webkit-efl.git] / LayoutTests / media / video-preload.html
1 <!DOCTYPE HTML>
2
3 <html>
4     <head>
5         <script src=media-file.js></script>
6         <script src=video-test.js></script>
7
8         <script>
9             var timer = null;
10             var movieInfo = 
11             {
12                 current : -1,
13                 movies : 
14                 [ 
15                     {
16                         // should not buffer, 'preload' is 'none'
17                         preload : "none",
18                         shouldBuffer : false,
19                         autoPlay : false,
20                         description : "until 'play()' is called", 
21                     },
22                     {
23                         preload : "metadata",
24                         shouldBuffer : true,
25                         autoPlay : false,
26                         description : "", 
27                     },
28                     {
29                         preload : "auto",
30                         shouldBuffer : true,
31                         autoPlay : false,
32                         description : "", 
33                     },
34                     {
35                         // should buffer because 'autoplay' is set
36                         preload : "none",
37                         shouldBuffer : true,
38                         autoPlay : true,
39                         description : " because of 'autoplay'", 
40                     },
41                 ]
42             };
43             var timer = null;
44
45             function checkLoad()
46             {
47                 var movie = movieInfo.movies[movieInfo.current];
48
49                 logResult(true, "did not buffer automatically");
50                 
51                 // start playback, which should force data to load
52                 movie.shouldBuffer = true;
53                 run("video.play()");
54             }
55
56             function loadedmetadata()
57             {
58                 var movie = movieInfo.movies[movieInfo.current];
59
60                 clearTimeout(timer);
61                 logResult(movie.shouldBuffer, "buffered automatically");
62                 openNextMovie();
63             }
64
65             function setupAttribute(attr, value)
66             {
67                 if (value)
68                     run("video.setAttribute('" + attr + "', '" + value + "')");
69                 else
70                     run("video.removeAttribute('" + attr + "')");
71             }
72
73             function openNextMovie()
74             {
75                 consoleWrite("");
76
77                 movieInfo.current++;
78                 if (movieInfo.current >= movieInfo.movies.length)
79                 {
80                     endTest();
81                     return;
82                 }
83
84                 var movie = movieInfo.movies[movieInfo.current];
85                 var url = findMediaFile("video", "content/test");
86                 var desc = "Will load with <em>'preload=" + movie.preload + "'</em>"
87                             + ", <b>should" + (movie.shouldBuffer ? "" : " not") + " </b> buffer automatically "
88                             + movie.description;
89                 consoleWrite(desc);
90
91                 setupAttribute('preload', movie.preload);
92                 setupAttribute('autoplay', movie.autoPlay);
93
94                 video.src = url;
95                 if (movieInfo.current > 0)
96                     video.load();
97                 if (!movie.shouldBuffer)
98                     timer = setTimeout(checkLoad, 200);
99             }
100             
101             function start()
102             {
103                 findMediaElement();
104
105                 waitForEvent("error");
106                 waitForEvent("loadstart");
107                 waitForEvent("play");
108                 waitForEvent('loadedmetadata', loadedmetadata);
109             
110                 openNextMovie();
111             }
112
113         </script>
114     </head>
115
116     <body onload="start()">
117         <p>Test to see if media loads automatically when 'preload' is specified.</p>
118         <video controls ></video>
119     </body>
120 </html>