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_Threshold_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_Threshold_mp4.html')
-rw-r--r-- | dom/media/mediasource/test/test_Threshold_mp4.html | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/dom/media/mediasource/test/test_Threshold_mp4.html b/dom/media/mediasource/test/test_Threshold_mp4.html new file mode 100644 index 000000000..a33dc08ec --- /dev/null +++ b/dom/media/mediasource/test/test_Threshold_mp4.html @@ -0,0 +1,84 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>MSE: data gap detection</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"> + +SimpleTest.waitForExplicitFinish(); + +runWithMSE(function(ms, el) { + +var threshold = 0.5; // gap threshold in seconds. +var fuzz = 0.000001; // fuzz when comparing double. + + once(ms, 'sourceopen').then(function() { + ok(true, "Receive a sourceopen event"); + var videosb = ms.addSourceBuffer("video/mp4"); + var vchunks = [ {start: 0, end: 3.203333}, { start: 3.203333, end: 6.406666}]; + + fetchAndLoad(videosb, 'bipbop/bipbop_video', ['init'], '.mp4') + .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', range(1, 5), '.m4s')) + .then(function() { + // We will insert a gap of threshold + videosb.timestampOffset = threshold; + return fetchAndLoad(videosb, 'bipbop/bipbop_video', range(5, 9), '.m4s'); + }).then(function() { + // HTMLMediaElement fires 'waiting' if somebody invokes |play()| before the MDSM + // has notified it of available data. Make sure that we get 'playing' before + // we starting waiting for 'waiting'. + info("Invoking play()"); + var p = once(el, 'playing'); + el.play(); + return p; + }).then(function() { + return once(el, 'waiting'); + }).then(function() { + // We're waiting for data after the start of the last frame. + // 0.033333 is the duration of the last frame. + ok(el.currentTime >= vchunks[1].end - 0.033333 + threshold - fuzz + && el.currentTime <= vchunks[1].end + threshold + fuzz, "skipped the gap properly: " + el.currentTime + " " + (vchunks[1].end + threshold)); + is(el.buffered.length, 2, "buffered range has right length"); + // Now we test that seeking will succeed despite the gap. + el.currentTime = el.buffered.end(0) + (threshold / 2); + return once(el, 'seeked'); + }).then(function() { + // Now we test that we don't pass the gap. + // Clean up our sourcebuffer by removing all data. + videosb.timestampOffset = 0; + videosb.remove(0, Infinity); + el.currentTime = 0; + el.pause(); + return once(videosb, "updateend"); + }).then(function() { + return fetchAndLoad(videosb, 'bipbop/bipbop_video', range(1, 5), '.m4s'); + }).then(function() { + // We will insert a gap of threshold + 1ms + videosb.timestampOffset = threshold + 1/1000; + return fetchAndLoad(videosb, 'bipbop/bipbop_video', range(5, 9), '.m4s'); + }).then(function() { + info("Invoking play()"); + var p = once(el, 'playing'); + el.play(); + return p; + }).then(function() { + return once(el, 'waiting'); + }).then(function() { + // We're waiting for data after the start of the last frame. + // 0.033333 is the duration of the last frame. + ok(el.currentTime >= vchunks[0].end - 0.033333 - fuzz + && el.currentTime <= vchunks[0].end + fuzz, "stopped at the gap properly: " + el.currentTime + " " + vchunks[0].end); + SimpleTest.finish(); + }); + }); +}); + +</script> +</pre> +</body> +</html> |