Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-precise-duration.html |
| diff --git a/third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-precise-duration.html b/third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-precise-duration.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..166deb189d747b973856a0c64e16f0dce8da04f4 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-precise-duration.html |
| @@ -0,0 +1,57 @@ |
| +<!DOCTYPE html> |
| +<html> |
| + <head> |
| + <script src="/w3c/resources/testharness.js"></script> |
| + <script src="/w3c/resources/testharnessreport.js"></script> |
| + <script src="mediasource-util.js"></script> |
| + <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.
|
| + </head> |
| + <body> |
| + <div id="log"></div> |
| + <script> |
| + mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData) |
| + { |
| + // Set duration .5 nanoseconds higher than known duration. Internally, most user |
| + // agents do not represent media time with sub-nanosecond precision, so this attempts |
| + // to catch edge cases arising from data type conversions. |
| + 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
|
| + mediaSource.duration = increased_duration; |
| + |
| + // Expect duration to exactly match what was set. |
| + assert_equals(mediaSource.duration, increased_duration); |
| + |
| + // Append media data. |
| + test.expectEvent(sourceBuffer, "updateend"); |
| + sourceBuffer.appendBuffer(mediaData); |
| + 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
|
| + { |
| + // Appending all data should not change the duration because set duration is |
| + // already larger than segmentInfo metadata (and we trust segmentInfo has an |
| + // 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.
|
| + assert_equals(mediaSource.duration, increased_duration); |
| + |
| + // Marking end of stream should cause duration to be reduced to match highest |
| + // buffered end time. |
| + mediaSource.endOfStream(); |
| + |
| + assert_equals(mediaElement.buffered.length, 1); |
| + assert_equals(mediaSource.duration, mediaElement.buffered.end(0)); |
| + |
| + // Play the last half second of media to verify 'ended' event is observed. The |
| + // ended event should be triggered when currentTime >= duration, so ensure that |
| + // earlier use of high-precision does not prevent this. |
| + 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.
|
| + mediaElement.currentTime = mediaSource.duration - .5; |
| + |
| + test.expectEvent(mediaElement, "ended"); |
| + mediaElement.play(); |
| + |
| + 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
|
| + { |
| + test.done(); |
| + }) |
| + }); |
| + }, "Test high precision duration is returned, then truncated upon endOfStream()"); |
| + </script> |
| + </body> |
| +</html> |