summaryrefslogtreecommitdiffstats
path: root/dom/media/test/test_streams_element_capture_reset.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/media/test/test_streams_element_capture_reset.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-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/test/test_streams_element_capture_reset.html')
-rw-r--r--dom/media/test/test_streams_element_capture_reset.html134
1 files changed, 134 insertions, 0 deletions
diff --git a/dom/media/test/test_streams_element_capture_reset.html b/dom/media/test/test_streams_element_capture_reset.html
new file mode 100644
index 000000000..888c3bec9
--- /dev/null
+++ b/dom/media/test/test_streams_element_capture_reset.html
@@ -0,0 +1,134 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Test that reloading and seeking in a media element that's being captured doesn't crash</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+ <script type="text/javascript" src="manifest.js"></script>
+</head>
+<body>
+<video id="v"></video>
+<video id="vout"></video>
+<video id="vout_untilended"></video>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+SimpleTest.waitForExplicitFinish();
+
+var v = document.getElementById('v');
+var vout = document.getElementById('vout');
+var vout_untilended = document.getElementById('vout_untilended');
+
+function dumpEvent(event) {
+ var v = event.target;
+ info(v.name + " GOT EVENT " + event.type +
+ " currentTime=" + v.currentTime +
+ " paused=" + v.paused +
+ " ended=" + v.ended +
+ " readyState=" + v.readyState);
+}
+
+var events = ["timeupdate", "seeking", "seeked", "ended", "playing", "pause"];
+for (var i = 0; i < events.length; ++i) {
+ v.addEventListener(events[i], dumpEvent, false);
+}
+
+function isWithinEps(a, b, msg) {
+ ok(Math.abs(a - b) < 0.01,
+ "Got " + a + ", expected " + b + "; " + msg);
+}
+
+function isGreaterThanOrEqualEps(a, b, msg) {
+ ok(a >= b - 0.01,
+ "Got " + a + ", expected at least " + b + "; " + msg);
+}
+
+function startTest(test) {
+ var seekTime = test.duration/2;
+
+ function endedAfterReplay() {
+ isGreaterThanOrEqualEps(v.currentTime, test.duration, "checking v.currentTime at third 'ended' event");
+ isGreaterThanOrEqualEps(vout.currentTime, (test.duration - seekTime) + test.duration*2,
+ "checking vout.currentTime after seeking, playing through and reloading");
+ SimpleTest.finish();
+ };
+
+ function endedAfterSeek() {
+ isGreaterThanOrEqualEps(v.currentTime, test.duration, "checking v.currentTime at second 'ended' event");
+ isGreaterThanOrEqualEps(vout.currentTime, (test.duration - seekTime) + test.duration,
+ "checking vout.currentTime after seeking and playing through again");
+ v.removeEventListener("ended", endedAfterSeek, false);
+ v.addEventListener("ended", endedAfterReplay, false);
+ v.src = test.name + "?1";
+ v.play();
+ };
+
+ function seeked() {
+ isGreaterThanOrEqualEps(v.currentTime, seekTime, "Finished seeking");
+ isGreaterThanOrEqualEps(vout.currentTime, test.duration,
+ "checking vout.currentTime has not changed after seeking");
+ v.removeEventListener("seeked", seeked, false);
+ function dontPlayAgain() {
+ ok(false, "vout_untilended should not play again");
+ }
+ vout_untilended.addEventListener("playing", dontPlayAgain, false);
+ vout_untilended.addEventListener("ended", dontPlayAgain, false);
+ v.addEventListener("ended", endedAfterSeek, false);
+ v.play();
+ };
+
+ function ended() {
+ // Don't compare current time until both v and vout_untilended are ended,
+ // otherwise, current time could be smaller than the duration.
+ if (!v.ended || !vout_untilended.ended) {
+ return;
+ }
+
+ isGreaterThanOrEqualEps(vout.currentTime, test.duration, "checking vout.currentTime at first 'ended' event");
+ isGreaterThanOrEqualEps(v.currentTime, test.duration, "checking v.currentTime at first 'ended' event");
+ is(vout.ended, false, "checking vout has not ended");
+ is(vout_untilended.ended, true, "checking vout_untilended has actually ended");
+
+ v.removeEventListener("ended", ended, false);
+ vout_untilended.removeEventListener("ended", ended, false);
+
+ v.pause();
+ v.currentTime = seekTime;
+ v.addEventListener("seeked", seeked, false);
+ };
+
+ v.addEventListener("ended", ended, false);
+ vout_untilended.addEventListener("ended", ended, false);
+
+ function checkNoEnded() {
+ ok(false, "ended event received unexpectedly");
+ };
+
+ vout.addEventListener("ended", checkNoEnded, false);
+
+ v.src = test.name;
+ v.name = test.name;
+ v.preload = "metadata";
+
+ function loadedmetadata() {
+ vout.srcObject = v.mozCaptureStream();
+ vout.play();
+
+ vout_untilended.srcObject = v.mozCaptureStreamUntilEnded();
+ vout_untilended.play();
+
+ v.play();
+ };
+
+ v.addEventListener("loadedmetadata", loadedmetadata, {once: true});
+}
+
+var testVideo = getPlayableVideo(gSmallTests);
+if (testVideo) {
+ startTest(testVideo);
+} else {
+ todo(false, "No playable video");
+}
+</script>
+</pre>
+</body>
+</html>