Bug 1362165: P9. Update mochitests. r=jwwang
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 26 May 2017 20:54:36 +0200
changeset 409401 2ba56b296e40a529b1b58f27b36e68248cf9500a
parent 409400 be4b872ba9092c86378faacc94c19c93ad8a5c84
child 409402 3329385fcf2d39197bb9aae5794c5429d1ccfde4
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwwang
bugs1362165
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1362165: P9. Update mochitests. r=jwwang I'm not sure what this mochitest was supposed to test, but it was doing it wrong anyway. MozReview-Commit-ID: BexSN7YgXwj
dom/media/mediasource/test/test_SeekableAfterEndOfStream.html
dom/media/mediasource/test/test_SeekableAfterEndOfStream_mp4.html
--- a/dom/media/mediasource/test/test_SeekableAfterEndOfStream.html
+++ b/dom/media/mediasource/test/test_SeekableAfterEndOfStream.html
@@ -7,43 +7,35 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-var updateCount = 0;
-
 runWithMSE(function (ms, v) {
   ms.addEventListener("sourceopen", function () {
     var sb = ms.addSourceBuffer("video/webm");
 
     fetchWithXHR("seek.webm", function (arrayBuffer) {
       sb.appendBuffer(new Uint8Array(arrayBuffer));
-      sb.addEventListener("updateend", function () {
-        updateCount++;
-        /* Ensure that we endOfStream on the first update event only as endOfStream can
-           raise more if the duration of the last buffered range and the intial duration
-           differ. See bug 1065207 */
-        if (updateCount == 1) {
-          ms.endOfStream();
-        };
+      var promises = [];
+      promises.push(once(sb, "updateend"));
+      promises.push(once(v, "loadedmetadata"));
+      Promise.all(promises).then(function () {
+        ms.endOfStream();
+        once(ms, "sourceended").then(function() {
+          var target = 2;
+          ok(v.seekable.length, "Resource is seekable");
+          ok(v.seekable.length &&
+             target >= v.seekable.start(0) &&
+             target < v.seekable.end(0), "Target is within seekable range");
+          SimpleTest.finish();
+        });
       });
     });
-
-    var target = 2;
-
-    v.addEventListener("loadedmetadata", function () {
-      ok(v.seekable.length, "Resource is seekable");
-      ok(v.seekable.length &&
-          target >= v.seekable.start(0) &&
-          target < v.seekable.end(0), "Target is within seekable range");
-      SimpleTest.finish();
-    });
   });
 });
-
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/mediasource/test/test_SeekableAfterEndOfStream_mp4.html
+++ b/dom/media/mediasource/test/test_SeekableAfterEndOfStream_mp4.html
@@ -7,43 +7,36 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-var updateCount = 0;
-
 runWithMSE(function (ms, v) {
   ms.addEventListener("sourceopen", function () {
     var sb = ms.addSourceBuffer("video/mp4");
 
     fetchWithXHR("bipbop/bipbop2s.mp4", function (arrayBuffer) {
       sb.appendBuffer(new Uint8Array(arrayBuffer));
-      sb.addEventListener("updateend", function () {
-        updateCount++;
-        /* Ensure that we endOfStream on the first update event only as endOfStream can
-           raise more if the duration of the last buffered range and the intial duration
-           differ. See bug 1065207 */
-        if (updateCount == 1) {
-          ms.endOfStream();
-        };
+      var promises = [];
+      promises.push(once(sb, "updateend"));
+      promises.push(once(v, "loadedmetadata"));
+      Promise.all(promises).then(function () {
+        ms.endOfStream();
+        once(ms, "sourceended").then(function() {
+          var target = 1.3;
+          ok(v.seekable.length, "Resource is seekable");
+          ok(v.seekable.length &&
+             target >= v.seekable.start(0) &&
+             target < v.seekable.end(0), "Target is within seekable range");
+          SimpleTest.finish();
+        });
       });
     });
-
-    var target = 1.3;
-
-    v.addEventListener("loadedmetadata", function () {
-      ok(v.seekable.length, "Resource is seekable");
-      ok(v.seekable.length &&
-          target >= v.seekable.start(0) &&
-          target < v.seekable.end(0), "Target is within seekable range");
-      SimpleTest.finish();
-    });
   });
 });
 
 </script>
 </pre>
 </body>
 </html>