properly doing media assignment via srcObject with prefix
authorDominique Hazael-Massieux <dom@w3.org>
Mon, 03 Jun 2013 17:51:15 +0200
changeset 56 93a2bc8f09b4
parent 55 c65aa59152e4
child 57 405a1260a758
properly doing media assignment via srcObject with prefix
a few more checks
submitted/W3C/video-assignment.html
--- a/submitted/W3C/video-assignment.html	Mon Jun 03 17:49:23 2013 +0200
+++ b/submitted/W3C/video-assignment.html	Mon Jun 03 17:51:15 2013 +0200
@@ -24,31 +24,33 @@
 t.step(function() {
   navigator.getUserMedia({video: true}, t.step_func(function (stream) {
     // TODO remove when prefixes are gone
-    var srcObj = BrowserHasFeature(vid, "srcObject");
-    if (!vid.srcObject && undefined !== srcObj) {
-       vid.srcObject = srcObj;
-    } 
-    vid.addEventListener("timeupdate", t.step_func(function() {
+    var srcObjName = FeatureNameInBrowser(vid, "srcObject");
+    var testOncePlaying = 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_equals(vid.played.end(0), vid.currentTime, "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");
-       var t = vid.currentTime;
-       vid.currentTime = 0;
-       assert_equals(vid.currentTime, t, "The UA MUST ignore attempts to set the currentTime attribute");
+       var time = vid.currentTime;
+       // not as in spec yet, see https://www.w3.org/Bugs/Public/show_bug.cgi?id=22249
+       assert_throws("INVALID_STATE_ERR", function() {
+          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
-       t.done();
-       
-    }), false);
-
-    vid.srcObject = stream;
+       vid.removeEventListener("timeupdate", testOncePlaying, false);
+       t.done();       
+    }
+    vid.addEventListener("timeupdate", t.step_func(testOncePlaying), false);
+    vid.autoplay = true;
+    vid[srcObjName] = 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.preload, "none", "A MediaStream cannot be preloaded.");
+    // TODO re-enable after resolution of see https://www.w3.org/Bugs/Public/show_bug.cgi?id=22247#c1 ?
+    // assert_equals(vid.preload, "none", "A MediaStream cannot be preloaded.");
     // not as in spec, see https://www.w3.org/Bugs/Public/show_bug.cgi?id=22246
     assert_equals(vid.buffered.length, 0, "A MediaStream cannot be preloaded.  Therefore, there is no buffered timeranges");
     assert_equals(vid.duration, Infinity, " A MediaStream does not have a pre-defined duration. ");
@@ -56,8 +58,7 @@
     assert_true(!vid.loop, "A MediaStream cannot be looped");
     vid.loop = true;
     // not sure about that one https://www.w3.org/Bugs/Public/show_bug.cgi?id=22247
-    assert_true(!vid.loop, "Setting looped to true in a MediaStream is a no-op");
-    t.done();
+    //assert_true(!vid.loop, "Setting looped to true in a MediaStream is a no-op");
   }), function(error) {});
 });
 </script>