Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-precise-duration.html

Issue 2581533002: MSE: Fix logic bugs with high precision duration (Closed)
Patch Set: Feedback Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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 </head>
8 <body>
9 <div id="log"></div>
10 <script>
11 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour ce, segmentInfo, sourceBuffer, mediaData)
12 {
13 // Set duration .5 nanoseconds higher than known duration. Interna lly, most user
14 // agents do not represent media time with sub-nanosecond precisio n, so this attempts
15 // to catch edge cases arising from data type conversions.
16 let increased_duration = segmentInfo.duration + /* .5 nanoseconds */ .0000000005;
17 mediaSource.duration = increased_duration;
18
19 // Expect duration to exactly match what was set.
20 assert_equals(mediaSource.duration, increased_duration);
21
22 // Append media data.
23 test.expectEvent(sourceBuffer, "updateend");
24 sourceBuffer.appendBuffer(mediaData);
25 test.waitForExpectedEvents(function()
26 {
27 // Appending all data should not change the duration because s et duration is
28 // already larger than segmentInfo metadata (and we trust segm entInfo has an
29 // accurate duration - see mediasource-duration.html).
30 assert_equals(mediaSource.duration, increased_duration);
31
32 // Marking end of stream should cause duration to be reduced t o match highest
33 // buffered end time.
34 mediaSource.endOfStream();
35
36 assert_equals(mediaElement.buffered.length, 1);
37 assert_equals(mediaSource.duration, mediaElement.buffered.end( 0));
38
39 // Play the last half second of media to verify 'ended' event is observed. The
40 // ended event should be triggered when currentTime >= duratio n, so ensure that
41 // earlier use of high-precision does not prevent this.
42 assert_greater_than(mediaSource.duration, .5);
43 mediaElement.currentTime = mediaSource.duration - .5;
44
45 test.expectEvent(mediaElement, "ended");
46 mediaElement.play();
47
48 test.waitForExpectedEvents(test.step_func_done());
49 });
50 }, "Test high precision duration is returned, then truncated upon endO fStream()");
51 </script>
52 </body>
53 </html>
OLDNEW
« no previous file with comments | « media/filters/chunk_demuxer.cc ('k') | third_party/WebKit/Source/core/html/HTMLMediaElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698