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'
>
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
;
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");
57 test
.waitForExpectedEvents(function()
59 assert_false(sourceBuffer
.updating
, "sourceBuffer.updating");
61 mediaSource
.endOfStream();
64 test
.expectEvent(mediaElement
, "ended");
67 test
.waitForExpectedEvents(function()
69 assert_greater_than(timeUpdateCount
, 2, "timeUpdateCount");
72 }, "Test HTMLVideoElement.getVideoPlaybackQuality() with MediaSource API", {timeout
: 5000});