Bug 1493885 - Update MediaStream-MediaElement-srcObject.https.html to spec, and bring back test that currentTime changes must be ignored. r=pehrsons
authorJan-Ivar Bruaroey <jib@mozilla.com>
Wed, 03 Oct 2018 21:37:54 +0000
changeset 488172 690011b571305eb937172d9d68e5dd4260f6e33e
parent 488171 3e1d1b6a529eb202af9a579f08e6bc293d1e4b12
child 488173 690cfe65a8c961ec5b2e56f8249498693e26edd0
push id246
push userfmarier@mozilla.com
push dateSat, 13 Oct 2018 00:15:40 +0000
reviewerspehrsons
bugs1493885
milestone64.0a1
Bug 1493885 - Update MediaStream-MediaElement-srcObject.https.html to spec, and bring back test that currentTime changes must be ignored. r=pehrsons Differential Revision: https://phabricator.services.mozilla.com/D7567
testing/web-platform/meta/mediacapture-streams/MediaStream-MediaElement-srcObject.https.html.ini
testing/web-platform/tests/mediacapture-streams/MediaStream-MediaElement-srcObject.https.html
deleted file mode 100644
--- a/testing/web-platform/meta/mediacapture-streams/MediaStream-MediaElement-srcObject.https.html.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[MediaStream-MediaElement-srcObject.https.html]
-  [Tests that a MediaStream can be assigned to a video element with srcObject]
-    expected: FAIL
-
--- a/testing/web-platform/tests/mediacapture-streams/MediaStream-MediaElement-srcObject.https.html
+++ b/testing/web-platform/tests/mediacapture-streams/MediaStream-MediaElement-srcObject.https.html
@@ -18,36 +18,44 @@ via the <code>srcObject</code> attribute
 <script src=/resources/testharness.js></script>
 <script src=/resources/testharnessreport.js></script>
 <script>
 var vid = document.getElementById("vid");
 var t = async_test("Tests that a MediaStream can be assigned to a video element with srcObject", {timeout: 10000});
 t.step(function() {
   navigator.mediaDevices.getUserMedia({video: true})
     .then(t.step_func(function (stream) {
-      var testOncePlaying = function() {
+      const testOnceTimeUpdate = function() {
          assert_equals(vid.played.length, 1, "A MediaStream's timeline always consists of a single range");
-         assert_equals(vid.played.start(0), 0, "A MediaStream's timeline always consists of a single range");
-         assert_approx_equals(vid.played.end(0), vid.currentTime, 0.0001, "A MediaStream's timeline always consists of a single range");
-         assert_equals(vid.readyState, vid.HAVE_ENOUGH_DATA, "Upon selecting a media stream, the UA sets readyState to HAVE_ENOUGH_DATA");
+         assert_equals(vid.played.start(0), 0, "A MediaStream's timeline always starts at zero");
+         assert_equals(vid.played.end(0), vid.currentTime, "A MediaStream's end MUST return the last known currentTime, says mediacapture-main");
          assert_equals(vid.duration, Infinity, " A MediaStream does not have a pre-defined duration. ");
-         var time = vid.currentTime;
 
-         assert_approx_equals(vid.currentTime, time, 0.0001, "The UA MUST ignore attempts to set the currentTime attribute");
+         var time = vid.currentTime;
+         vid.currentTime = 0;
+         assert_equals(vid.currentTime, time, "The UA MUST ignore attempts to set the currentTime attribute");
+
          // TODO add test that duration must be set to currentTime
          // when mediastream is destroyed
-         vid.removeEventListener("timeupdate", testOncePlaying, false);
-         t.done();
       }
-      vid.addEventListener("timeupdate", t.step_func(testOncePlaying), false);
+      vid.addEventListener("timeupdate", t.step_func(testOnceTimeUpdate), {once: true});
+
+      const testOnceLoadedData = function() {
+         assert_equals(vid.readyState, vid.HAVE_ENOUGH_DATA, "Upon selecting a media stream, the UA sets readyState to HAVE_ENOUGH_DATA");
+         assert_equals(vid.duration, Infinity, "A MediaStream does not have a pre-defined duration.");
+
+         vid.addEventListener("timeupdate", () => t.step_timeout(t.done()), {once: true});
+      }
+      vid.addEventListener("loadeddata", t.step_func(testOnceLoadedData), {once: true});
       vid.srcObject = stream;
       vid.play();
       assert_true(!vid.seeking, "A MediaStream is not seekable");
       assert_equals(vid.seekable.length, 0, "A MediaStream is not seekable");
       assert_equals(vid.defaultPlaybackRate, 1, "playback rate is always 1");
       assert_equals(vid.playbackRate, 1, "playback rate is always 1");
       assert_equals(vid.buffered.length, 0, "A MediaStream cannot be preloaded.  Therefore, there is no buffered timeranges");
-      assert_equals(vid.duration, vid.readyState == vid.HAVE_NOTHING ? NaN : Infinity, " A MediaStream does not have a pre-defined duration. ");
+      assert_equals(vid.readyState, vid.HAVE_NOTHING, "readyState is HAVE_NOTHING initially");
+      assert_equals(vid.duration, NaN, "A MediaStream does not have any duration initially.");
     }), function(error) {});
 });
 </script>
 </body>
 </html>