diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/media/mediasource/test/test_TruncatedDuration_mp4.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/media/mediasource/test/test_TruncatedDuration_mp4.html')
-rw-r--r-- | dom/media/mediasource/test/test_TruncatedDuration_mp4.html | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/dom/media/mediasource/test/test_TruncatedDuration_mp4.html b/dom/media/mediasource/test/test_TruncatedDuration_mp4.html new file mode 100644 index 000000000..f226093de --- /dev/null +++ b/dom/media/mediasource/test/test_TruncatedDuration_mp4.html @@ -0,0 +1,83 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>MSE: truncating the media seeks to end of media and update buffered range</title> + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <script type="text/javascript" src="mediasource.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +<pre id="test"> +<script class="testbody" type="text/javascript"> + +// This test append data to a mediasource and then seek to half the duration +// of the video. +// We then shorten the video to 1/3rd of its original size. +// We ensure that the buffered range immediately reflect the truncation +// and that we've seeked to the new end of the media as per W3C spec and +// video.currentTime got updated. + +SimpleTest.waitForExplicitFinish(); + +function round(n) { + return Math.round(n * 1000) / 1000; +} + +function do_seeking(e) { + var v = e.target; + v.removeEventListener("seeking", do_seeking, false); + SimpleTest.finish(); +} + +function do_seeked(e) { + var v = e.target; + v.removeEventListener("seeked", do_seeked, false); + var duration = round(v.duration / 3); + is(v._sb.updating, false, "sourcebuffer isn't updating"); + v._sb.remove(duration, Infinity); + once(v._sb, "updateend", function() { + v._ms.duration = duration + // frames aren't truncated, so duration may be slightly more. + isfuzzy(v.duration, duration, 1/30, "element duration was updated"); + v._sb.abort(); // this shouldn't abort updating the duration (bug 1130826). + ok(v.seeking, "seeking is true"); + // test playback position was updated (bug 1130839). + is(v.currentTime, v.duration, "current time was updated"); + is(v._sb.buffered.length, 1, "One buffered range"); + // Truncated mediasource duration will cause the video element to seek. + v.addEventListener("seeking", do_seeking, false); + }); +} + +function do_loaded(e) { + var v = e.target; + v.removeEventListener("loadeddata", do_loaded, false); + // mp4 metadata states 10s when we only have 1.6s worth of video. + v._sb.remove(v._sb.buffered.end(0), Infinity); + once(v._sb, "updateend", function() { + v._ms.duration = v._sb.buffered.end(0); + is(v.duration, v._ms.duration, "current time updated with mediasource duration"); + v.currentTime = v.duration / 2; + is(v.currentTime, v.duration / 2, "current time was updated"); + ok(v.seeking, "seeking is true"); + v.addEventListener("seeked", do_seeked, false); + }); +} + +runWithMSE(function (ms, v) { + ms.addEventListener("sourceopen", function () { + var sb = ms.addSourceBuffer("video/mp4"); + v._sb = sb; + v._ms = ms; + + fetchWithXHR("bipbop/bipbop2s.mp4", function (arrayBuffer) { + sb.appendBuffer(new Uint8Array(arrayBuffer)); + v.addEventListener("loadeddata", do_loaded, false); + }); + }); +}); + +</script> +</pre> +</body> +</html> |