Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / media / video-preload.html
blobc3600405a5f37ea49283eac7cbec1e1863993eb3
1 <!DOCTYPE HTML>
3 <html>
4 <head>
5 <script src=media-file.js></script>
6 <script src=video-test.js></script>
8 <script>
9 var timer = null;
10 var movieInfo =
12 current : -1,
13 movies :
16 // should not buffer, 'preload' is 'none'
17 preload : "none",
18 shouldBuffer : false,
19 autoPlay : false,
20 playInsteadOfLoad : false,
21 description : "until 'play()' is called",
24 // should buffer, because load() is called.
25 preload : "none",
26 shouldBuffer : true,
27 autoPlay : false,
28 playInsteadOfLoad : false,
29 description : "because 'load()' is called",
32 // should buffer, because play() is called.
33 preload : "none",
34 shouldBuffer : true,
35 autoPlay : false,
36 playInsteadOfLoad : true,
37 description : "because 'play()' is called",
40 preload : "metadata",
41 shouldBuffer : true,
42 autoPlay : false,
43 playInsteadOfLoad : false,
44 description : "",
47 preload : "auto",
48 shouldBuffer : true,
49 autoPlay : false,
50 playInsteadOfLoad : false,
51 description : "",
54 // should buffer because 'autoplay' is set
55 preload : "none",
56 shouldBuffer : true,
57 autoPlay : true,
58 playInsteadOfLoad : false,
59 description : " because of 'autoplay'",
63 var timer = null;
65 function checkLoad()
67 var movie = movieInfo.movies[movieInfo.current];
69 logResult(true, "did not buffer automatically");
71 // start playback, which should force data to load
72 movie.shouldBuffer = true;
73 run("video.play()");
76 function loadedmetadata()
78 var movie = movieInfo.movies[movieInfo.current];
80 clearTimeout(timer);
81 logResult(movie.shouldBuffer, "buffered automatically");
82 openNextMovie();
85 function setupAttribute(attr, value)
87 if (value)
88 run("video.setAttribute('" + attr + "', '" + value + "')");
89 else
90 run("video.removeAttribute('" + attr + "')");
93 function openNextMovie()
95 consoleWrite("");
97 movieInfo.current++;
98 if (movieInfo.current >= movieInfo.movies.length)
100 endTest();
101 return;
104 var movie = movieInfo.movies[movieInfo.current];
105 var url = findMediaFile("video", "content/test");
106 var desc = "Will load with <em>'preload=" + movie.preload + "'</em>"
107 + ", <b>should" + (movie.shouldBuffer ? "" : " not") + " </b> buffer automatically "
108 + movie.description;
109 consoleWrite(desc);
111 setupAttribute('preload', movie.preload);
112 setupAttribute('autoplay', movie.autoPlay);
114 video.src = url;
115 if (movieInfo.current > 0) {
116 if (movie.playInsteadOfLoad) {
117 run("video.play()");
118 } else {
119 run("video.load()");
122 if (!movie.shouldBuffer)
123 timer = setTimeout(checkLoad, 200);
126 function start()
128 findMediaElement();
130 waitForEvent("error");
131 waitForEvent("loadstart");
132 waitForEvent("play");
133 waitForEvent('loadedmetadata', loadedmetadata);
135 openNextMovie();
138 </script>
139 </head>
141 <body onload="start()">
142 <p>Test to see if media loads automatically when 'preload' is specified.</p>
143 <video controls ></video>
144 </body>
145 </html>