2 <title>Verifies preload=metadata doesn't buffer the entire clip.
</title>
3 <script src=
"../resources/testharness.js"></script>
4 <script src=
"../resources/testharnessreport.js"></script>
5 <script src=
"../../media-resources/media-file.js"></script>
7 <video controls preload=metadata
></video>
9 async_test(function(t
) {
10 var have_metadata
= false;
11 var waiting_for_metadata
= false;
12 var video
= document
.querySelector("video");
14 video
.onloadedmetadata
= t
.step_func(function() {
16 if (waiting_for_metadata
)
20 video
.onsuspend
= t
.step_func(function() {
21 // The metadata event may not fire before suspend occurs, so wait if needed;
22 // while not spec'd, it'd be nice if this wasn't true, see crbug.com/455866.
24 waiting_for_metadata
= true;
28 assert_equals(video
.buffered
.length
, 1);
29 assert_equals(video
.seekable
.length
, 1);
31 // If the entire clip wasn't buffered, the buffered range should be smaller
32 // than the seekable range; which should be the duration since the server
33 // supports range requests.
34 assert_true(video
.buffered
.end(0) < video
.duration
);
35 assert_equals(video
.seekable
.end(0), video
.duration
);
36 assert_true(video
.buffered
.end(0) < video
.seekable
.end(0),
37 video
.buffered
.end(0) + " < " + video
.seekable
.end(0));
41 // Use a .webm to ensure metadata is near the beginning of the file.
42 var mediaFile
= "resources/media-source/webm/test.webm";
43 video
.src
= "http://127.0.0.1:8000/media/video-throttled-load.cgi?" +
44 "nph=1&name=" + mediaFile
+ "&throttle=40&type=video/webm";