Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / media / media-source / mediasource-getvideoplaybackquality.html
bloba8c37a023df904f44272a217f3582b3ff4b16888
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="/w3c/resources/testharness.js"></script>
5 <script src="/w3c/resources/testharnessreport.js"></script>
6 <script src="mediasource-util.js"></script>
7 <link rel='stylesheet' href='/w3c/resources/testharness.css'>
8 </head>
9 <body>
10 <div id="log"></div>
11 <script>
12 mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
14 var previousQuality = mediaElement.getVideoPlaybackQuality();
15 var timeUpdateCount = 0;
16 mediaElement.addEventListener("timeupdate", test.step_func(function (e)
18 var videoElement = e.target;
19 var newQuality = videoElement.getVideoPlaybackQuality();
21 assert_not_equals(previousQuality, newQuality, "Verify new object");
22 assert_greater_than(newQuality.creationTime, previousQuality.creationTime, "creationTime");
24 assert_greater_than_equal(newQuality.totalVideoFrames, 0, "totalVideoFrames >= 0");
25 assert_greater_than_equal(newQuality.totalVideoFrames, previousQuality.totalVideoFrames, "totalVideoFrames");
27 assert_greater_than_equal(newQuality.droppedVideoFrames, 0, "droppedVideoFrames >= 0");
28 assert_greater_than_equal(newQuality.droppedVideoFrames, previousQuality.droppedVideoFrames, "droppedVideoFrames");
30 assert_greater_than_equal(newQuality.corruptedVideoFrames, 0, "corruptedVideoFrames >= 0");
31 assert_greater_than_equal(newQuality.corruptedVideoFrames, previousQuality.corruptedVideoFrames, "corruptedVideoFrames");
32 previousQuality = newQuality;
33 timeUpdateCount++;
34 }));
36 test.failOnEvent(mediaElement, 'error');
38 test.expectEvent(sourceBuffer, "updatestart");
39 test.expectEvent(sourceBuffer, "update");
40 test.expectEvent(sourceBuffer, "updateend");
41 sourceBuffer.appendBuffer(mediaData);
42 assert_true(sourceBuffer.updating, "sourceBuffer.updating");
44 test.waitForExpectedEvents(function()
46 assert_false(sourceBuffer.updating, "sourceBuffer.updating");
48 test.expectEvent(sourceBuffer, "updatestart");
49 test.expectEvent(sourceBuffer, "update");
50 test.expectEvent(sourceBuffer, "updateend");
52 mediaSource.duration = 1;
54 assert_true(sourceBuffer.updating, "sourceBuffer.updating");
55 });
57 test.waitForExpectedEvents(function()
59 assert_false(sourceBuffer.updating, "sourceBuffer.updating");
61 mediaSource.endOfStream();
62 mediaElement.play();
64 test.expectEvent(mediaElement, "ended");
65 });
67 test.waitForExpectedEvents(function()
69 assert_greater_than(timeUpdateCount, 2, "timeUpdateCount");
70 test.done();
71 });
72 }, "Test HTMLVideoElement.getVideoPlaybackQuality() with MediaSource API", {timeout: 5000});
73 </script>
74 </body>
75 </html>