| Index: third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-seekbar-buffer-with-currentTime.html
|
| diff --git a/third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-seekbar-buffer-with-currentTime.html b/third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-seekbar-buffer-with-currentTime.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..cbde364928c4d2fb3178a46f0dd3733af20f144b
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-seekbar-buffer-with-currentTime.html
|
| @@ -0,0 +1,107 @@
|
| +<!DOCTYPE html>
|
| +<html>
|
| + <head>
|
| +
|
| + <script>
|
| + // NOTE: For this to work in content shell, must comment
|
| + // RemoveProprietaryMediaTypesAndCodecsForTests() in shell_main_delegate.cc
|
| + force_mp4 = false;
|
| + if (force_mp4) {
|
| + // CREDIT: https://github.com/erkserkserks/h264ify
|
| + // var audioElem = document.createElement('audio');
|
| + // var origCanPlayType = audioElem.canPlayType.bind(audioElem);
|
| + // audioElem.__proto__.canPlayType = function(type) {
|
| + var origChecker = MediaSource.isTypeSupported.bind(MediaSource);
|
| + MediaSource.isTypeSupported = function(type) {
|
| + var disallowed_types = ['webm', 'vp8', 'vp9'];
|
| + // If video type is in disallowed_types, say we don't support them
|
| + for (var i = 0; i < disallowed_types.length; i++) {
|
| + if (type.indexOf(disallowed_types[i]) !== -1) return '';
|
| + }
|
| +
|
| + // Otherwise, ask the browser
|
| + return origChecker(type);
|
| + }
|
| + }
|
| + </script>
|
| + <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">
|
| + </head>
|
| + <body>
|
| + <script>
|
| + if (window.testRunner) {
|
| + testRunner.dumpPixelResults();
|
| + testRunner.waitUntilDone();
|
| + }
|
| +
|
| + // The most important part of this test is verifying correct painting of the seekbar
|
| + // with respect to currentTime and the buffered ranges. Use an audio tag to ensure
|
| + // controls show persistently without mouse hover. Don't remove the element when the
|
| + // test completes.
|
| + test_properties = { audio_only: true, remove_element_when_done: false };
|
| +
|
| +
|
| + mediasource_test(function(test, mediaElement, mediaSource)
|
| + {
|
| + // Force controls to show.
|
| + mediaElement.controls = true;
|
| +
|
| + // Fetch an audio file using the appropriate manifest.
|
| + var subType = MediaSourceUtil.getSubType(MediaSourceUtil.AUDIO_ONLY_TYPE);
|
| + var mediaDataManifest = subType + '/test-a-128k-44100Hz-1ch-manifest.json';
|
| + MediaSourceUtil.fetchManifestAndData(test, mediaDataManifest, function(manifest_type, mediaData) {
|
| +
|
| + // Once fetched, append the whole file.
|
| + var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_ONLY_TYPE);
|
| + test.expectEvent(sourceBuffer, 'updateend', 'append completed');
|
| + test.expectEvent(mediaElement, 'loadedmetadata', 'got metadata');
|
| + test.expectEvent(mediaElement, 'canplaythrough', 'can play through');
|
| +
|
| + sourceBuffer.appendBuffer(mediaData);
|
| + test.waitForExpectedEvents(function()
|
| + {
|
| + // Explicitly set duration (not truncating) to make duration same for webm
|
| + // and mp4 files.
|
| + test.expectEvent(mediaElement, 'durationchange', 'duration changed');
|
| + mediaSource.duration = 2.1;
|
| + test.waitForExpectedEvents(function()
|
| + {
|
| + // One buffered range for full content duration.
|
| + assert_equals(mediaElement.buffered.length, 1);
|
| + assert_equals(Math.round(mediaElement.duration), 2);
|
| +
|
| + // Remove some media in the middle to create two buffered ranges.
|
| + sourceBuffer.remove(.5, 1);
|
| + test.expectEvent(sourceBuffer, 'updateend', 'remove completed');
|
| +
|
| + test.waitForExpectedEvents(function()
|
| + {
|
| + mediaSource.endOfStream();
|
| +
|
| + // Now two buffered ranges.
|
| + assert_equals(mediaElement.buffered.length, 2);
|
| +
|
| + // Seek near the end and play to end.
|
| + mediaElement.currentTime = 1.75;
|
| + mediaElement.play();
|
| +
|
| + // Wait for ended and conclude the test.
|
| + test.expectEvent(mediaElement, 'ended', 'playback ended');
|
| + test.waitForExpectedEvents(function(){
|
| + // Pass the test asserts.
|
| + test.done();
|
| +
|
| + // Image diff will verify seekbar painting is correct.
|
| + if (window.testRunner)
|
| + testRunner.notifyDone();
|
| + });
|
| + });
|
| + });
|
| + });
|
| + });
|
| + }, 'Verify seekbar indicates buffered range containing currentTime', test_properties);
|
| + </script>
|
| + </body>
|
| +</html>
|
|
|