Bug 1320258. Part 1 - add a test case to test 'ended' is fired when seeking to the end of media. r=jya
authorJW Wang <jwwang@mozilla.com>
Fri, 25 Nov 2016 15:06:30 +0800
changeset 324614 08264c30352ddcb6c2c98b5def210fbfac6fc983
parent 324613 9aba8184664ddfca0ae5c95d9ab5f7e8daab049e
child 324615 cd9a0b0df8a32c3caef445bc8c0ef4fd984331ab
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersjya
bugs1320258
milestone53.0a1
Bug 1320258. Part 1 - add a test case to test 'ended' is fired when seeking to the end of media. r=jya MozReview-Commit-ID: 4cS9GiTYB7l
dom/media/mediasource/test/mochitest.ini
dom/media/mediasource/test/test_EndedEvent.html
--- a/dom/media/mediasource/test/mochitest.ini
+++ b/dom/media/mediasource/test/mochitest.ini
@@ -55,16 +55,17 @@ skip-if = toolkit == 'android' #timeout 
 [test_BufferingWait_mp4.html]
 skip-if = ((os == "win" && os_version == "5.1") || (toolkit == 'android')) # Not supported on xp and android 2.3
 [test_DrainOnMissingData_mp4.html]
 skip-if = ((os == "win" && os_version == "5.1") || (toolkit == 'android')) # Not supported on xp and android 2.3
 [test_DurationChange.html]
 [test_DurationUpdated.html]
 [test_DurationUpdated_mp4.html]
 skip-if = ((os == "win" && os_version == "5.1") || (toolkit == 'android')) # Not supported on xp and android 2.3
+[test_EndedEvent.html]
 [test_EndOfStream.html]
 [test_EndOfStream_mp4.html]
 skip-if = ((os == "win" && os_version == "5.1") || (toolkit == 'android')) # Not supported on xp and android 2.3
 [test_Eviction_mp4.html]
 skip-if = (os == "win" && os_version == "5.1") # Not supported on xp.
 [test_FrameSelection.html]
 [test_FrameSelection_mp4.html]
 skip-if = ((os == "win" && os_version == "5.1") || (toolkit == 'android')) # Not supported on xp and android 2.3
new file mode 100644
--- /dev/null
+++ b/dom/media/mediasource/test/test_EndedEvent.html
@@ -0,0 +1,33 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>MSE: basic functionality</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) {
+  once(ms, 'sourceopen').then(function() {
+    var sb = ms.addSourceBuffer("video/webm");
+    fetchWithXHR("seek.webm", (buf) => sb.appendBuffer(new Uint8Array(buf)));
+    sb.addEventListener("updateend", () => ms.endOfStream());
+
+    // Test 'ended' is fired when seeking to the end of the media
+    // once the duration is known.
+    el.onloadedmetadata = () => {
+      el.currentTime = el.duration;
+    };
+    el.addEventListener("ended", SimpleTest.finish.bind(null));
+  });
+});
+
+</script>
+</pre>
+</body>
+</html>