Bug 1320258. Part 1 - add a test case to test 'ended' is fired when seeking to the end of media. r?jya draft
authorJW Wang <jwwang@mozilla.com>
Fri, 25 Nov 2016 15:06:30 +0800
changeset 445181 59a46228429d9ab1184b61f0d7f06aae9147772b
parent 445180 b1efee4ead0550f5e08cbc41a0a84f15f5d99912
child 445182 93163ba716b73c194faf98f1497439e7878222e7
push id37454
push userjwwang@mozilla.com
push dateTue, 29 Nov 2016 09:37:48 +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>