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

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: Created 4 years 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 <link rel='stylesheet' href='/w3c/resources/testharness.css'>
wolenetz 2016/12/16 00:56:52 this isn't necessary any longer
chcunningham 2017/01/03 17:48:05 Done.
8 </head>
9 <body>
10 <div id="log"></div>
11 <script>
12 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour ce, segmentInfo, sourceBuffer, mediaData)
13 {
14 // Set duration .5 nanoseconds higher than known duration. Interna lly, most user
15 // agents do not represent media time with sub-nanosecond precisio n, so this attempts
16 // to catch edge cases arising from data type conversions.
17 let increased_duration = segmentInfo.duration + /* .5 nanoseconds */ .0000000005;
mlamouri (slow - plz ping) 2016/12/15 10:20:51 Unless all mediasource-* tests are using `let`, I
chcunningham 2017/01/03 17:48:05 We have a lot of let usage already. https://cs.chr
18 mediaSource.duration = increased_duration;
19
20 // Expect duration to exactly match what was set.
21 assert_equals(mediaSource.duration, increased_duration);
22
23 // Append media data.
24 test.expectEvent(sourceBuffer, "updateend");
25 sourceBuffer.appendBuffer(mediaData);
26 test.waitForExpectedEvents(function()
mlamouri (slow - plz ping) 2016/12/15 10:20:51 Could this simply be: ``` sourceBuffer.addEventLis
chcunningham 2017/01/03 17:48:05 I started down this path but it makes the test les
27 {
28 // Appending all data should not change the duration because s et duration is
29 // already larger than segmentInfo metadata (and we trust segm entInfo has an
30 // accurate duration).
wolenetz 2016/12/16 00:56:52 Add comment reference to existing (or new) test th
chcunningham 2017/01/03 17:48:05 Done.
31 assert_equals(mediaSource.duration, increased_duration);
32
33 // Marking end of stream should cause duration to be reduced t o match highest
34 // buffered end time.
35 mediaSource.endOfStream();
36
37 assert_equals(mediaElement.buffered.length, 1);
38 assert_equals(mediaSource.duration, mediaElement.buffered.end( 0));
39
40 // Play the last half second of media to verify 'ended' event is observed. The
41 // ended event should be triggered when currentTime >= duratio n, so ensure that
42 // earlier use of high-precision does not prevent this.
43 assert_true(mediaSource.duration > .5);
mlamouri (slow - plz ping) 2016/12/15 10:20:52 assert_greater_than(mediaSource.duration, .5);
chcunningham 2017/01/03 17:48:05 Done.
44 mediaElement.currentTime = mediaSource.duration - .5;
45
46 test.expectEvent(mediaElement, "ended");
47 mediaElement.play();
48
49 test.waitForExpectedEvents(function()
mlamouri (slow - plz ping) 2016/12/15 10:20:51 same as above but I think you can even right a one
chcunningham 2017/01/03 17:48:05 simplified, but continued using the waitFor. See c
50 {
51 test.done();
52 })
53 });
54 }, "Test high precision duration is returned, then truncated upon endO fStream()");
55 </script>
56 </body>
57 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698